Re: [PATCH 0/2] mm: memory-failure: fix HWPoison flag race with non-atomic page flag ops
From: Michael S. Tsirkin
Date: Tue Jul 07 2026 - 16:27:25 EST
On Wed, Jul 01, 2026 at 10:36:31AM +0200, David Hildenbrand (Arm) wrote:
> On 7/1/26 10:33, Michael S. Tsirkin wrote:
> > On Wed, Jul 01, 2026 at 10:26:26AM +0200, David Hildenbrand (Arm) wrote:
> >> On 7/1/26 10:18, Michael S. Tsirkin wrote:
> >>>
> >>> So on this idea. It might not matter. What I had in mind is:
> >>> 1. run the current logic
> >>> 2. add page to a list of pages to check, then invoke e.g. call_rcu_tasks
> >>> (or call_rcu_tasks_rude) maybe
> >>> 3. in the callback, recheck and if poison cleared, go back to 1
> >>> 4. otherwise everyone will see the bit set, remove from list we are done
> >>>
> >>> it seems to not regress anything, and for the rare race, we set
> >>> the bit eventually.
> >>>
> >>
> >> So test-and-set (and friends) would also have to check the data structure that
> >> remembers bit to set/clear (and possibly update the data structure).
> >>
> >> That does seem doable. Do you have a prototype?
> >
> > what do you think ;) post it?
>
> As RFC please :) [and if it's AI generated, obviously properly reviewed and
> reworked by you]
I spent a bit poking at it, and it's hairy.
The issue is that we have calls to both set and clear bits.
When we record them in a side side structure so they can be retried,
we have to carefully record both sets and clears and their order and make sure
they do not bypass each other. So if there's set already in the
structure, we need to take it out of structure and only then add a clear.
It gets very hairy because we want to set from NMI. So now we can have
clear in the data structure and set from NMI bypasses that. Now what?
And set from NMI can't be 100% safe anyway as we discussed ... Kinda
reduced my motivation to try and make this reliable at all.
> --
> Cheers,
>
> David