The patch titled Subject: mm, compaction: abort free scanner if split fails has been added to the -mm tree. Its filename is mm-compaction-abort-free-scanner-if-split-fails.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-compaction-abort-free-scanner-if-split-fails.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-compaction-abort-free-scanner-if-split-fails.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: David Rientjes <rientjes@xxxxxxxxxx> Subject: mm, compaction: abort free scanner if split fails If the memory compaction free scanner cannot successfully split a free page (only possible due to per-zone low watermark), terminate the free scanner rather than continuing to scan memory needlessly. If the per-zone watermark is insufficient for a free page of order <= cc->order, then terminate the scanner since future splits will also likely fail. This prevents the compaction freeing scanner from scanning all memory on very large zones (very noticeable for zones > 128GB, for instance) when all splits will likely fail. Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1606211447360.43430@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/compaction.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff -puN mm/compaction.c~mm-compaction-abort-free-scanner-if-split-fails mm/compaction.c --- a/mm/compaction.c~mm-compaction-abort-free-scanner-if-split-fails +++ a/mm/compaction.c @@ -496,7 +496,7 @@ static unsigned long isolate_freepages_b order = page_order(page); isolated = __isolate_free_page(page, order); if (!isolated) - goto isolate_fail; + break; set_page_private(page, order); total_isolated += isolated; list_add_tail(&page->lru, freelist); @@ -518,6 +518,9 @@ isolate_fail: } + if (locked) + spin_unlock_irqrestore(&cc->zone->lock, flags); + /* * There is a tiny chance that we have read bogus compound_order(), * so be careful to not go outside of the pageblock. @@ -539,9 +542,6 @@ isolate_fail: if (strict && blockpfn < end_pfn) total_isolated = 0; - if (locked) - spin_unlock_irqrestore(&cc->zone->lock, flags); - /* Update the pageblock-skip if the whole pageblock was scanned */ if (blockpfn == end_pfn) update_pageblock_skip(cc, valid_page, total_isolated, false); @@ -1066,6 +1066,7 @@ static void isolate_freepages(struct com block_end_pfn = block_start_pfn, block_start_pfn -= pageblock_nr_pages, isolate_start_pfn = block_start_pfn) { + unsigned long isolated; /* * This can iterate a massively long zone without finding any @@ -1090,8 +1091,12 @@ static void isolate_freepages(struct com continue; /* Found a block suitable for isolating free pages from. */ - isolate_freepages_block(cc, &isolate_start_pfn, - block_end_pfn, freelist, false); + isolated = isolate_freepages_block(cc, &isolate_start_pfn, + block_end_pfn, freelist, false); + /* If isolation failed, do not continue needlessly */ + if (!isolated && isolate_start_pfn < block_end_pfn && + cc->nr_freepages <= cc->nr_migratepages) + break; /* * If we isolated enough freepages, or aborted due to async _ Patches currently in -mm which might be from rientjes@xxxxxxxxxx are mm-compaction-split-freepages-without-holding-the-zone-lock-fix.patch mm-compaction-abort-free-scanner-if-split-fails.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html