From: Brendan Jackman <jackmanb@google.com>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Oscar Salvador <osalvador@suse.de>,
Johannes Weiner <hannes@cmpxchg.org>,
Vlastimil Babka <vbabka@suse.cz>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/page_alloc: Add lockdep assertion for pageblock type change
Date: Mon, 3 Mar 2025 13:55:11 +0000 [thread overview]
Message-ID: <Z8W0v0LjuyH8ztTQ@google.com> (raw)
In-Reply-To: <4d0f0bca-3096-4fb4-9e8b-d4dcdf7eeb92@redhat.com>
On Mon, Mar 03, 2025 at 02:11:23PM +0100, David Hildenbrand wrote:
> On 03.03.25 13:13, Brendan Jackman wrote:
> > Since the migratetype hygiene patches [0], the locking here is
> > a bit more formalised.
> >
> > For other stuff, it's pretty obvious that it would be protected by the
> > zone lock. But it didn't seem totally self-evident that it should
> > protect the pageblock type. So it seems particularly helpful to have it
> > written in the code.
>
> [...]
>
> > +
> > u64 max_mem_size = U64_MAX;
> > /* add this memory to iomem resource */
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 579789600a3c7bfb7b0d847d51af702a9d4b139a..1ed21179676d05c66f77f9dbebf88e36bbe402e9 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -417,6 +417,10 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
> > void set_pageblock_migratetype(struct page *page, int migratetype)
> > {
> > + lockdep_assert_once(system_state == SYSTEM_BOOTING ||
> > + in_mem_hotplug() ||
> > + lockdep_is_held(&page_zone(page)->lock));
> > +
>
> I assume the call chain on the memory hotplug path is mostly
>
> move_pfn_range_to_zone()->memmap_init_range()->set_pageblock_migratetype()
>
> either when onlining a memory block, or from pagemap_range() while holding
> the hotplug lock.
>
> But there is also the memmap_init_zone_device()->memmap_init_compound()->__init_zone_device_page()->set_pageblock_migratetype()
> one, called from pagemap_range() *without* holding the hotplug lock, and you
> assertion would be missing that.
>
> I'm not too happy about that assertion in general.
Hmm, thanks for pointing that out.
I guess if we really wanted the assertion the approach would be to
replace in_mem_hotplug() with some more fine-grained logic about the
state of the pageblock? But that seems like it would require rework
that isn't really justified.
So yeah I guess this synchronization isn't as ready as I thought for
such a straightforwad "you need one of these locks here" assertion.
My ulterior motive here is the series I'm working on where the
pageblock records the ASI mapping status, so maybe I can find a weaker
assertion that at least helps with that more specific logic.
next prev parent reply other threads:[~2025-03-03 13:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 12:13 [PATCH v2] mm/page_alloc: Add lockdep assertion for pageblock type change Brendan Jackman
2025-03-03 13:11 ` David Hildenbrand
2025-03-03 13:48 ` David Hildenbrand
2025-03-03 13:55 ` Brendan Jackman [this message]
2025-03-03 14:06 ` David Hildenbrand
2025-03-03 16:00 ` Brendan Jackman
2025-03-03 17:06 ` David Hildenbrand
2025-03-04 12:50 ` Brendan Jackman
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=Z8W0v0LjuyH8ztTQ@google.com \
--to=jackmanb@google.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=vbabka@suse.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.