thp: cleanup: introduce mk_huge_pmd()
[firefly-linux-kernel-4.4.55.git] / mm / compaction.c
index 2c4ce17651d825c97c7d89ecea52bf53f17ce0aa..694eaabaaebdc0827c93d81c97f200fc534a115e 100644 (file)
@@ -346,7 +346,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
         * pages requested were isolated. If there were any failures, 0 is
         * returned and CMA will fail.
         */
-       if (strict && nr_strict_required != total_isolated)
+       if (strict && nr_strict_required > total_isolated)
                total_isolated = 0;
 
        if (locked)
@@ -713,7 +713,15 @@ static void isolate_freepages(struct zone *zone,
 
                /* Found a block suitable for isolating free pages from */
                isolated = 0;
-               end_pfn = min(pfn + pageblock_nr_pages, zone_end_pfn);
+
+               /*
+                * As pfn may not start aligned, pfn+pageblock_nr_page
+                * may cross a MAX_ORDER_NR_PAGES boundary and miss
+                * a pfn_valid check. Ensure isolate_freepages_block()
+                * only scans within a pageblock
+                */
+               end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
+               end_pfn = min(end_pfn, zone_end_pfn);
                isolated = isolate_freepages_block(cc, pfn, end_pfn,
                                                   freelist, false);
                nr_freepages += isolated;