On 2/28/25 10:20, Brendan Jackman wrote: > 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@xxxxxxxxxx> 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 guess that's a good addition to the changelog. Acked-by: Vlastimil Babka <vbabka@xxxxxxx> > > 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@xxxxxxxxxxxxxx/T/ >