linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Zi Yan <ziy@nvidia.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	Johannes Weiner <hannes@cmpxchg.org>,
	David Hildenbrand <david@redhat.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH] mm/page_alloc: check the correct buddy if it is a starting block
Date: Fri, 5 Sep 2025 03:11:30 +0000	[thread overview]
Message-ID: <20250905031129.lgipzjwz2swhxlg7@master> (raw)
In-Reply-To: <D9D94987-8A36-41F0-B0A8-3BB47910223E@nvidia.com>

On Thu, Sep 04, 2025 at 10:01:01PM -0400, Zi Yan wrote:
>On 3 Sep 2025, at 22:06, Wei Yang wrote:
>
>> find_large_buddy() search buddy based on start_pfn, which maybe
>> different from page's pfn, e.g. when page is not pageblock aligned,
>> because prep_move_freepages_block() always align start_pfn to pageblock.
>>
>> This means when we found a starting block at start_pfn, it may check
>> on the wrong page theoretically.
>
>and not split the free page as it is supposed to, causing a freelist migratetype
>mismatch.
>

Thanks, this is important.

>>
>> The good news is the page passed to __move_freepages_block_isolate() has
>> only two possible cases:
>>
>>   * page is pageblock aligned
>>   * page is __first_valid_page() of this block
>>
>> So it is safe for the first case, and it won't get a buddy larger than
>> pageblock for the second case.
>>
>> To eliminate the ambiguity, unify the handling for starting/tail block.
>
>To fix the issue, check the returned pfn of find_large_buddy() to decide
>whether to split the free page:
>1. if it is not a PageBuddy pfn, no split;
>2. if it is a PageBuddy pfn but order <= pageblock_order, no split;
>3. if it is a PageBuddy pfn with order > pageblock_order,
>   start_pfn is either in the starting block or tail block, split the PageBuddy
>   at pageblock_order level.
>
>
>Otherwise, LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>

Thanks.

@Andrew, if not bother, would you mind adjust the changelog?

-- 
Wei Yang
Help you, Help me


  reply	other threads:[~2025-09-05  3:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04  2:06 Wei Yang
2025-09-05  2:01 ` Zi Yan
2025-09-05  3:11   ` Wei Yang [this message]
2025-09-05  3:25     ` Andrew Morton
2025-09-05  9:40 ` David Hildenbrand
2025-09-05 13:35   ` Wei Yang

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=20250905031129.lgipzjwz2swhxlg7@master \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    --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