[PATCH v2 19/25] mm/sparse: Register information into meminspect

From: Mukesh Ojha

Date: Tue Mar 10 2026 - 16:24:31 EST


Annotate vital static, dynamic information into meminspect for
debugging:
- mem_section (static)
- section (dynamic)
- mem_section_usage(dynamic)

meminspect uses a different API to annotate variables for inspection,
and information about these variables is stored in the inspection table.

Co-developed-by: Eugen Hristev <eugen.hristev@xxxxxxxxxx>
Signed-off-by: Eugen Hristev <eugen.hristev@xxxxxxxxxx>
Signed-off-by: Mukesh Ojha <mukesh.ojha@xxxxxxxxxxxxxxxx>
---
mm/sparse.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/mm/sparse.c b/mm/sparse.c
index dfabe554adf8..38beae2d4294 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -15,6 +15,7 @@
#include <linux/swapops.h>
#include <linux/bootmem_info.h>
#include <linux/vmstat.h>
+#include <linux/meminspect.h>
#include "internal.h"
#include <asm/dma.h>

@@ -30,6 +31,7 @@ struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]
____cacheline_internodealigned_in_smp;
#endif
EXPORT_SYMBOL(mem_section);
+MEMINSPECT_SIMPLE_ENTRY(mem_section);

#ifdef NODE_NOT_IN_PAGE_FLAGS
/*
@@ -253,6 +255,7 @@ static void __init memblocks_present(void)
size = sizeof(struct mem_section *) * NR_SECTION_ROOTS;
align = 1 << (INTERNODE_CACHE_SHIFT);
mem_section = memblock_alloc_or_panic(size, align);
+ meminspect_register_va(mem_section, size);
}
#endif

@@ -343,6 +346,9 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
limit = MEMBLOCK_ALLOC_ACCESSIBLE;
goto again;
}
+
+ meminspect_register_va(usage, size);
+
return usage;
}


--
2.50.1