[PATCH 2/2] mm: memblock: show all region flags in debugfs
From: Meijing Zhao
Date: Wed Aug 19 2026 - 03:56:20 EST
From: Meijing Zhao <zhaomeijing@xxxxxxxxxxx>
Commit 493f349e38d0 ("memblock: Add flags and nid info in memblock
debugfs") made memblock_debug_show() stop after finding the first set
flag. A memblock region can carry multiple flags, so debugfs hides all
but the lowest set bit.
In particular, memory allocated for HugeTLB pages is reserved with both
MEMBLOCK_RSRV_KERN and MEMBLOCK_RSRV_HUGETLB, but debugfs only reports
RSV_KERN.
Print every set flag separated by '|'. A HugeTLB reservation is now
shown as:
RSV_KERN|RSV_HUGETLB
instead of:
RSV_KERN
Fixes: 493f349e38d0 ("memblock: Add flags and nid info in memblock debugfs")
Signed-off-by: Meijing Zhao <zhaomeijing@xxxxxxxxxxx>
---
mm/memblock.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/mm/memblock.c b/mm/memblock.c
index f2952d725c10..5d806fe92cd7 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2896,6 +2896,7 @@ static int memblock_debug_show(struct seq_file *m, void *private)
int i, j, nid;
unsigned int count = ARRAY_SIZE(flagname);
phys_addr_t end;
+ bool first;
for (i = 0; i < type->cnt; i++) {
reg = &type->regions[i];
@@ -2909,14 +2910,18 @@ static int memblock_debug_show(struct seq_file *m, void *private)
else
seq_printf(m, "%4c ", 'x');
if (reg->flags) {
+ first = true;
for (j = 0; j < count; j++) {
- if (reg->flags & (1U << j)) {
- seq_printf(m, "%s\n", flagname[j]);
- break;
- }
+ if (!(reg->flags & (1U << j)))
+ continue;
+ if (!first)
+ seq_putc(m, '|');
+ seq_puts(m, flagname[j] ?: "UNKNOWN");
+ first = false;
}
- if (j == count)
- seq_printf(m, "%s\n", "UNKNOWN");
+ if (first)
+ seq_puts(m, "UNKNOWN");
+ seq_putc(m, '\n');
} else {
seq_printf(m, "%s\n", "NONE");
}
--
2.25.1