From: David Hildenbrand <david@redhat.com>
To: Brendan Jackman <jackmanb@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Oscar Salvador <osalvador@suse.de>
Cc: 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 14:11:23 +0100 [thread overview]
Message-ID: <4d0f0bca-3096-4fb4-9e8b-d4dcdf7eeb92@redhat.com> (raw)
In-Reply-To: <20250303-pageblock-lockdep-v2-1-3fc0c37e9532@google.com>
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.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-03-03 13:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 12:13 Brendan Jackman
2025-03-03 13:11 ` David Hildenbrand [this message]
2025-03-03 13:48 ` David Hildenbrand
2025-03-03 13:55 ` Brendan Jackman
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=4d0f0bca-3096-4fb4-9e8b-d4dcdf7eeb92@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox