Skip to content

Commit 3da0272

Browse files
Kemeng Shiakpm00
authored andcommitted
mm/compaction: correctly return failure with bogus compound_order in strict mode
In strict mode, we should return 0 if there is any hole in pageblock. If we successfully isolated pages at beginning at pageblock and then have a bogus compound_order outside pageblock in next page. We will abort search loop with blockpfn > end_pfn. Although we will limit blockpfn to end_pfn, we will treat it as a successful isolation in strict mode as blockpfn is not < end_pfn and return partial isolated pages. Then isolate_freepages_range may success unexpectly with hole in isolated range. Link: https://lkml.kernel.org/r/[email protected] Fixes: 9fcd6d2 ("mm, compaction: skip compound pages by order in free scanner") Signed-off-by: Kemeng Shi <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Acked-by: Mel Gorman <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4c17989 commit 3da0272

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/compaction.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,12 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
626626
if (PageCompound(page)) {
627627
const unsigned int order = compound_order(page);
628628

629-
if (likely(order <= MAX_ORDER)) {
629+
if (blockpfn + (1UL << order) <= end_pfn) {
630630
blockpfn += (1UL << order) - 1;
631631
page += (1UL << order) - 1;
632632
nr_scanned += (1UL << order) - 1;
633633
}
634+
634635
goto isolate_fail;
635636
}
636637

@@ -678,8 +679,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
678679
spin_unlock_irqrestore(&cc->zone->lock, flags);
679680

680681
/*
681-
* There is a tiny chance that we have read bogus compound_order(),
682-
* so be careful to not go outside of the pageblock.
682+
* Be careful to not go outside of the pageblock.
683683
*/
684684
if (unlikely(blockpfn > end_pfn))
685685
blockpfn = end_pfn;

0 commit comments

Comments
 (0)