Skip to content

Commit 493f349

Browse files
Yuwei Guanrppt
authored andcommitted
memblock: Add flags and nid info in memblock debugfs
Currently, the memblock debugfs can display the count of memblock_type and the base and end of the reg. However, when memblock_mark_*() or memblock_set_node() is executed on some range, the information in the existing debugfs cannot make it clear why the address is not consecutive. For example, cat /sys/kernel/debug/memblock/memory 0: 0x0000000080000000..0x00000000901fffff 1: 0x0000000090200000..0x00000000905fffff 2: 0x0000000090600000..0x0000000092ffffff 3: 0x0000000093000000..0x00000000973fffff 4: 0x0000000097400000..0x00000000b71fffff 5: 0x00000000c0000000..0x00000000dfffffff 6: 0x00000000e2500000..0x00000000f87fffff 7: 0x00000000f8800000..0x00000000fa7fffff 8: 0x00000000fa800000..0x00000000fd3effff 9: 0x00000000fd3f0000..0x00000000fd3fefff 10: 0x00000000fd3ff000..0x00000000fd7fffff 11: 0x00000000fd800000..0x00000000fd901fff 12: 0x00000000fd902000..0x00000000fd909fff 13: 0x00000000fd90a000..0x00000000fd90bfff 14: 0x00000000fd90c000..0x00000000ffffffff 15: 0x0000000880000000..0x0000000affffffff So we can add flags and nid to this debugfs. For example, cat /sys/kernel/debug/memblock/memory 0: 0x0000000080000000..0x00000000901fffff 0 NONE 1: 0x0000000090200000..0x00000000905fffff 0 NOMAP 2: 0x0000000090600000..0x0000000092ffffff 0 NONE 3: 0x0000000093000000..0x00000000973fffff 0 NOMAP 4: 0x0000000097400000..0x00000000b71fffff 0 NONE 5: 0x00000000c0000000..0x00000000dfffffff 0 NONE 6: 0x00000000e2500000..0x00000000f87fffff 0 NONE 7: 0x00000000f8800000..0x00000000fa7fffff 0 NOMAP 8: 0x00000000fa800000..0x00000000fd3effff 0 NONE 9: 0x00000000fd3f0000..0x00000000fd3fefff 0 NOMAP 10: 0x00000000fd3ff000..0x00000000fd7fffff 0 NONE 11: 0x00000000fd800000..0x00000000fd901fff 0 NOMAP 12: 0x00000000fd902000..0x00000000fd909fff 0 NONE 13: 0x00000000fd90a000..0x00000000fd90bfff 0 NOMAP 14: 0x00000000fd90c000..0x00000000ffffffff 0 NONE 15: 0x0000000880000000..0x0000000affffffff 0 NONE Signed-off-by: Yuwei Guan <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Reviewed-by: Kefeng Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport (IBM) <[email protected]>
1 parent fc493f8 commit 493f349

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

mm/memblock.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,20 +2158,40 @@ void __init memblock_free_all(void)
21582158
}
21592159

21602160
#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK)
2161+
static const char * const flagname[] = {
2162+
[ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG",
2163+
[ilog2(MEMBLOCK_MIRROR)] = "MIRROR",
2164+
[ilog2(MEMBLOCK_NOMAP)] = "NOMAP",
2165+
[ilog2(MEMBLOCK_DRIVER_MANAGED)] = "DRV_MNG",
2166+
};
21612167

21622168
static int memblock_debug_show(struct seq_file *m, void *private)
21632169
{
21642170
struct memblock_type *type = m->private;
21652171
struct memblock_region *reg;
2166-
int i;
2172+
int i, j;
2173+
unsigned int count = ARRAY_SIZE(flagname);
21672174
phys_addr_t end;
21682175

21692176
for (i = 0; i < type->cnt; i++) {
21702177
reg = &type->regions[i];
21712178
end = reg->base + reg->size - 1;
21722179

21732180
seq_printf(m, "%4d: ", i);
2174-
seq_printf(m, "%pa..%pa\n", &reg->base, &end);
2181+
seq_printf(m, "%pa..%pa ", &reg->base, &end);
2182+
seq_printf(m, "%4d ", memblock_get_region_node(reg));
2183+
if (reg->flags) {
2184+
for (j = 0; j < count; j++) {
2185+
if (reg->flags & (1U << j)) {
2186+
seq_printf(m, "%s\n", flagname[j]);
2187+
break;
2188+
}
2189+
}
2190+
if (j == count)
2191+
seq_printf(m, "%s\n", "UNKNOWN");
2192+
} else {
2193+
seq_printf(m, "%s\n", "NONE");
2194+
}
21752195
}
21762196
return 0;
21772197
}

0 commit comments

Comments
 (0)