mm: sparse: Skip no-map regions in memblocks_present
Subsystems (2)
PATCH 1/1 mm: sparse: Skip no-map regions in memblocks_present
Do not mark regions that are marked with nomap to be present, otherwise these memblock cause unnecessarily allocation of metadata.
--- mm/sparse.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/sparse.c +4 -0
@@ -256,6 +256,10 @@ void __init memblocks_present(void)struct memblock_region *reg;for_each_memblock (memory, reg) { + +if (memblock_is_nomap (reg)) +continue ; +memory_present (memblock_get_region_node (reg),memblock_region_memory_base_pfn (reg),memblock_region_memory_end_pfn (reg));
Signature · 1 line
2.7.4
Quoted 24 lines · KarimAllah Ahmed
Do not mark regions that are marked with nomap to be present, otherwise these memblock cause unnecessarily allocation of metadata.
Cc Andrew Morton <[email protected]>Cc Pavel Tatashin <[email protected]>Cc Oscar Salvador <[email protected]>Cc Michal Hocko <[email protected]>Cc Mike Rapoport <[email protected]>Cc Baoquan He <[email protected]>Cc Qian Cai <[email protected]>Cc Wei Yang <[email protected]>Cc Logan Gunthorpe <[email protected]>Signed-off-by KarimAllah Ahmed <[email protected]>---
mm/sparse.c| 4 ++++1 file changed, 4 insertions(+)mm/sparse.c +0
-0
mm/sparse.c void __init memblocks_present(void) · line 265
Quoted 10 lines
mm/sparse.c +4
-0@@ -256,6 +256,10 @@ void __init memblocks_present(void)struct memblock_region *reg;for_each_memblock (memory, reg) { + +if (memblock_is_nomap (reg)) +continue ; +memory_present (memblock_get_region_node (reg),memblock_region_memory_base_pfn (reg),memblock_region_memory_end_pfn (reg));
The logic looks good, while I am not sure this would take effect. Since the metadata is SECTION size aligned while memblock is not.
If I am correct, on arm64, we mark nomap memblock in map_mem()
memblock_mark_nomap(kernel_start, kernel_end - kernel_start);
And kernel text area is less than 40M, if I am right. This means memblocks_present would still mark the section present.
Would you mind showing how much memory range it is marked nomap?
Quoted 2 lines
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 41 lines · Wei Yang
Quoted 25 lines · KarimAllah Ahmed
Do not mark regions that are marked with nomap to be present, otherwise these memblock cause unnecessarily allocation of metadata.
Cc Andrew Morton <[email protected]>Cc Pavel Tatashin <[email protected]>Cc Oscar Salvador <[email protected]>Cc Michal Hocko <[email protected]>Cc Mike Rapoport <[email protected]>Cc Baoquan He <[email protected]>Cc Qian Cai <[email protected]>Cc Wei Yang <[email protected]>Cc Logan Gunthorpe <[email protected]>Signed-off-by KarimAllah Ahmed <[email protected]>---
mm/sparse.c| 4 ++++1 file changed, 4 insertions(+)mm/sparse.c +0
-0mm/sparse.c void __init memblocks_present(void) · line 265
Quoted 10 lines
mm/sparse.c +4
-0@@ -256,6 +256,10 @@ void __init memblocks_present(void)struct memblock_region *reg;for_each_memblock (memory, reg) { + +if (memblock_is_nomap (reg)) +continue ; +memory_present (memblock_get_region_node (reg),memblock_region_memory_base_pfn (reg),memblock_region_memory_end_pfn (reg));The logic looks good, while I am not sure this would take effect. Since the metadata is SECTION size aligned while memblock is not.
Quoted 3 lines
If I am correct, on arm64, we mark nomap memblock in
map_mem()memblock_mark_nomap(kernel_start, kernel_end - kernel_start);
The nomap is also done by EFI code in ${src}/drivers/firmware/efi/arm-init.c
.. and hopefully in the future by this:
https://lkml.org/lkml/2019/7/12/126
So it is not really striclty associated with the map_mem().
So it is extremely dependent on the platform how much memory will end up mapped as nomap.
Quoted 5 lines
And kernel text area is less than 40M, if I am right. This means
memblocks_presentwould still mark the section present.Would you mind showing how much memory range it is marked nomap?
We actually have some downstream patches that are using this nomap flag for more than the use-cases I described above which would enflate the nomap regions a bit :)
Quoted 5 lines
Quoted 4 lines
Signature · 2 lines
-- 2.7.4
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Quoted 57 lines · KarimAllah
Quoted 41 lines · Wei Yang
Quoted 25 lines · KarimAllah Ahmed
Do not mark regions that are marked with nomap to be present, otherwise these memblock cause unnecessarily allocation of metadata.
Cc Andrew Morton <[email protected]>Cc Pavel Tatashin <[email protected]>Cc Oscar Salvador <[email protected]>Cc Michal Hocko <[email protected]>Cc Mike Rapoport <[email protected]>Cc Baoquan He <[email protected]>Cc Qian Cai <[email protected]>Cc Wei Yang <[email protected]>Cc Logan Gunthorpe <[email protected]>Signed-off-by KarimAllah Ahmed <[email protected]>---
mm/sparse.c| 4 ++++1 file changed, 4 insertions(+)mm/sparse.c +0
-0mm/sparse.c void __init memblocks_present(void) · line 265
Quoted 10 lines
mm/sparse.c +4
-0@@ -256,6 +256,10 @@ void __init memblocks_present(void)struct memblock_region *reg;for_each_memblock (memory, reg) { + +if (memblock_is_nomap (reg)) +continue ; +memory_present (memblock_get_region_node (reg),memblock_region_memory_base_pfn (reg),memblock_region_memory_end_pfn (reg));The logic looks good, while I am not sure this would take effect. Since the metadata is SECTION size aligned while memblock is not.
Quoted 3 lines
If I am correct, on arm64, we mark nomap memblock in
map_mem()memblock_mark_nomap(kernel_start, kernel_end - kernel_start);The nomap is also done by EFI code in
${src}/drivers/firmware/efi/arm-init.c.. and hopefully in the future by this:
https://lkml.org/lkml/2019/7/12/126So it is not really striclty associated with the
map_mem().So it is extremely dependent on the platform how much memory will end up mapped?? as nomap.
Quoted 1 line
Quoted 9 lines
Quoted 4 lines
And kernel text area is less than 40M, if I am right. This means
memblocks_presentwould still mark the section present.Would you mind showing how much memory range it is marked nomap?
We actually have some downstream patches that are using this nomap flag for more than the use-cases I described above which would enflate the nomap regions?? a bit :)
Thanks for your explanation.
If my understanding is correct, the range you mark nomap could not be used by the system, it looks those ranges are useless for the system. Just curious about how linux could use these memory after marking nomap?
Quoted 17 lines
Quoted 5 lines
Quoted 4 lines
Signature · 2 lines
-- 2.7.4Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 2 lines · KarimAllah Ahmed
Do not mark regions that are marked with nomap to be present, otherwise these memblock cause unnecessarily allocation of metadata.
This begs for much more information. How come nomap regions are in usable memblocks? What if memblock allocator used that memory? In other words, shouldn't nomap (an unusable memory iirc) be in reserved memblocks or removed altogethher?
Quoted 33 lines
Cc Andrew Morton <[email protected]>Cc Pavel Tatashin <[email protected]>Cc Oscar Salvador <[email protected]>Cc Michal Hocko <[email protected]>Cc Mike Rapoport <[email protected]>Cc Baoquan He <[email protected]>Cc Qian Cai <[email protected]>Cc Wei Yang <[email protected]>Cc Logan Gunthorpe <[email protected]>Signed-off-by KarimAllah Ahmed <[email protected]>--- mm/sparse.c | 4 ++++ 1 file changed, 4 insertions(+)mm/sparse.c +4
-0@@ -256,6 +256,10 @@ void __init memblocks_present(void)struct memblock_region *reg;for_each_memblock (memory, reg) { + +if (memblock_is_nomap (reg)) +continue ; +memory_present (memblock_get_region_node (reg),memblock_region_memory_base_pfn (reg),memblock_region_memory_end_pfn (reg));Signature · 1 line
2.7.4
Signature · 2 lines
Michal Hocko SUSE Labs