We iterate pfn from order 0 to MAX_PAGE_ORDER aligned to find large buddy. While if the order is less than start_pfn aligned order, we would get the same pfn and do the same check again. Iterate from start_pfn aligned order to reduce duplicated work. Signed-off-by: Wei Yang Cc: Johannes Weiner Cc: Zi Yan Cc: Vlastimil Babka Cc: David Hildenbrand --- I build this and run, but not sure how fully test this. --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 27ea4c7acd15..7f2dfd30106f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2033,7 +2033,7 @@ static int move_freepages_block(struct zone *zone, struct page *page, /* Look for a buddy that straddles start_pfn */ static unsigned long find_large_buddy(unsigned long start_pfn) { - int order = 0; + int order = start_pfn ? __ffs(start_pfn) : MAX_PAGE_ORDER; struct page *page; unsigned long pfn = start_pfn; -- 2.34.1