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 11:54:15 -0400	[thread overview]
Message-ID: <20260701112946-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <c03ec696-d635-4c7f-8c77-89a439d9135b@kernel.org>

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]
> -- 
> Cheers,
> 
> David

Not "generated" surely. But assisted, yes. Still hacking on it, but the difficulty
with memory-failure is that fundamentally, it's not 100% robust.

For example, we have a fifo fed by hardware and consumed by a workqueue:

        struct memory_failure_cpu *mf_cpu;
        unsigned long proc_flags;
        bool buffer_overflow;
        struct memory_failure_entry entry = {
                .pfn =          pfn,
                .flags =        flags,
        };

        mf_cpu = &get_cpu_var(memory_failure_cpu);
        raw_spin_lock_irqsave(&mf_cpu->lock, proc_flags);
        buffer_overflow = !kfifo_put(&mf_cpu->fifo, entry);
        if (!buffer_overflow)
                schedule_work_on(smp_processor_id(), &mf_cpu->work);
        raw_spin_unlock_irqrestore(&mf_cpu->lock, proc_flags);
        put_cpu_var(memory_failure_cpu);
        if (buffer_overflow)
                pr_err("buffer overflow when queuing memory failure at %#lx\n",
                       pfn);


if there are lots of these and the scheduler is slow and it overflows,
it's sayonara you have lost the flag, right?


Oh and by the way, I just noticed that when buddy merges pages it does
not check the poison bit. So it looks like there's a simple way to lose
the poison bit - have it merge with a non poisoned page.

I guess maybe we should fix this last one.

-- 
MST


  reply	other threads:[~2026-07-01 15:54 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
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 [this message]
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=20260701112946-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