[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z8F_16DEb1j-aAcB@google.com>
Date: Fri, 28 Feb 2025 09:20:23 +0000
From: Brendan Jackman <jackmanb@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: David Hildenbrand <david@...hat.com>,
Oscar Salvador <osalvador@...e.de>,
Johannes Weiner <hannes@...xchg.org>,
Vlastimil Babka <vbabka@...e.cz>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/page_alloc: Add lockdep assertion for pageblock type
change
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@...gle.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/
Powered by blists - more mailing lists