From: Brendan Jackman <jackmanb@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>,
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] mm/page_alloc: Add lockdep assertion for pageblock type change
Date: Fri, 28 Feb 2025 09:20:23 +0000 [thread overview]
Message-ID: <Z8F_16DEb1j-aAcB@google.com> (raw)
In-Reply-To: <20250227143302.2338b1cf15919c64a6c1eb27@linux-foundation.org>
On Thu, Feb 27, 2025 at 02:33:02PM -0800, Andrew Morton wrote:
> On Thu, 27 Feb 2025 16:15:47 +0000 Brendan Jackman <jackmanb@google.com> wrote:
>
> > Since the migratetype hygiene patches [0], the locking here is
> > a bit more formalised, so write it down with an assert.
> >
> > ...
> >
> > --- 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));
> > +
> > if (unlikely(page_group_by_mobility_disabled &&
> > migratetype < MIGRATE_PCPTYPES))
> > migratetype = MIGRATE_UNMOVABLE;
> >
>
> We could add such assertions all over the place. Why this place in
> particular?
For the other stuff, it's pretty obvious that it would be protected by
the zone lock (or, I don't know about it!). But it didn't seem totally
self-evident to me that it should protect the pageblock type. So it
seems particularly helpful to have it written in the code.
I may be heavily biased about this though, because of the code I'm
working on for [0]. I use the pageblock type to remember whether it's
mapped in the ASI restricted address space.
[0] https://lore.kernel.org/linux-mm/CA+i-1C1gOBLxRxE5YFGzeayYWBYyE_X6oH4D=9eVePt4=ehTig@mail.gmail.com/T/
next prev parent reply other threads:[~2025-02-28 9:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 16:15 Brendan Jackman
2025-02-27 22:33 ` Andrew Morton
2025-02-28 9:20 ` Brendan Jackman [this message]
2025-02-28 10:12 ` Vlastimil Babka
2025-02-28 17:31 ` kernel test robot
2025-02-28 18:28 ` Johannes Weiner
2025-03-03 11:18 ` Andy Shevchenko
2025-03-03 23:13 ` Stephen Rothwell
2025-03-04 10:18 ` Brendan Jackman
2025-03-04 10:31 ` David Hildenbrand
2025-02-28 23:42 ` kernel test robot
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=Z8F_16DEb1j-aAcB@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox