The patch titled Subject: mm/page_alloc: add lockdep assertion for pageblock type change has been added to the -mm mm-unstable branch. Its filename is mm-page_alloc-add-lockdep-assertion-for-pageblock-type-change.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_alloc-add-lockdep-assertion-for-pageblock-type-change.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Brendan Jackman <jackmanb@xxxxxxxxxx> Subject: mm/page_alloc: add lockdep assertion for pageblock type change Date: Thu, 27 Feb 2025 16:15:47 +0000 Since the migratetype hygiene patches [0], the locking here is a bit more formalised, so write it down with an assert. [0] https://lore.kernel.org/lkml/20240320180429.678181-3-hannes@xxxxxxxxxxx/T/ Link: https://lkml.kernel.org/r/20250227-pageblock-lockdep-v1-1-3701efb331bb@xxxxxxxxxx Signed-off-by: Brendan Jackman <jackmanb@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Oscar Salvador <osalvador@xxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/memory_hotplug.h | 1 + mm/memory_hotplug.c | 5 +++++ mm/page_alloc.c | 4 ++++ 3 files changed, 10 insertions(+) --- a/include/linux/memory_hotplug.h~mm-page_alloc-add-lockdep-assertion-for-pageblock-type-change +++ a/include/linux/memory_hotplug.h @@ -175,6 +175,7 @@ void put_online_mems(void); void mem_hotplug_begin(void); void mem_hotplug_done(void); +bool in_mem_hotplug(void); /* See kswapd_is_running() */ static inline void pgdat_kswapd_lock(pg_data_t *pgdat) --- a/mm/memory_hotplug.c~mm-page_alloc-add-lockdep-assertion-for-pageblock-type-change +++ a/mm/memory_hotplug.c @@ -267,6 +267,11 @@ void mem_hotplug_done(void) cpus_read_unlock(); } +bool in_mem_hotplug(void) +{ + return percpu_is_write_locked(&mem_hotplug_lock); +} + u64 max_mem_size = U64_MAX; /* add this memory to iomem resource */ --- a/mm/page_alloc.c~mm-page_alloc-add-lockdep-assertion-for-pageblock-type-change +++ a/mm/page_alloc.c @@ -417,6 +417,10 @@ void set_pfnblock_flags_mask(struct page 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; _ Patches currently in -mm which might be from jackmanb@xxxxxxxxxx are mm-mmu_gather-update-comment-on-rcu-freeing.patch selftests-mm-report-errno-when-things-fail-in-gup_longterm.patch selftests-mm-fix-assumption-that-sudo-is-present.patch selftests-mm-skip-uffd-stress-if-userfaultfd-not-available.patch selftests-mm-skip-uffd-wp-mremap-if-userfaultfd-not-available.patch selftests-mm-uffd-rename-nr_cpus-nr_threads.patch selftests-mm-print-some-details-when-uffd-stress-gets-bad-params.patch selftests-mm-dont-fail-uffd-stress-if-too-many-cpus.patch selftests-mm-skip-map_populate-on-weird-filesystems.patch selftests-mm-skip-gup_longerm-tests-on-weird-filesystems.patch mm-page_alloc-warn-on-nr_reserved_highatomic-underflow.patch mm-page_alloc-clarify-terminology-in-migratetype-fallback-code.patch mm-page_alloc-clarify-should_claim_block-commentary.patch mm-page_alloc-add-lockdep-assertion-for-pageblock-type-change.patch scripts-gdb-add-lx_per_cpu_ptr.patch