From: Miaohe Lin <linmiaohe@huawei.com>
To: <jane.chu@oracle.com>
Cc: David Hildenbrand <david@redhat.com>,
Luis Chamberlain <mcgrof@kernel.org>,
syzbot <syzbot+e6367ea2fdab6ed46056@syzkaller.appspotmail.com>,
<akpm@linux-foundation.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <nao.horiguchi@gmail.com>,
<syzkaller-bugs@googlegroups.com>,
"Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>,
Zi Yan <ziy@nvidia.com>
Subject: Re: [syzbot] [mm?] WARNING in memory_failure
Date: Tue, 30 Sep 2025 14:31:36 +0800 [thread overview]
Message-ID: <c97dedf5-0f45-5082-64b6-ef0772dc33a3@huawei.com> (raw)
In-Reply-To: <8d39b975-b85f-42f2-8be4-0b7adee09dd6@oracle.com>
On 2025/9/30 12:35, jane.chu@oracle.com wrote:
>
>
> On 9/29/2025 7:51 PM, Miaohe Lin wrote:
>> On 2025/9/30 2:23, jane.chu@oracle.com wrote:
>>>
>>>
>>> On 9/29/2025 10:49 AM, jane.chu@oracle.com wrote:
>>>>
>>>> On 9/29/2025 10:29 AM, jane.chu@oracle.com wrote:
>>>>>
>>>>> On 9/29/2025 4:08 AM, Pankaj Raghav (Samsung) wrote:
>>>>>>>
>>>>>>> I want to change all the split functions in huge_mm.h and provide
>>>>>>> mapping_min_folio_order() to try_folio_split() in truncate_inode_partial_folio().
>>>>>>>
>>>>>>> Something like below:
>>>>>>>
>>>>>>> 1. no split function will change the given order;
>>>>>>> 2. __folio_split() will no longer give VM_WARN_ONCE when provided new_order
>>>>>>> is smaller than mapping_min_folio_order().
>>>>>>>
>>>>>>> In this way, for an LBS folio that cannot be split to order 0, split
>>>>>>> functions will return -EINVAL to tell caller that the folio cannot
>>>>>>> be split. The caller is supposed to handle the split failure.
>>>>>>
>>>>>> IIUC, we will remove warn on once but just return -EINVAL in __folio_split()
>>>>>> function if new_order < min_order like this:
>>>>>> ...
>>>>>> min_order = mapping_min_folio_order(folio->mapping);
>>>>>> if (new_order < min_order) {
>>>>>> - VM_WARN_ONCE(1, "Cannot split mapped folio below min- order: %u",
>>>>>> - min_order);
>>>>>> ret = -EINVAL;
>>>>>> goto out;
>>>>>> }
>>>>>> ...
>>>>>
>>>>> Then the user process will get a SIGBUS indicting the entire huge page at higher order -
>>>>> folio_set_has_hwpoisoned(folio);
>>>>> if (try_to_split_thp_page(p, false) < 0) {
>>>>> res = -EHWPOISON;
>>>>> kill_procs_now(p, pfn, flags, folio);
>>>>> put_page(p);
>>>>> action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED);
>>>>> goto unlock_mutex;
>>>>> }
>>>>> VM_BUG_ON_PAGE(!page_count(p), p);
>>>>> folio = page_folio(p);
>>>>>
>>>>> the huge page is not usable any way, kind of similar to the hugetlb page situation: since the page cannot be splitted, the entire page is marked unusable.
>>>>>
>>>>> How about keep the current huge page split code as is, but change the M- F code to recognize that in a successful splitting case, the poisoned page might just be in a lower folio order, and thus, deliver the SIGBUS ?
>>>>>
>>>>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>>>>> index a24806bb8e82..342c81edcdd9 100644
>>>>> --- a/mm/memory-failure.c
>>>>> +++ b/mm/memory-failure.c
>>>>> @@ -2291,7 +2291,9 @@ int memory_failure(unsigned long pfn, int flags)
>>>>> * page is a valid handlable page.
>>>>> */
>>>>> folio_set_has_hwpoisoned(folio);
>>>>> - if (try_to_split_thp_page(p, false) < 0) {
>>>>> + ret = try_to_split_thp_page(p, false);
>>>>> + folio = page_folio(p);
>>>>> + if (ret < 0 || folio_test_large(folio)) {
>>>>> res = -EHWPOISON;
>>>>> kill_procs_now(p, pfn, flags, folio);
>>>>> put_page(p);
>>>>> @@ -2299,7 +2301,6 @@ int memory_failure(unsigned long pfn, int flags)
>>>>> goto unlock_mutex;
>>>>> }
>>>>> VM_BUG_ON_PAGE(!page_count(p), p);
>>>>> - folio = page_folio(p);
>>>>> }
>>>>>
>>>>> thanks,
>>>>> -jane
>>>>
>>>> Maybe this is better, in case there are other reason for split_huge_page() to return -EINVAL.
>>>>
>>>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>>>> index a24806bb8e82..2bfa05acae65 100644
>>>> --- a/mm/memory-failure.c
>>>> +++ b/mm/memory-failure.c
>>>> @@ -1659,9 +1659,10 @@ static int identify_page_state(unsigned long pfn, struct page *p,
>>>> static int try_to_split_thp_page(struct page *page, bool release)
>>>> {
>>>> int ret;
>>>> + int new_order = min_order_for_split(page_folio(page));
>>>>
>>>> lock_page(page);
>>>> - ret = split_huge_page(page);
>>>> + ret = split_huge_page_to_list_to_order(page, NULL, new_order);
>>>> unlock_page(page);
>>>>
>>>> if (ret && release)
>>>> @@ -2277,6 +2278,7 @@ int memory_failure(unsigned long pfn, int flags)
>>>> folio_unlock(folio);
>>>>
>>>> if (folio_test_large(folio)) {
>>>> + int ret;
>>>> /*
>>>> * The flag must be set after the refcount is bumped
>>>> * otherwise it may race with THP split.
>>>> @@ -2291,7 +2293,9 @@ int memory_failure(unsigned long pfn, int flags)
>>>> * page is a valid handlable page.
>>>> */
>>>> folio_set_has_hwpoisoned(folio);
>>>> - if (try_to_split_thp_page(p, false) < 0) {
>>>> + ret = try_to_split_thp_page(p, false);
>>>> + folio = page_folio(p);
>>>> + if (ret < 0 || folio_test_large(folio)) {
>>>> res = -EHWPOISON;
>>>> kill_procs_now(p, pfn, flags, folio);
>>>> put_page(p);
>>>> @@ -2299,7 +2303,6 @@ int memory_failure(unsigned long pfn, int flags)
>>>> goto unlock_mutex;
>>>> }
>>>> VM_BUG_ON_PAGE(!page_count(p), p);
>>>> - folio = page_folio(p);
>>>> }
>>>>
>>>> /*
>>>> @@ -2618,7 +2621,8 @@ static int soft_offline_in_use_page(struct page *page)
>>>> };
>>>>
>>>> if (!huge && folio_test_large(folio)) {
>>>> - if (try_to_split_thp_page(page, true)) {
>>>> + if ((try_to_split_thp_page(page, true)) ||
>>>> + folio_test_large(page_folio(page))) {
>>>> pr_info("%#lx: thp split failed\n", pfn);
>>>> return -EBUSY;
>>>> }
>>>
>>> In soft offline, better to check if (min_order_for_split > 0), no need to split, just return for now ...
>>
>> I might be miss something but why we have to split it? Could we migrate the whole thp or folio with min_order instead?
>
> The soft offline code was originally written with the assumption that only 1 base page will be offlined.
Yes, only page corresponding to parameter @pfn of soft_offline_page() will be offlined.
>
> With the recent introduction of min_order, it might quietly offline multiple pages, is that a desirable thing?
I don't think so. Even if try_to_split_thp_page splits folio into smaller one with min_order, page_handle_poison()
will put back the folio into buddy after migrate_pages, set the hwpoisoned flag to raw error page and hold the extra
refcnt. So only raw error page will be offlined while other sub-pages will be put back into buddy.
Or am I miss something?
Thanks.
.
next prev parent reply other threads:[~2025-09-30 6:31 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 16:22 [syzbot] [mm?] WARNING in memory_failure syzbot
2025-09-24 11:32 ` David Hildenbrand
2025-09-24 15:03 ` Zi Yan
2025-09-24 15:35 ` David Hildenbrand
2025-09-24 16:33 ` Zi Yan
2025-09-24 17:05 ` David Hildenbrand
2025-09-24 17:52 ` Zi Yan
2025-09-25 12:02 ` Pankaj Raghav (Samsung)
2025-09-25 14:24 ` Zi Yan
2025-09-25 16:23 ` Yang Shi
2025-09-25 16:48 ` David Hildenbrand
2025-09-25 17:26 ` Yang Shi
2025-09-29 11:08 ` Pankaj Raghav (Samsung)
2025-09-29 15:20 ` Zi Yan
2025-09-29 16:13 ` David Hildenbrand
2025-10-01 1:51 ` Zi Yan
2025-10-01 2:06 ` syzbot
2025-10-01 2:13 ` Zi Yan
2025-10-01 4:51 ` syzbot
2025-10-01 23:58 ` jane.chu
2025-10-02 0:38 ` Zi Yan
2025-10-02 2:04 ` Zi Yan
2025-10-02 2:50 ` syzbot
2025-10-02 5:23 ` jane.chu
2025-10-02 13:54 ` Zi Yan
2025-10-02 17:47 ` jane.chu
2025-10-09 7:39 ` Miaohe Lin
2025-10-10 15:25 ` Zi Yan
2025-10-02 17:54 ` jane.chu
2025-10-02 18:45 ` Zi Yan
2025-10-03 4:02 ` jane.chu
2025-10-02 18:33 ` Zi Yan
2025-10-02 19:09 ` syzbot
2025-10-02 7:25 ` David Hildenbrand
2025-09-29 17:29 ` jane.chu
2025-09-29 17:49 ` jane.chu
2025-09-29 18:23 ` jane.chu
2025-09-29 20:15 ` Zi Yan
2025-09-29 20:52 ` jane.chu
2025-09-30 2:51 ` Miaohe Lin
2025-09-30 4:35 ` jane.chu
2025-09-30 6:31 ` Miaohe Lin [this message]
2025-10-01 18:15 ` jane.chu
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=c97dedf5-0f45-5082-64b6-ef0772dc33a3@huawei.com \
--to=linmiaohe@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=jane.chu@oracle.com \
--cc=kernel@pankajraghav.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=nao.horiguchi@gmail.com \
--cc=syzbot+e6367ea2fdab6ed46056@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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