Re: [PATCH v2] mm/memory_hotplug: don't offline a hwpoisoned page still in the page cache
From: David Hildenbrand (Arm)
Date: Mon Nov 23 2026 - 14:45:47 EST
On 11/23/26 06:46, Mani Tofigh wrote:
>
>
> On 11/6/26 3:58 PM, David Hildenbrand (Arm) wrote:
>> I didn't understand why just checking for the refcount is not sufficient. Can
>> you elaborate once more (and please not send a new revision before the
>> discussion is over).
>>
>> Memory poisoning must grab a reference when setting the folio hwpoison. Any
>> other reference (pin, pagecache, swapcache, mapping) keeps it alive.
>>
>> Why can't we build on and?
>
>
> Right, but memory_failure() doesn't always hold that reference. It i)
> sets the flag before get_hwpoison_page() grabs it, which waits on
> pcp_batch_high_lock that offline_pages() holds, and ii) gives up with
> the flag set and no reference when get_hwpoison_page() fails (e.g.,
> a pagecache folio briefly off the LRU). In both cases the pagecache
> holds the only reference, so offline can't tell it apart from a
> page memory_failure() already handled.
>
> So I think if we move zone_pcp_disable() in memory_failure() before
> setting the flag and keep the reference when it gives up, offline could
> simply treat any poisoned page with refcount > 1 as busy. That'd cover
> pins too. What do you think?
We'll have to find a way to make that reliable. Everything else is just hacking
around it.
Why can we block concurrent offlining through get_online_mems/put_online_mems?
But I hate these functions.
Or alternatively (better?), have a memory notifier that block concurrent
memory_failure() by grabbing the mf_mutex when MEM_GOING_OFFLINE and releasing
it when MEM_CANCEL_OFFLINE/MEM_OFFLINE.
Needs some thought, but if the problem is that these two mechanisms don't
interact well concurrently, then we should make them mutually exclusive.
--
Cheers,
David