Re: [PATCH] mm/memory_hotplug: don't offline a hwpoisoned page still in the page cache
From: Mani Tofigh
Date: Tue Nov 03 2026 - 15:00:25 EST
On 11/2/26 1:56 AM, David Hildenbrand (Arm) wrote:
What if we still have the page pinned somehow? (vmscplice etc).
Wouldn't it be better to make sure that poisoning code holds exactly one
reference (whoever set hwpoison) and check here that the refcount is 1 ?
Pagecache references would turn it > 1.
Yes right, a pin isn't covered (neither before nor with this patch).
I don't think refcount == 1 can replace the mapping check though. In the
race from the changelog memory_failure() has set PG_hwpoison but is still waiting in get_hwpoison_page(), so it doesn't hold its reference yet, and a clean page-cache folio then has just the one reference from the page cache. memory_failure() also doesn't take a reference on the kernel pages it ignores, and a poisoned page that gets freed later sits at 0.
So I'd keep the mapping check and add "refcount <= 1" on top as a
follow-up, since that also needs do_migrate_range() to drop the reference it takes when it takes a poisoned folio off the LRU. Does that sound good?
I'll send a v2 soon with a small do_migrate_range() change from the bot's review.
Mani