From ed7de9af1a010c4eb5c1a0aab76aa0983f4fd3cc Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Tue, 2 Sep 2025 02:58:07 +0000 Subject: [PATCH] mm-page_alloc-find_large_buddy-from-start_pfn-aligned-order-v2 add comment on assignment of order Link: https://lkml.kernel.org/r/20250828091618.7869-1-richard.weiyang@gmail.com Link: https://lkml.kernel.org/r/20250902025807.11467-1-richard.weiyang@gmail.com Signed-off-by: Wei Yang Reviewed-by: Zi Yan Cc: Johannes Weiner Cc: Vlastimil Babka Cc: David Hildenbrand Signed-off-by: Andrew Morton --- mm/page_alloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d8b7268f19f74..0873d640f26cc 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2033,6 +2033,12 @@ 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) { + /* + * If start_pfn is not an order-0 PageBuddy, next PageBuddy containing + * start_pfn has minimal order of __ffs(start_pfn) + 1. Start checking + * the order with __ffs(start_pfn). If start_pfn is order-0 PageBuddy, + * the starting order does not matter. + */ int order = start_pfn ? __ffs(start_pfn) : MAX_PAGE_ORDER; struct page *page; unsigned long pfn = start_pfn; -- 2.51.0