From: Zi Yan <ziy@nvidia.com>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>,
Matthew Wilcox <willy@infradead.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Jinjiang Tu <tujinjiang@huawei.com>,
Oscar Salvador <osalvador@suse.de>,
linmiaohe@huawei.com, mhocko@kernel.org, linux-mm@kvack.org,
wangkefeng.wang@huawei.com
Subject: Re: [PATCH v2 2/2] mm/memory_hotplug: fix hwpoisoned large folio handling in do_migrate_range
Date: Fri, 22 Aug 2025 13:24:03 -0400 [thread overview]
Message-ID: <15506AAB-D1B7-4C9A-BA59-20EC3AE819A7@nvidia.com> (raw)
In-Reply-To: <3c214dff-9649-4015-840f-10de0e03ebe4@redhat.com>
On 21 Aug 2025, at 18:07, David Hildenbrand wrote:
> On 21.08.25 07:02, Andrew Morton wrote:
>> On Tue, 22 Jul 2025 17:30:06 +0200 David Hildenbrand <david@redhat.com> wrote:
>>
>>> On 20.07.25 04:23, Andrew Morton wrote:
>>>>
>>>> I continue to retain the original patch in mm-hotfixes as part of
>>>> akpm's lame bug-tracking system. 3 weeks in -next.
>>>>
>>>> And I just added a cc:stable to it because December 2018.
>>>>
>>>> I don't expect many real-world users will be putting fake delays in
>>>> memory_failure(), but it's there.
>>>>
>>>> So what do we do here? Add a TODO, merge it under the
>>>> better-than-it-was-before theory and move on?
>>>
>>> I would feel better if we could just not fail memory offlining. Memory
>>> offlining is documented to loop forever if something bad happens, and
>>> user space can cancel it.
>>>
>>
>> Pathetic monthly prod to keep this on people's radar.
>>
>
> Let's do something minimal for now:
>
> From 403b2a375a10c17fd6e2aeffbe0fdaf623faa621 Mon Sep 17 00:00:00 2001
> From: Jinjiang Tu <tujinjiang@huawei.com>
> Date: Fri, 27 Jun 2025 20:57:47 +0800
> Subject: [PATCH] mm/memory_hotplug: fix hwpoisoned large folio handling in
> do_migrate_range
>
> In do_migrate_range(), the hwpoisoned folio may be large folio, which
> can't be handled by unmap_poisoned_folio().
>
> I can reproduce this issue in qemu after adding delay in memory_failure()
>
> BUG: kernel NULL pointer dereference, address: 0000000000000000
> Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> RIP: 0010:try_to_unmap_one+0x16a/0xfc0
> <TASK>
> rmap_walk_anon+0xda/0x1f0
> try_to_unmap+0x78/0x80
> ? __pfx_try_to_unmap_one+0x10/0x10
> ? __pfx_folio_not_mapped+0x10/0x10
> ? __pfx_folio_lock_anon_vma_read+0x10/0x10
> unmap_poisoned_folio+0x60/0x140
> do_migrate_range+0x4d1/0x600
> ? slab_memory_callback+0x6a/0x190
> ? notifier_call_chain+0x56/0xb0
> offline_pages+0x3e6/0x460
> memory_subsys_offline+0x130/0x1f0
> device_offline+0xba/0x110
> acpi_bus_offline+0xb7/0x130
> acpi_scan_hot_remove+0x77/0x290
> acpi_device_hotplug+0x1e0/0x240
> acpi_hotplug_work_fn+0x1a/0x30
> process_one_work+0x186/0x340
>
> Besides, do_migrate_range() may be called between memory_failure set
> hwpoison flag and isolate the folio from lru, so remove WARN_ON(). In other
> places, unmap_poisoned_folio() is called when the folio is isolated, obey
> it in do_migrate_range() too.
>
> Fixes: b15c87263a69 ("hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined")
> Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com>
> [ David: don't abort offlining, fixed typo, added comment ]
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> mm/memory_hotplug.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
Acked-by: Zi Yan <ziy@nvidia.com>
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 1f15af712bc34..74318c7877156 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1815,8 +1815,14 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
> pfn = folio_pfn(folio) + folio_nr_pages(folio) - 1;
> if (folio_contain_hwpoisoned_page(folio)) {
> - if (WARN_ON(folio_test_lru(folio)))
> - folio_isolate_lru(folio);
> + /*
> + * unmap_poisoned_folio() cannot handle large folios
> + * in all cases yet.
> + */
> + if (folio_test_large(folio) && !folio_test_hugetlb(folio))
> + goto put_folio;
> + if (folio_test_lru(folio) && !folio_isolate_lru(folio))
> + goto put_folio;
> if (folio_mapped(folio)) {
> folio_lock(folio);
> unmap_poisoned_folio(folio, pfn, false);
> --
> 2.50.1
>
>
> Man oh man, is hwpoison handling a mess.
>
--
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2025-08-22 17:24 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 12:57 [PATCH v2 0/2] fix two calls of unmap_poisoned_folio() for large folio Jinjiang Tu
2025-06-27 12:57 ` [PATCH v2 1/2] mm/vmscan: fix hwpoisoned large folio handling in shrink_folio_list Jinjiang Tu
2025-06-27 17:10 ` David Hildenbrand
2025-06-27 22:00 ` Andrew Morton
2025-06-28 2:38 ` Jinjiang Tu
2025-06-28 3:13 ` Miaohe Lin
2025-07-01 14:13 ` Oscar Salvador
2025-07-03 7:30 ` Jinjiang Tu
2025-06-27 12:57 ` [PATCH v2 2/2] mm/memory_hotplug: fix hwpoisoned large folio handling in do_migrate_range Jinjiang Tu
2025-07-01 14:21 ` Oscar Salvador
2025-07-03 7:46 ` Jinjiang Tu
2025-07-03 7:57 ` David Hildenbrand
2025-07-03 8:24 ` Jinjiang Tu
2025-07-03 9:06 ` David Hildenbrand
2025-07-07 11:51 ` Jinjiang Tu
2025-07-07 12:37 ` David Hildenbrand
2025-07-08 1:15 ` Jinjiang Tu
2025-07-08 9:54 ` David Hildenbrand
2025-07-09 16:27 ` Zi Yan
2025-07-14 13:53 ` Pankaj Raghav
2025-07-14 14:20 ` Zi Yan
2025-07-14 14:24 ` David Hildenbrand
2025-07-14 15:09 ` Pankaj Raghav (Samsung)
2025-07-14 15:14 ` David Hildenbrand
2025-07-14 15:25 ` Zi Yan
2025-07-14 15:28 ` Zi Yan
2025-07-14 15:33 ` David Hildenbrand
2025-07-14 15:44 ` Zi Yan
2025-07-14 15:52 ` David Hildenbrand
2025-07-20 2:23 ` Andrew Morton
2025-07-22 15:30 ` David Hildenbrand
2025-08-21 5:02 ` Andrew Morton
2025-08-21 22:07 ` David Hildenbrand
2025-08-22 17:24 ` Zi Yan [this message]
2025-08-25 2:05 ` Miaohe Lin
2025-07-03 7:53 ` David Hildenbrand
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=15506AAB-D1B7-4C9A-BA59-20EC3AE819A7@nvidia.com \
--to=ziy@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=kernel@pankajraghav.com \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=mhocko@kernel.org \
--cc=osalvador@suse.de \
--cc=tujinjiang@huawei.com \
--cc=wangkefeng.wang@huawei.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