Linux CXL
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: linux-kernel@vger.kernel.org, Miaohe Lin <linmiaohe@huawei.com>,
	Naoya Horiguchi <nao.horiguchi@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oscar Salvador <osalvador@suse.de>,
	Andi Kleen <andi@firstfloor.org>,
	Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	Rik van Riel <riel@redhat.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Brendan Jackman <jackmanb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Nico Pache <npache@redhat.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
	Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Harry Yoo <harry@kernel.org>, Hao Li <hao.li@linux.dev>,
	Kiryl Shutsemau <kas@kernel.org>,
	Byungchul Park <byungchul@sk.com>,
	linux-mm@kvack.org, linux-cxl@vger.kernel.org
Subject: Re: [PATCH 0/2] mm: memory-failure: fix HWPoison flag race with non-atomic page flag ops
Date: Wed, 1 Jul 2026 04:18:08 -0400	[thread overview]
Message-ID: <20260701041112-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <2f884bfa-3cd5-4fba-8aa4-c2e68890ab64@kernel.org>

On Wed, Jul 01, 2026 at 10:08:45AM +0200, David Hildenbrand (Arm) wrote:
> >> Cheers,
> >> 
> >> David
> > 
> > Yay. I did that + dropped the extra lock/unlock and now it's in the noise in
> > my testing. needs much more testing of course.
> 
> Cool. I'd expect that latency-sensitive workloads (PREEMPT_RT) would not want to
> have hwpoison handling either way, so using the no_resched variants at these
> places might be doable.
> 
> > 
> > If you want me to post (including addressing your other feedback) let me
> > know.
> > 
> 
> Let's first discuss the options. We essentially have the following one so far:
> 
> 1) Ignore the problem
> 
> It's been there forever ... but I am not quite happy about that.
> 
> 2) Use atomics everywhere
> 
> The easiest+cleanest, but as measured, the performance hit is real.
> 
> 3) Keep retrying for a couple of times
> 
> The big problem is "how long". A CPU in a hypervisor might be stalled for quite
> a while (20s? can be longer).

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.


> 4) Disable preemption around non-atomic updates + synchronize_rcu() loop
> 
> I think it should work, but I don't like the possibly endless retry loop. (well,
> it would never be an endless loop in practice)
> 
> Is there a problem with synchronize_rcu() latency, given that it can take in bad
> scenarios a couple of seconds? (grace periods can be large ... but also very short)
> 
> 4) disable local interrupts around non-atomic updates + let all CPUs perform
>    atomic setting/clearing of the bit through smp_call_function_many().
> 
> Disabling local interrupts is way too expensive. :(
> 
> 5) disable preemption around non-atomic updates + let all CPUs perform
>    atomic setting/clearing of the bit through schedule_on_each_cpu()
> 
> Mixture of 3) + 4), but schedule_on_each_cpu() can also possibly take a long
> time (as long as we cannot schedule on a CPU ...).
> 
> We could likely build something that remembers all pages with bits-to-set /
> bits-to-clear, to then kick off a per-cpu work ... and once all CPUs processed a
> page it was fully processed ... needs much more thought.
> 
> 6) stop_machine()
> 
> Big hammer. I think we'd still need to disable preemption around non-atomic updates.
> 
> 7) Move hwpoison bit out of page->flags
> 
> Use a sparse bitmap. Quite invasive, and any hwpoison bit checking code would
> get more expensive.
> 
> 
> 
> Did I mess something up / forget something?
> 
> > Or look into call_rcu_tasks/call_rcu_tasks_rude which might work without 
> > changes in mm.
> 
> Looking into call_rcu_tasks() (the first time) the semantics are interesting
> ("involuntary preemption is not a Tasks RCU quiescent state").
> 
> I'm curious how this interacts with random page allocations (on the IRQ path?),
> and which design you envision given that we only get a single callback (who
> prevents code to re-enter).
> 
> > 
> > Or if someone else is gonnu work on this, absolutely fine too.
> 
> I can likely let someone work on that, but I think we should first figure out
> what can really be done. (and likely when we send it out, it should be an RFC)
> 
> -- 
> Cheers,
> 
> David


  reply	other threads:[~2026-07-01  8:18 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-28 21:45 [PATCH 0/2] mm: memory-failure: fix HWPoison flag race with non-atomic page flag ops Michael S. Tsirkin
2026-06-28 21:45 ` [PATCH 1/2] mm: memory-failure: use RCU to fix HWPoison flag race Michael S. Tsirkin
2026-06-28 21:45 ` [PATCH 2/2] mm: wrap non-atomic page flag ops in RCU for HWPoison safety Michael S. Tsirkin
2026-06-29  2:11 ` [PATCH 0/2] mm: memory-failure: fix HWPoison flag race with non-atomic page flag ops Andi Kleen
2026-06-29  8:10   ` Michael S. Tsirkin
2026-06-29  8:21     ` David Hildenbrand (Arm)
2026-06-29  8:39     ` Michael S. Tsirkin
2026-06-29 16:54       ` Andi Kleen
2026-06-29 17:04         ` David Hildenbrand (Arm)
2026-06-29 20:43           ` Michael S. Tsirkin
2026-06-29  6:49 ` David Hildenbrand (Arm)
2026-06-29  7:34   ` Michael S. Tsirkin
2026-06-29 13:05     ` David Hildenbrand (Arm)
2026-06-29 20:08       ` Michael S. Tsirkin
2026-06-29 20:55         ` Andi Kleen
2026-06-29 21:17           ` Michael S. Tsirkin
2026-06-29 21:39             ` Andi Kleen
2026-06-29 21:59               ` Michael S. Tsirkin
2026-06-29 21:22         ` David Hildenbrand (Arm)
2026-06-29 21:43           ` David Hildenbrand (Arm)
2026-06-29 23:34             ` Michael S. Tsirkin
2026-06-30  6:17               ` David Hildenbrand (Arm)
2026-06-30  6:27                 ` Michael S. Tsirkin
2026-06-30  6:34                   ` David Hildenbrand (Arm)
2026-06-30  7:25                     ` Michael S. Tsirkin
2026-06-29 21:50           ` Michael S. Tsirkin
2026-06-30  6:30             ` David Hildenbrand (Arm)
2026-06-30  6:41               ` David Hildenbrand (Arm)
2026-06-30 21:58                 ` Michael S. Tsirkin
2026-07-01  8:08                   ` David Hildenbrand (Arm)
2026-07-01  8:18                     ` Michael S. Tsirkin [this message]
2026-07-01  8:26                       ` David Hildenbrand (Arm)
2026-07-01  8:33                         ` Michael S. Tsirkin
2026-07-01  8:36                           ` David Hildenbrand (Arm)
2026-07-01 15:54                             ` Michael S. Tsirkin
2026-07-01 16:17                               ` David Hildenbrand (Arm)
2026-06-29 21:54           ` Michael S. Tsirkin
2026-07-01  7:25             ` David Hildenbrand (Arm)
2026-06-29 23:29       ` Michael S. Tsirkin
2026-07-01  7:31         ` David Hildenbrand (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260701041112-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=byungchul@sk.com \
    --cc=cl@gentwo.org \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=hao.li@linux.dev \
    --cc=harry@kernel.org \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=jackmanb@google.com \
    --cc=kas@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=nao.horiguchi@gmail.com \
    --cc=npache@redhat.com \
    --cc=osalvador@suse.de \
    --cc=riel@redhat.com \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox