Re: [PATCH v2] mm/memory_hotplug: don't offline a hwpoisoned page still in the page cache
From: Miaohe Lin
Date: Thu Nov 26 2026 - 22:39:33 EST
On 2026/11/26 17:22, Oscar Salvador (SUSE) wrote:
> On Mon, Nov 23, 2026 at 08:45:37PM +0100, David Hildenbrand (Arm) wrote:
>> 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?
I once tried to fix the race between memory_failure and memory offlining [1],
but ultimately failed.
>> 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.
>
> I think this is the way to go.
> memory-failure is a shaky operation and over the years we have seen how challenging
> was to interact with other parts of the kernel without crashing.
I'd also prefer making memory_failure() and memory offlining mutually
exclusive instead of adding more ad-hoc synchronization or spreading
get_online_mems()/put_online_mems() into another path.
>
> IMHO, we can try to be clever and try to workaround those issues
> (memhotplug vs memfailure) or just make the two exclusive.
>
> @Miaohe: Thoughts?
We've already run into quite a few race conditions, and there will likely be
more in the future. memory_failure and memory offlining happen very infrequently,
so it's not really worth adding all sorts of code just for them. Therefore, I feel
that making the two mutually exclusive is a better, more permanent fix.
[1] https://lore.kernel.org/all/20220226094034.23938-1-linmiaohe@xxxxxxxxxx/
Thanks.
.