mm, page_alloc: fail has_unmovable_pages when seeing reserved pages
[sfrench/cifs-2.6.git] / mm / page_alloc.c
index 77e4d3c5c57b72dcd7e411a03707c26dc85c7c04..e6106d7e9eb04d3460692985167811faf943b8e1 100644 (file)
@@ -7353,10 +7353,10 @@ void *__init alloc_large_system_hash(const char *tablename,
  * race condition. So you can't expect this function should be exact.
  */
 bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
+                        int migratetype,
                         bool skip_hwpoisoned_pages)
 {
        unsigned long pfn, iter, found;
-       int mt;
 
        /*
         * For avoiding noise data, lru_add_drain_all() should be called
@@ -7364,8 +7364,14 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
         */
        if (zone_idx(zone) == ZONE_MOVABLE)
                return false;
-       mt = get_pageblock_migratetype(page);
-       if (mt == MIGRATE_MOVABLE || is_migrate_cma(mt))
+
+       /*
+        * CMA allocations (alloc_contig_range) really need to mark isolate
+        * CMA pageblocks even when they are not movable in fact so consider
+        * them movable here.
+        */
+       if (is_migrate_cma(migratetype) &&
+                       is_migrate_cma(get_pageblock_migratetype(page)))
                return false;
 
        pfn = page_to_pfn(page);
@@ -7377,6 +7383,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
 
                page = pfn_to_page(check);
 
+               if (PageReserved(page))
+                       return true;
+
                /*
                 * Hugepages are not in LRU lists, but they're movable.
                 * We need not scan over tail pages bacause we don't
@@ -7450,7 +7459,7 @@ bool is_pageblock_removable_nolock(struct page *page)
        if (!zone_spans_pfn(zone, pfn))
                return false;
 
-       return !has_unmovable_pages(zone, page, 0, true);
+       return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE, true);
 }
 
 #if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA)