From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Miaohe Lin <linmiaohe@huawei.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
kas@kernel.org, kexec@lists.infradead.org,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Brendan Jackman <brendan.jackman@linux.dev>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
Oscar Salvador <osalvador@suse.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
hannes@cmpxchg.or, shakeel.butt@linux.dev,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, rmikey@meta.com, riel@surriel.com,
harry@kernel.org, linux-cxl@vger.kernel.org,
driver-core@lists.linux.dev, kernel-team@meta.com
Subject: Re: [PATCH v5 7/9] drivers/base/memory: count inherited poisoned frames into the block
Date: Fri, 18 Sep 2026 22:16:25 +0200 [thread overview]
Message-ID: <fb2237be-f7bc-4ad6-bcb0-7c3ef53136ef@kernel.org> (raw)
In-Reply-To: <aq1RaH0eE0hZfNpr@gmail.com>
On 9/18/26 17:22, Breno Leitao wrote:
> On Fri, Sep 18, 2026 at 02:18:03PM +0200, David Hildenbrand (Arm) wrote:
>> On 9/17/26 15:01, Breno Leitao wrote:
>>>
>>> Fair point, I'll clean up the naming in the next revision.
>>>
>>> I'll also add that ->empty field, which should help locate this bit
>>> faster and may let us skip the bitmap query entirely on the happy path.
>>>
>>> Anything else you'd like addressed?
>>>
>>> Good to know this moved the needle from "David hates this feature" to
>>> "David only hates the naming" -- I'll take that as progress. :-P
>>
>> ;)
>>
>> I think the crucial part is to find a way to cleanly distinguish our source of
>> information, and also how the source does only apply to some memory.
>
> Right, we have two source for poisoned page information, today.
>
> 1) LINUX_EFI_POISONED_MEMORY: Used to track memory block that got
> poisioned, and will be passed around during kexec.
> 2) PG_hwpoison on struct page: Used by the memory subsystem to avoid
> touching it.
How are both kept in sync? See below.
>
> And I understand that this design is fine, and we want to be easy to
> identify what we are querying on function name. For instance,
> I understand you confusion in range_contains_poisoned_memory() came
> from:
>
> range_contains_poisoned_memory():
> * What the caller reads:
> * "is any memory in this range hardware poisoned?"
> * What actually runs:
> * "is any bit set in an EFI table that a PREVIOUS kernel wrote,
> at 2 MiB granularity, for this memory region?"
Right, and we should use that only as a source for anything during early boot.
So maybe it should hint at the "early" aspect somehow.
Which brings me back to: is the bitmap kept in sync when memory gets hwpoisoned?
That is: as memory gets hwpoisoned, will the bitmap get set immediately?
>
> So, I think think this is a naming issue, and I need to think more about
> it. Maybe appending efiposioned (on data that is coming from EFI config
> table). Let me think more about it.
>
>> Regarding this patch here, I'd assume it's sufficient.
>>
>> But I do wonder why we are walking pages when we have a bitmap to walk/process
>> at hand?
>
> Because the counter has to agree with the page flag, and the page flag is
> not the bitmap.
But how could they go out of sync? I'd assume only for memory holes
(!pfn_to_online_page), but for that we don't need to test actual page flags.
>
> PG_hwpoison in a block is the union of every source that poisoned a
> frame; the inherited EFI table is one of them, and it is the coarse and
> partial one.
So you're saying that this code is possibly racy with other setting code? Or
which other sources might there be if the generically called
range_contains_poisoned_memory()
wouldn't be able to identify it (and it only queries the bitmap?).
>
> You might ask why I do not just count the bits set in the bitmape and
> multiply by the frames a unit covers.
>
> That was my first try. It over-counts: a bit stands for a whole 2M unit,
> but only the frames that reach __free_pages_core() get flagged -- CMA
> comes back through __free_pages(), the initrd and __init memory through
> free_reserved_pages(), and KHO-preserved frames never get an initialised
> struct page at all.
Why are other hwpoisoned pages not flagged? If initrd or anything else is
hwpoisoned, we should not be running this kernel?
>
> And the over-count cannot be undone later.
The inconsistency is worrisome.
I wouldn't say that I hate it but it certainly has "great, more hwpoison hacks"
smell to it.
We have enough semi-broken hwpoison ... stuff ... in our code base already. So
I'm hoping we're not adding more to it?
> If the walk itself is what bothers you, the way out is not the bitmap
> but counting as we flag: hwpoison_boot_page() already knows the pfn, so
> it can bump a per-block-id counter in a small memblock array that
> memblk_nr_poison_init() then just reads.
The inconsistency is what worries me.
And that we have pages we are told are hwpoisoned but we seem to ignore that and
carry on with our kernel letting it boot?
>
> Exact by construction, no walk. Happy to go that way instead if you
> prefer it.
Let me first try to understand the semantics here.
--
Cheers,
David
next prev parent reply other threads:[~2026-09-18 20:16 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 12:53 [PATCH v5 0/9] mm/memory-failure: keep hardware-poisoned pages out of the next kexec Breno Leitao
2026-09-15 12:53 ` [PATCH v5 1/9] mm/page_alloc: factor out the accept-and-free tail of __free_pages_core() Breno Leitao
2026-09-15 12:57 ` sashiko-bot
2026-09-15 12:53 ` [PATCH v5 2/9] mm/memory-failure: efi: add the LINUX_EFI_POISONED_MEMORY configuration table Breno Leitao
2026-09-15 13:05 ` sashiko-bot
2026-09-15 12:53 ` [PATCH v5 3/9] mm/memory-failure: libstub: install the poisoned-memory EFI table Breno Leitao
2026-09-15 13:15 ` sashiko-bot
2026-09-15 14:00 ` Breno Leitao
2026-09-16 15:39 ` Usama Arif
2026-09-17 10:53 ` Breno Leitao
2026-09-15 12:53 ` [PATCH v5 4/9] mm/memory-failure: efi: adopt the inherited poisoned-memory table Breno Leitao
2026-09-15 13:24 ` sashiko-bot
2026-09-15 12:53 ` [PATCH v5 5/9] mm/memory-failure: efi: record hardware-poisoned frames into the " Breno Leitao
2026-09-15 13:36 ` sashiko-bot
2026-09-15 14:33 ` Breno Leitao
2026-09-15 12:53 ` [PATCH v5 6/9] mm/memory-failure: efi: answer whether a range is poisoned Breno Leitao
2026-09-15 13:45 ` sashiko-bot
2026-09-16 6:44 ` David Hildenbrand (Arm)
2026-09-18 15:27 ` Breno Leitao
2026-09-18 15:53 ` Harry Yoo
2026-09-18 20:02 ` David Hildenbrand (Arm)
2026-09-15 12:53 ` [PATCH v5 7/9] drivers/base/memory: count inherited poisoned frames into the block Breno Leitao
2026-09-15 13:59 ` sashiko-bot
2026-09-16 6:48 ` David Hildenbrand (Arm)
2026-09-16 9:35 ` Breno Leitao
2026-09-16 14:51 ` David Hildenbrand (Arm)
2026-09-17 13:01 ` Breno Leitao
2026-09-18 12:18 ` David Hildenbrand (Arm)
2026-09-18 15:22 ` Breno Leitao
2026-09-18 20:16 ` David Hildenbrand (Arm) [this message]
2026-09-15 12:53 ` [PATCH v5 8/9] mm/memory-failure: add hwpoison_boot_page() to flag an inherited frame Breno Leitao
2026-09-15 14:11 ` sashiko-bot
2026-09-15 12:53 ` [PATCH v5 9/9] mm/memory-failure: keep inherited poisoned frames out of the buddy allocator Breno Leitao
2026-09-15 14:25 ` sashiko-bot
2026-09-16 8:32 ` Vlastimil Babka (SUSE)
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=fb2237be-f7bc-4ad6-bcb0-7c3ef53136ef@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=brendan.jackman@linux.dev \
--cc=dakr@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.or \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=leitao@debian.org \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
--cc=riel@surriel.com \
--cc=rmikey@meta.com \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=x86@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
all inboxes | Powered by JetHome®