memblock: Add flags and nid info in memblock debugfs
PATCH v4 1/1 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
---
v4:
- show string value for each memblock flag
--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
mm/memblock.c +22 -2
@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {
@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg)); +if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ; + } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }
Signature · 1 line
2.34.1
Quoted 45 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory0: 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
Quoted 1 line
Signed-off-by Yuwei Guan <[email protected]>
LGTM
Quoted 54 lines
---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +22
-2@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg)); +if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ; + } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }
Quoted 28 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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/memory0: 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..0x00000000fd3fefff10: 0x00000000fd3ff000..0x00000000fd7fffff
11: 0x00000000fd800000..0x00000000fd901fff
12: 0x00000000fd902000..0x00000000fd909fff
13: 0x00000000fd90a000..0x00000000fd90bfff
14: 0x00000000fd90c000..0x00000000ffffffff
15: 0x0000000880000000..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory
Quoted 16 lines
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 NONEIt's useful for debug memblock, thanks,
I also found memblock reserved type's node is always wrong, from memblock=debug, and read /sys/kernel/debug/memblock/reserved return bad node info, I will send a patch.
Quoted 56 lines
Signed-off-by Yuwei Guan <[email protected]>---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +22
-2@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg)); +if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ; + } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }
Mike Rapoport
maintainerHi,
Quoted 80 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory0: 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 NONESigned-off-by Yuwei Guan <[email protected]>---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +8
-1@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;
mm/memblock.c static int memblock_debug_show(struct seq_file *m, void *private) · line 2165
Quoted 10 lines
mm/memblock.c +7
-1seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg)); +if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ;
The flags are mostly mutually exclusive because it's unlikely they are used together, but not because there are some restrictions on possible flags combinations. So generally it's possible to have multiple flags set on the same region.
Sorry, I missed that in v3.
Quoted 13 lines
mm/memblock.c +7
-0+ } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 84 lines · Mike Rapoport
Hi,
Quoted 81 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory0: 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 NONESigned-off-by Yuwei Guan <[email protected]>---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +8
-1@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;
Quoted 14 lines
mm/memblock.c static int memblock_debug_show(struct seq_file *m, void *private) · line 2165
Quoted 9 lines
mm/memblock.c +7
-1seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg)); +if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ;The flags are mostly mutually exclusive because it's unlikely they are used together, but not because there are some restrictions on possible flags combinations. So generally it's possible to have multiple flags set on the same region.
But do we really need to account for that as of now, when no memblock region carries more than a single flag ? But in that case all flags here need to be printed with "|" in between ?
Quoted 17 lines
Sorry, I missed that in v3.
Quoted 13 lines
mm/memblock.c +7
-0+ } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }Signature · 1 line
2.34.1
Mike Rapoport
maintainerQuoted 100 lines · Anshuman Khandual
Quoted 84 lines · Mike Rapoport
Hi,
Quoted 81 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory0: 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 NONESigned-off-by Yuwei Guan <[email protected]>---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +8
-1@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;Quoted 14 lines
mm/memblock.c static int memblock_debug_show(struct seq_file *m, void *private) · line 2165
Quoted 9 lines
mm/memblock.c +7
-1seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg)); +if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ;The flags are mostly mutually exclusive because it's unlikely they are used together, but not because there are some restrictions on possible flags combinations. So generally it's possible to have multiple flags set on the same region.
Quoted 2 lines
But do we really need to account for that as of now, when no memblock region carries more than a single flag ?
Right now we don't care indeed, I'm a bit concerned of what will happen if we'd have regions with multiple flags set.
Quoted 1 line
But in that case all flags here need to be printed with "|" in between ?
We could use space rather than "|" for simplicity, but thinking more about it, I'm inclined to just take this version and we'll deal with multiple flags if/when required.
Quoted 16 lines
Quoted 16 lines
Sorry, I missed that in v3.
Quoted 13 lines
mm/memblock.c +7
-0+ } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 45 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory0: 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
Quoted 1 line
Signed-off-by Yuwei Guan <[email protected]>
Applied, thanks!
Quoted 57 lines
---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +22
-2@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg)); +if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ; + } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Mike Rapoport
maintainerHi Yuwei,
Quoted 79 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory0: 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 NONESigned-off-by Yuwei Guan <[email protected]>---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +8
-1@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {
mm/memblock.c static int memblock_debug_show(struct seq_file *m, void *private) · line 2160
Quoted 6 lines
mm/memblock.c +2
-1@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg));
As Kefeng mentioned, the node id for reserved regions will be wrong, so this needs to be updated so that when reg->nid == MAX_NUMNODES we'll print e.g. 'x'.
Quoted 18 lines
mm/memblock.c +12
-0+if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ; + } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 85 lines · Mike Rapoport <[email protected]> 于2023年5月27日周六 18:37写道:
Hi Yuwei,
Quoted 81 lines · Yuwei Guan
Currently, the memblock debugfs can display the count of
memblock_typeand the base and end of the reg. However, when memblock_mark_*() ormemblock_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..0x0000000affffffffSo we can add flags and nid to this debugfs.
For example,
cat/sys/kernel/debug/memblock/memory0: 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 NONESigned-off-by Yuwei Guan <[email protected]>---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +8
-1@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;
Quoted 8 lines
mm/memblock.c static int memblock_debug_show(struct seq_file *m, void *private) · line 2160
Quoted 4 lines
mm/memblock.c +2
-1seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg));As Kefeng mentioned, the node id for reserved regions will be wrong, so this needs to be updated so that when
reg->nid==MAX_NUMNODESwe'll print e.g. 'x'.
Hi Mike,
How about print 'x' when reg->nid == MAX_NUMNODES, base on this patch,
https://lore.kernel.org/linux-mm/[email protected]/T/#m6d214d4ea8912b64f5efc9c3f51ae71aa057d1f1
mm/memblock.c +0 -0
@@ -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 ", ®->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)) {
Quoted 23 lines
Quoted 17 lines
mm/memblock.c +12
-1+if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ; + } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; } --Quoted 2 lines
2.34.1
--
Sincerely yours,
Mike.
Mike Rapoport
maintainerQuoted 50 lines · Yuwei Guan
Quoted 41 lines · Mike Rapoport <[email protected]> 于2023年5月27日周六 18:37写道:
Hi Yuwei,
Quoted 36 lines · Yuwei Guan
Signed-off-by Yuwei Guan <[email protected]>---
v4:
- show string value for each memblock flag--- mm/memblock.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)mm/memblock.c +8
-1@@ -2136,12 +2136,19 @@ void __init memblock_free_all(void) }#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_ARCH_KEEP_MEMBLOCK ) +static const char *const flagname[] = { + [ilog2 (MEMBLOCK_HOTPLUG )] ="HOTPLUG" , + [ilog2 (MEMBLOCK_MIRROR )] ="MIRROR" , + [ilog2 (MEMBLOCK_NOMAP )] ="NOMAP" , + [ilog2 (MEMBLOCK_DRIVER_MANAGED )] ="DRV_MNG" , +};static int memblock_debug_show (struct seq_file *m,void *private) {struct memblock_type *type = m->private;struct memblock_region *reg; -int i; +int i, j; +unsigned int count =ARRAY_SIZE (flagname);phys_addr_t end;for (i =0 ; i < type->cnt; i++) {@@ -2149,7 +2156,20 @@ static int memblock_debug_show(struct seq_file *m, void *private) end = reg->base + reg->size -1 ;Quoted 8 lines
mm/memblock.c static int memblock_debug_show(struct seq_file *m, void *private) · line 2160
Quoted 4 lines
mm/memblock.c +2
-1seq_printf (m,"%4d: " , i); -seq_printf (m,"%pa..%pa\n" , ®->base, &end); +seq_printf (m,"%pa..%pa " , ®->base, &end); +seq_printf (m,"%4d " ,memblock_get_region_node (reg));As Kefeng mentioned, the node id for reserved regions will be wrong, so this needs to be updated so that when
reg->nid==MAX_NUMNODESwe'll print e.g. 'x'.
Quoted 4 lines
Hi Mike,
How about print 'x' when
reg->nid==MAX_NUMNODES, base on this patch,
https://lore.kernel.org/linux-mm/[email protected]/T/#m6d214d4ea8912b64f5efc9c3f51ae71aa057d1f1
This is fine, can you please send a formal patch?
Quoted 53 lines
mm/memblock.c +6
-2@@ -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 " , ®->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)) {Quoted 23 lines
Quoted 17 lines
mm/memblock.c +12
-1+if (reg->flags) { +for (j =0 ; j < count; j++) { +if (reg->flags & (1U << j)) { +seq_printf (m,"%s\n" , flagname[j]); +break ; + } + } +if (j == count) +seq_printf (m,"%s\n" ,"UNKNOWN" ); + }else { +seq_printf (m,"%s\n" ,"NONE" ); + } }return 0 ; } --Quoted 2 lines
2.34.1
--
Sincerely yours,
Mike.
Signature · 2 lines
Sincerely yours, Mike.