memblock: Update nid info in memblock debugfs
authorYuwei Guan <ssawgyw@gmail.com>
Thu, 1 Jun 2023 13:31:49 +0000 (21:31 +0800)
committerMike Rapoport (IBM) <rppt@kernel.org>
Fri, 2 Jun 2023 05:23:41 +0000 (08:23 +0300)
The node id for memblock reserved regions will be wrong,
so let's show 'x' for reg->nid == MAX_NUMNODES in debugfs to keep it align.

Suggested-by: Mike Rapoport (IBM) <rppt@kernel.org>
Co-developed-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Yuwei Guan <ssawgyw@gmail.com>
Link: https://lore.kernel.org/r/20230601133149.37160-1-ssawgyw@gmail.com
Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
mm/memblock.c

index c5c80d9bcea3d9e32618f3d38bb022e38441ab4d..3d449aaba0525fe3ec865899b49df9a93d35b5a3 100644 (file)
@@ -2169,17 +2169,21 @@ static int memblock_debug_show(struct seq_file *m, void *private)
 {
        struct memblock_type *type = m->private;
        struct memblock_region *reg;
-       int i, j;
+       int i, j, nid;
        unsigned int count = ARRAY_SIZE(flagname);
        phys_addr_t end;
 
        for (i = 0; i < type->cnt; i++) {
                reg = &type->regions[i];
                end = reg->base + reg->size - 1;
+               nid = memblock_get_region_node(reg);
 
                seq_printf(m, "%4d: ", i);
                seq_printf(m, "%pa..%pa ", &reg->base, &end);
-               seq_printf(m, "%4d ", memblock_get_region_node(reg));
+               if (nid != MAX_NUMNODES)
+                       seq_printf(m, "%4d ", nid);
+               else
+                       seq_printf(m, "%4c ", 'x');
                if (reg->flags) {
                        for (j = 0; j < count; j++) {
                                if (reg->flags & (1U << j)) {