linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, hannes@cmpxchg.org, ziy@nvidia.com
Cc: linux-mm@kvack.org, vishal.moola@gmail.com,
	David Hildenbrand <david@redhat.com>
Subject: Re: [Patch v2] mm/page_alloc: find_large_buddy() from start_pfn aligned order
Date: Tue, 2 Sep 2025 10:04:53 +0200	[thread overview]
Message-ID: <4cb33d86-12c9-4b60-bcd4-e9f9ea5a0b16@suse.cz> (raw)
In-Reply-To: <20250902025807.11467-1-richard.weiyang@gmail.com>

On 9/2/25 04:58, Wei Yang wrote:
> 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.
> 
> Link: https://lkml.kernel.org/r/20250828091618.7869-1-richard.weiyang@gmail.com
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: David Hildenbrand <david@redhat.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Reviewed-by: Zi Yan <ziy@nvidia.com>

Reviewed-by: Vlastimil Babka <vbabka@suse.cz>

> 
> ---
> v2: add comment on assignment of order
> ---
>  mm/page_alloc.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 07d79ae557f8..5d9ceca869e5 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2033,7 +2033,13 @@ 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;
> +	/*
> +	 * 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;
>  



  reply	other threads:[~2025-09-02  8:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  2:58 Wei Yang
2025-09-02  8:04 ` Vlastimil Babka [this message]
2025-09-02 14:33 ` Johannes Weiner
2025-09-02 14:36   ` Zi Yan
2025-09-02 15:12     ` Johannes Weiner
2025-09-02 16:25 ` Vishal Moola (Oracle)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4cb33d86-12c9-4b60-bcd4-e9f9ea5a0b16@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=richard.weiyang@gmail.com \
    --cc=vishal.moola@gmail.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox