Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/page_alloc: find_large_buddy() from start_pfn aligned order

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.

[richard.weiyang@gmail.com: 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
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 <richard.weiyang@gmail.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wei Yang and committed by
Andrew Morton
204dfefe c66ae644

+7 -1
+7 -1
mm/page_alloc.c
··· 2033 2033 /* Look for a buddy that straddles start_pfn */ 2034 2034 static unsigned long find_large_buddy(unsigned long start_pfn) 2035 2035 { 2036 - int order = 0; 2036 + /* 2037 + * If start_pfn is not an order-0 PageBuddy, next PageBuddy containing 2038 + * start_pfn has minimal order of __ffs(start_pfn) + 1. Start checking 2039 + * the order with __ffs(start_pfn). If start_pfn is order-0 PageBuddy, 2040 + * the starting order does not matter. 2041 + */ 2042 + int order = start_pfn ? __ffs(start_pfn) : MAX_PAGE_ORDER; 2037 2043 struct page *page; 2038 2044 unsigned long pfn = start_pfn; 2039 2045