From: jane.chu@oracle.com
To: Chris Mason <clm@meta.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
stable@vger.kernel.org, muchun.song@linux.dev, osalvador@suse.de,
david@kernel.org, linmiaohe@huawei.com, jiaqiyan@google.com,
william.roche@oracle.com, rientjes@google.com,
akpm@linux-foundation.org, lorenzo.stoakes@oracle.com,
Liam.Howlett@Oracle.com, rppt@kernel.org, surenb@google.com,
mhocko@suse.com, willy@infradead.org
Subject: Re: [PATCH v4 1/2] mm/memory-failure: fix missing ->mf_stats count in hugetlb poison
Date: Wed, 14 Jan 2026 10:15:25 -0800 [thread overview]
Message-ID: <43df0859-ee93-45cb-9c1f-5492df613ac1@oracle.com> (raw)
In-Reply-To: <20260114153749.3004663-1-clm@meta.com>
On 1/14/2026 7:37 AM, Chris Mason wrote:
> On Tue, 13 Jan 2026 01:07:50 -0700 Jane Chu <jane.chu@oracle.com> wrote:
>
>> When a newly poisoned subpage ends up in an already poisoned hugetlb
>> folio, 'num_poisoned_pages' is incremented, but the per node ->mf_stats
>> is not. Fix the inconsistency by designating action_result() to update
>> them both.
>>
>> While at it, define __get_huge_page_for_hwpoison() return values in terms
>> of symbol names for better readibility. Also rename
>> folio_set_hugetlb_hwpoison() to hugetlb_update_hwpoison() since the
>> function does more than the conventional bit setting and the fact
>> three possible return values are expected.
>>
>
> Hi everyone,
>
> I ran mm-new through the AI patch review prompts, and this commit was flagged.
> The review below looks right to me:
>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>
> [ ... ]
>
>> @@ -2029,22 +2037,29 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb)
>> *hugetlb = 1;
>> retry:
>> res = get_huge_page_for_hwpoison(pfn, flags, &migratable_cleared);
>> - if (res == 2) { /* fallback to normal page handling */
>> + switch (res) {
>> + case -EINVAL: /* fallback to normal page handling */
>> *hugetlb = 0;
>> return 0;
>> - } else if (res == -EHWPOISON) {
>> - if (flags & MF_ACTION_REQUIRED) {
>> - folio = page_folio(p);
>> - res = kill_accessing_process(current, folio_pfn(folio), flags);
>> - }
>> - action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED);
>> - return res;
>> - } else if (res == -EBUSY) {
>> + case -EBUSY:
>> if (!(flags & MF_NO_RETRY)) {
>> flags |= MF_NO_RETRY;
>> goto retry;
>> }
>> return action_result(pfn, MF_MSG_GET_HWPOISON, MF_IGNORED);
>> + case MF_HUGETLB_FOLIO_PRE_POISONED:
>> + case MF_HUGETLB_PAGE_PRE_POISON:
>> + if (flags & MF_ACTION_REQUIRED) {
>> + folio = page_folio(p);
>> + res = kill_accessing_process(current, folio_pfn(folio), flags);
>> + }
>> + if (res == MF_HUGETLB_FOLIO_PRE_POISONED)
>
> When MF_ACTION_REQUIRED is set, kill_accessing_process() overwrites res
> before this check. kill_accessing_process() returns either 0 or
> -EHWPOISON, so the check for MF_HUGETLB_FOLIO_PRE_POISONED (which is 3)
> will always be false in that path.
>
> This means action_result() will be called with MF_MSG_HUGE instead of
> MF_MSG_ALREADY_POISONED. Looking at action_result():
>
> if (type != MF_MSG_ALREADY_POISONED && type != MF_MSG_PFN_MAP) {
> num_poisoned_pages_inc(pfn);
> update_per_node_mf_stats(pfn, result);
> }
>
> Does this cause incorrect counter increments for already-poisoned pages
> when MF_ACTION_REQUIRED is set? The original code called action_result()
> unconditionally with MF_MSG_ALREADY_POISONED regardless of whether
> kill_accessing_process() was called.
>
> Should a separate variable preserve the original res value before the
> call to kill_accessing_process()?
Good catch! William Roche has also pointed out the same issue to me in
private. I will fix it in v5 soon.
thanks,
-jane
>
>> + action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED);
>> + else
>> + action_result(pfn, MF_MSG_HUGE, MF_FAILED);
>> + return res;
>
>
>
prev parent reply other threads:[~2026-01-14 18:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 8:07 Jane Chu
2026-01-13 8:07 ` [PATCH v4 2/2] mm/memory-failure: teach kill_accessing_process to accept hugetlb tail page pfn Jane Chu
2026-01-13 23:22 ` [PATCH v4 1/2] mm/memory-failure: fix missing ->mf_stats count in hugetlb poison Andrew Morton
2026-01-14 15:37 ` Chris Mason
2026-01-14 18:15 ` jane.chu [this message]
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=43df0859-ee93-45cb-9c1f-5492df613ac1@oracle.com \
--to=jane.chu@oracle.com \
--cc=Liam.Howlett@Oracle.com \
--cc=akpm@linux-foundation.org \
--cc=clm@meta.com \
--cc=david@kernel.org \
--cc=jiaqiyan@google.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=william.roche@oracle.com \
--cc=willy@infradead.org \
/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