From: Zi Yan <ziy@nvidia.com>
To: Balbir Singh <balbirs@nvidia.com>
Cc: David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Miaohe Lin <linmiaohe@huawei.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/3] mm/memory-failure: handle min_order_for_split() error code properly
Date: Thu, 20 Nov 2025 10:00:55 -0500 [thread overview]
Message-ID: <86CBD3DE-2245-4C79-BDA3-4977548898E3@nvidia.com> (raw)
In-Reply-To: <b7af446a-eb74-483f-8a88-d48266278f05@nvidia.com>
On 19 Nov 2025, at 23:45, Balbir Singh wrote:
> On 11/20/25 14:59, Zi Yan wrote:
>> min_order_for_split() returns -EBUSY when the folio is truncated and cannot
>> be split. In commit 77008e1b2ef7 ("mm/huge_memory: do not change
>> split_huge_page*() target order silently"), memory_failure() does not
>> handle it and pass -EBUSY to try_to_split_thp_page() directly.
>> try_to_split_thp_page() returns -EINVAL since -EBUSY becomes 0xfffffff0 as
>> new_order is unsigned int in __folio_split() and this large new_order is
>> rejected as an invalid input. The code does not cause a bug.
>> soft_offline_in_use_page() also uses min_order_for_split() but it always
>> passes 0 as new_order for split.
>>
>> Handle it properly by checking min_order_for_split() return value and not
>> calling try_to_split_thp_page() if the value is negative. Add a comment
>> in soft_offline_in_use_page() to clarify the possible negative new_order
>> value.
>>
>> Signed-off-by: Zi Yan <ziy@nvidia.com>
>> ---
>> mm/memory-failure.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index 7f908ad795ad..86582f030159 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -2437,8 +2437,11 @@ int memory_failure(unsigned long pfn, int flags)
>> * or unhandlable page. The refcount is bumped iff the
>> * page is a valid handlable page.
>> */
>> - folio_set_has_hwpoisoned(folio);
>> - err = try_to_split_thp_page(p, new_order, /* release= */ false);
>> + if (new_order >= 0) {
>> + folio_set_has_hwpoisoned(folio);
>
> if new_order < 0, do we skip setting hwpoisioned bit on the folio?
The bit should be set. Anyway, I am going to take David’s approach to
change min_order_for_split().
Thanks.
>
>> + err = try_to_split_thp_page(p, new_order, /* release= */ false);
>> + } else
>> + err = new_order;
>> /*
>> * If splitting a folio to order-0 fails, kill the process.
>> * Split the folio regardless to minimize unusable pages.
>> @@ -2779,6 +2782,7 @@ static int soft_offline_in_use_page(struct page *page)
>> /*
>> * If new_order (target split order) is not 0, do not split the
>> * folio at all to retain the still accessible large folio.
>> + * new_order can be -EBUSY, meaning the folio cannot be split.
>> * NOTE: if minimizing the number of soft offline pages is
>> * preferred, split it to non-zero new_order like it is done in
>> * memory_failure().
>
> Balbir
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2025-11-20 15:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 3:59 [RFC PATCH 0/3] folio->mapping == NULL check issue Zi Yan
2025-11-20 3:59 ` [RFC PATCH 1/3] mm/huge_memory: prevent NULL pointer dereference in try_folio_split_to_order() Zi Yan
2025-11-20 4:28 ` Balbir Singh
2025-11-20 14:45 ` Zi Yan
2025-11-20 9:25 ` David Hildenbrand (Red Hat)
2025-11-20 14:41 ` Zi Yan
2025-11-20 19:56 ` David Hildenbrand (Red Hat)
2025-11-21 16:41 ` Zi Yan
2025-11-21 17:09 ` David Hildenbrand (Red Hat)
2025-11-21 17:24 ` Zi Yan
2025-11-20 3:59 ` [RFC PATCH 2/3] mm/huge_memory: add kernel-doc for folio_split_supported() Zi Yan
2025-11-20 4:37 ` Balbir Singh
2025-11-20 9:27 ` David Hildenbrand (Red Hat)
2025-11-20 14:48 ` Zi Yan
2025-11-20 20:01 ` David Hildenbrand (Red Hat)
2025-11-20 3:59 ` [RFC PATCH 3/3] mm/memory-failure: handle min_order_for_split() error code properly Zi Yan
2025-11-20 4:45 ` Balbir Singh
2025-11-20 15:00 ` Zi Yan [this message]
2025-11-20 9:37 ` David Hildenbrand (Red Hat)
2025-11-20 14:59 ` Zi Yan
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=86CBD3DE-2245-4C79-BDA3-4977548898E3@nvidia.com \
--to=ziy@nvidia.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=balbirs@nvidia.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=lance.yang@linux.dev \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=nao.horiguchi@gmail.com \
--cc=npache@redhat.com \
--cc=ryan.roberts@arm.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