mm/mm_init: don't subtract managed CMA pages twice
PATCH 1/1 mm/mm_init: don't subtract managed CMA pages twice
From: Chris Mason <[email protected]>
With hugetlb_cma_only, the "reserved" value in the "Memory:" boot message can be wrong (small or underflowed).
When mem_init_print_info() calculates the reserved memory, it assumes that no CMA pages are managed yet. However, some CMA pages from hugetlb might already be managed at that point, so we end up subtracting them twice.
Fix it by only subtracting CMA pages that are not managed yet.
This has very low urgency, as it only affects a boot message.
---
This should go through the memblock tree.
--- mm/mm_init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
mm/mm_init.c +7 -1
@@ -2608,6 +2608,12 @@ static void __init mem_init_print_info(void) {unsigned long physpages, codesize, datasize, rosize, bss_size;unsigned long init_code_size, init_data_size; +unsigned long unmanaged_cma = totalcma_pages; +struct zone *zone; + +/* Some CMA pages might already be managed. */ +for_each_populated_zone (zone) + unmanaged_cma -=zone_cma_pages (zone); physpages =get_num_physpages (); codesize = _etext - _stext;
@@ -2647,7 +2653,7 @@ static void __init mem_init_print_info(void)K (nr_free_pages ()),K (physpages), codesize /SZ_1K , datasize /SZ_1K , rosize /SZ_1K , (init_data_size + init_code_size) /SZ_1K , bss_size /SZ_1K , -K (physpages -totalram_pages () - totalcma_pages), +K (physpages -totalram_pages () - unmanaged_cma),K (totalcma_pages) #ifdef CONFIG_HIGHMEM ,K (totalhigh_pages ())
---
base-commit: d9a27fa1050902a6e38bdb780b0277cbf1dfa5a5
change-id: 20261119-cma_managed-2541ae8731ae
Best regards,
Signature · 1 line
David Hildenbrand (Arm) <[email protected]>
Quoted 13 lines · David Hildenbrand (Arm)
From: Chris Mason <[email protected]>
With
hugetlb_cma_only, the "reserved" value in the "Memory:" boot message can be wrong (small or underflowed).When
mem_init_print_info()calculates the reserved memory, it assumes that no CMA pages are managed yet. However, some CMA pages from hugetlb might already be managed at that point, so we end up subtracting them twice.
Quoted 8 lines
Fix it by only subtracting CMA pages that are not managed yet.
This has very low urgency, as it only affects a boot message.
Fixes b1b7c045e808 ("mm/hugetlb: initialize gigantic bootmem hugepage struct pages earlier")Signed-off-by Chris Mason <[email protected]>[ david: improve description and comment ]Signed-off-by David Hildenbrand (Arm) <[email protected]>
Thanks.
Mike Rapoport
maintainerQuoted 8 lines · David Hildenbrand (Arm)
From: Chris Mason <[email protected]>
With
hugetlb_cma_only, the "reserved" value in the "Memory:" boot message can be wrong (small or underflowed).When
mem_init_print_info()calculates the reserved memory, it assumes that no CMA pages are managed yet. However, some CMA pages from hugetlb might already be managed at that point,
How about I change it to
However, hugetlb may have already initialized its bootmem CMA areas,
when applying?
Quoted 5 lines
so we end up subtracting them twice.
Fix it by only subtracting CMA pages that are not managed yet.
This has very low urgency, as it only affects a boot message.
Agree :)
Quoted 9 lines
Fixes b1b7c045e808 ("mm/hugetlb: initialize gigantic bootmem hugepage struct pages earlier")Signed-off-by Chris Mason <[email protected]>[ david: improve description and comment ]Signed-off-by David Hildenbrand (Arm) <[email protected]>---
This should go through the memblock tree.--- mm/mm_init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 2 lines
Sincerely yours, Mike.
Quoted 6 lines · Mike Rapoport
Quoted 5 lines · David Hildenbrand (Arm)
From: Chris Mason <[email protected]>
With
hugetlb_cma_only, the "reserved" value in the "Memory:" boot message can be wrong (small or underflowed).
Quoted 7 lines
Quoted 3 lines
When
mem_init_print_info()calculates the reserved memory, it assumes that no CMA pages are managed yet. However, some CMA pages from hugetlb might already be managed at that point,How about I change it to
However, hugetlb may have already initialized its bootmem CMA areas,
sure, why not. Thanks!
Signature · 3 lines
Cheers, David
From: Mike Rapoport (Microsoft) <[email protected]>
Quoted 8 lines · David Hildenbrand (Arm)
With
hugetlb_cma_only, the "reserved" value in the "Memory:" boot message can be wrong (small or underflowed).When
mem_init_print_info()calculates the reserved memory, it assumes that no CMA pages are managed yet. However, some CMA pages from hugetlb might already be managed at that point, so we end up subtracting them twice.[...]
Applied to for-next branch of memblock.git tree, thanks!
[1/1] mm/mm_init: don't subtract managed CMA pages twice
commit: 3a348bd13cd3bc5ae6d1f564473f40166cc2009d
tree: https://git.kernel.org/pub/scm/linux/kernel/git/mm/memblock
branch: for-next
--
Sincerely yours,
Mike.
Quoted 9 lines · David Hildenbrand (Arm)
From: Chris Mason <[email protected]>
With
hugetlb_cma_only, the "reserved" value in the "Memory:" boot message can be wrong (small or underflowed).When
mem_init_print_info()calculates the reserved memory, it assumes that no CMA pages are managed yet. However, some CMA pages from hugetlb might already be managed at that point, so we end up subtracting them twice.
Quoted 8 lines
Fix it by only subtracting CMA pages that are not managed yet.
This has very low urgency, as it only affects a boot message.
Fixes b1b7c045e808 ("mm/hugetlb: initialize gigantic bootmem hugepage struct pages earlier")Signed-off-by Chris Mason <[email protected]>[ david: improve description and comment ]Signed-off-by David Hildenbrand (Arm) <[email protected]>
Signature · 2 lines
Oscar Salvador SUSE Labs