Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Jiaqi Yan <jiaqiyan@google.com>, Zi Yan <ziy@nvidia.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>,
	harry.yoo@oracle.com, osalvador@suse.de,
	lorenzo.stoakes@oracle.com, jackmanb@google.com,
	hannes@cmpxchg.org, nao.horiguchi@gmail.com, david@kernel.org,
	william.roche@oracle.com, tony.luck@intel.com,
	wangkefeng.wang@huawei.com, jane.chu@oracle.com,
	akpm@linux-foundation.org, muchun.song@linux.dev,
	liam@infradead.org, rientjes@google.com, duenwen@google.com,
	jthoughton@google.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, vbabka@suse.cz, rppt@kernel.org,
	shuah@kernel.org, surenb@google.com, mhocko@suse.com,
	boudewijn@delta-utec.com, ljs@kernel.org, osalvador@kernel.org,
	willy@infradead.org
Subject: Re: [PATCH v5 1/4] mm/page_alloc: only free healthy pages in high-order has_hwpoisoned folio
Date: Mon, 22 Jun 2026 10:35:44 +0200	[thread overview]
Message-ID: <c8ab2147-c6aa-480f-bfe2-55f095b55add@kernel.org> (raw)
In-Reply-To: <CACw3F53jgq5JS+0qkC3Jmj-jkDRHm1H_Z=Xvv-jKoL5XHy11sg@mail.gmail.com>

On 6/22/26 03:13, Jiaqi Yan wrote:
> On Thu, Jun 18, 2026 at 9:04 AM Zi Yan <ziy@nvidia.com> wrote:
>> >> when copy fails with EHWPOISON), the next list_add() is going to cause
>> >
>> > I think we should fix compaction_free() (as a separate patch preceding this
>> > one) to not proceed if prepare returns false. It could in theory already
>> > happen before this patch due to a random memory corruption of struct page
>> > causing some of the existing checks to fail.
>>
>> Something like below should do the job, plus
>> Fixes: 733aea0b3a7bb ("mm/compaction: add support for >0 order folio memory compaction.")
>>
>> diff --git a/mm/compaction.c b/mm/compaction.c
>> index b776f35ad0200..b2104cbe63477 100644
>> --- a/mm/compaction.c
>> +++ b/mm/compaction.c
>> @@ -1876,10 +1876,12 @@ static void compaction_free(struct folio *dst, unsigned long data)
>>         struct page *page = &dst->page;
>>
>>         if (folio_put_testzero(dst)) {
>> -               free_pages_prepare(page, order);
>> +               if (!free_pages_prepare(page, order))
> 
> ... for other cases that free_pages_prepare() fails, this is
> absolutely necessary for correctness. Do you mind sending it out for
> formal review (I will be happy to help review).

I think it would be faster if you just added it to your series with a
Suggested-by: or something? Unless Zi objects. The change is straightforward.

I'd perhaps do just a

if (folio_put_testzero(dst) && free_pages_prepare(page, order))

to avoid the goto?

>> +                       goto skip;
>>                 list_add(&dst->lru, &cc->freepages[order]);
>>                 cc->nr_freepages += 1 << order;
>>         }
>> +skip:
>>         cc->nr_migratepages += 1 << order;
>>         /*
>>          * someone else has referenced the page, we cannot take it back to our

Maybe in the comment here add also the possibility that _prepare failed().

>>
>> >
>> >> trouble. Or you can rename the function to
>> >> __free_pages_prepare_and_free_has_hwpoison()? At least, caller knows the
>> >> potential side effect.
>> >
>> > Uh that's long. All callers are from PAGE ALLOCATOR mm-subsystem, it's not a
>> > driver API so we'll know what we're doing (famous last words :)
>>
>> The name above is a half joke. :)
>>
>> BTW, I do not even trust myself sometimes. ;) Just look at the
>> compaction_free() issue I introduced myself. But I do not want to be too
>> pedantic here. So a comment above __free_pages_prepare() should be
>> sufficient.
> 
> There is already a comment about the possible freeing case.
> 
>>
>> --
>> Best Regards,
>> Yan, Zi
>>



  reply	other threads:[~2026-06-22  8:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-31  5:58 [PATCH v5 0/4] Only free healthy pages in high-order has_hwpoisoned folio Jiaqi Yan
2026-05-31  5:58 ` [PATCH v5 1/4] mm/page_alloc: only " Jiaqi Yan
2026-06-09  3:44   ` Miaohe Lin
2026-06-12 18:34     ` Zi Yan
     [not found]       ` <CACw3F51hi1SAs264i0FKMbieOQhCpRQQ9s7gS_cHDYgHsqu0WQ@mail.gmail.com>
2026-06-17  1:56         ` Zi Yan
2026-06-18 14:52           ` Vlastimil Babka (SUSE)
2026-06-18 16:04             ` Zi Yan
2026-06-22  1:13               ` Jiaqi Yan
2026-06-22  8:35                 ` Vlastimil Babka (SUSE) [this message]
     [not found]         ` <ce2f2cea-1451-09a4-4562-62808b1c2d93@huawei.com>
2026-06-18 15:02           ` Vlastimil Babka (SUSE)
2026-06-22  1:12             ` Jiaqi Yan
2026-06-22  8:30               ` Vlastimil Babka (SUSE)
2026-06-22  1:12           ` Jiaqi Yan
2026-06-15  2:03     ` Jiaqi Yan
2026-05-31  5:58 ` [PATCH v5 2/4] mm/memory-failure: set has_hwpoisoned flags on dissolved HugeTLB folio Jiaqi Yan
2026-06-09  6:34   ` Miaohe Lin
2026-05-31  5:58 ` [PATCH v5 3/4] mm/memory-failure: skip take_page_off_buddy after dissolving HWPoison HugeTLB page Jiaqi Yan
2026-06-09  7:21   ` Miaohe Lin
2026-06-15  0:16     ` Jiaqi Yan
2026-05-31  5:58 ` [PATCH v5 4/4] selftests/mm: add hard memory failure anonymous 1G HugeTLB page test Jiaqi Yan
2026-06-01 18:04   ` Jiaqi Yan
2026-06-17  7:38   ` Miaohe Lin

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=c8ab2147-c6aa-480f-bfe2-55f095b55add@kernel.org \
    --to=vbabka@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=boudewijn@delta-utec.com \
    --cc=david@kernel.org \
    --cc=duenwen@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=harry.yoo@oracle.com \
    --cc=jackmanb@google.com \
    --cc=jane.chu@oracle.com \
    --cc=jiaqiyan@google.com \
    --cc=jthoughton@google.com \
    --cc=liam@infradead.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nao.horiguchi@gmail.com \
    --cc=osalvador@kernel.org \
    --cc=osalvador@suse.de \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=tony.luck@intel.com \
    --cc=vbabka@suse.cz \
    --cc=wangkefeng.wang@huawei.com \
    --cc=william.roche@oracle.com \
    --cc=willy@infradead.org \
    --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