Re: [PATCH 0/2] mm: memory-failure: fix HWPoison flag race with non-atomic page flag ops
From: Michael S. Tsirkin
Date: Mon Jun 29 2026 - 17:51:37 EST
On Mon, Jun 29, 2026 at 11:22:11PM +0200, David Hildenbrand (Arm) wrote:
> [...]
>
> >
> > And again, I'm really not sure fixing a theoretical race when memory
> > is failing is worth slowing the world by 0.1-1% for.
> >
>
> Fully agreed. I was hoping RCU was cheaper (I mean, we were once told that RCU
> read side locking is essentially for free ... well in some configs :) )
>
> The question if we could optimize it reasonably enough ...
>
> >
> > From what I saw in my testing, if we allocate 4k pages
> > it's hidden by the overhead. With hp and thp it's measureably
> > worse than rcu on !preempt config.
>
> ... for example, by doing the rcu read lock + unlock around the
>
> for (i = 1; i < (1 << order); i++) {
>
> loop on the alloc path.
Is this different from what this patch is doing?
if (unlikely(order)) {
int i;
hwpoison_rcu_lock();
if (compound) {
page[1].flags.f &= ~PAGE_FLAGS_SECOND;
#ifdef NR_PAGES_IN_LARGE_FOLIO
folio->_nr_pages = 0;
#endif
}
for (i = 1; i < (1 << order); i++) {
if (compound)
bad += free_tail_page_prepare(page, page + i);
if (is_check_pages_enabled()) {
if (free_page_is_bad(page + i)) {
bad++;
continue;
}
}
(page + i)->flags.f &= ~PAGE_FLAGS_CHECK_AT_PREP;
}
hwpoison_rcu_unlock();
}
> But I suspect it's not going to make that much of a
> difference.
It makes a difference! Just not enough to make it completely unmeasureable.
> I concluded, similar to Andi, that stop_machine() is too big of a hammer.
>
> I wonder if something could be built out of preempt_disable() and sync SMP
> calls. hmm :(
rcu_lock is basically same as preempt_disable if rcu is non preemptible,
no?
> --
> Cheers,
>
> David