um/mm: get max_low_pfn from memblock
Subsystems (2)
PATCH 1/1 um/mm: get max_low_pfn from memblock
Current calculation of max_low_pfn is introduced in commit af84eab20891 ("[PATCH] uml: fix LVM crash"). It is intended to set max_low_pfn to the same value as max_pfn.
But I am not sure why the max_pfn is set to totalram_pages, which represents the number of usable pages in system instead of an absolute page frame number. (The change history stops there.)
While we can get the maximum page frame number from memblock, this looks more reasonable than setting to totalram_pages.
Also this would help changing totalram_pages accounting, since we plan to move the accounting into __free_pages_core(). With this change, totalram_pages may not represent the total usable pages at this point, since some pages would be deferred initialized.
---
A simple UML bootup test looks good.
--- arch/um/kernel/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/kernel/mem.c +1 -1
@@ -73,7 +73,7 @@ void __init mem_init(void)/* this will put all low memory onto the freelists */ memblock_free_all (); - max_low_pfn =totalram_pages (); + max_low_pfn =PFN_DOWN (memblock_end_of_DRAM ()); max_pfn = max_low_pfn; kmalloc_ok =1 ; }
Signature · 1 line
2.34.1
Quoted 8 lines · Wei Yang
Current calculation of
max_low_pfnis introduced in commitaf84eab20891("[PATCH] uml: fix LVM crash"). It is intended to setmax_low_pfnto the same value asmax_pfn.But I am not sure why the
max_pfnis set tototalram_pages, which represents the number of usable pages in system instead of an absolute page frame number. (The change history stops there.)
Quoted 7 lines
While we can get the maximum page frame number from memblock, this looks more reasonable than setting to
totalram_pages.Also this would help changing
totalram_pagesaccounting, since we plan to move the accounting into__free_pages_core(). With this change,totalram_pagesmay not represent the total usable pages at this point, since some pages would be deferred initialized.
Question is if deferred page init is even a thing on UM. But it certainly looks odd+suspiciously wrong to rely on totalram_pages().
Quoted 22 lines
Signed-off-by Wei Yang <[email protected]>CC Jason Lunz <[email protected]>CC Jeff Dike <[email protected]>Cc Paolo 'Blaisorblade' Giarrusso <[email protected]>Cc Alasdair G Kergon <[email protected]>Cc Jens Axboe <[email protected]>CC Andrew Morton <[email protected]>CC Mike Rapoport (IBM) <[email protected]>CC David Hildenbrand <[email protected]>---
A simple UML bootup test looks good.--- arch/um/kernel/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/um/kernel/mem.c +0
-0
arch/um/kernel/mem.c void __init mem_init(void) · line 79
Quoted 8 lines
arch/um/kernel/mem.c +1
-1@@ -73,7 +73,7 @@ void __init mem_init(void)/* this will put all low memory onto the freelists */ memblock_free_all (); - max_low_pfn =totalram_pages (); + max_low_pfn =PFN_DOWN (memblock_end_of_DRAM ()); max_pfn = max_low_pfn; kmalloc_ok =1 ; }
Matches what a bunch of other archs do.
Randomly staring at other users:
arch/loongarch/kernel/numa.c: max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); arch/loongarch/kernel/setup.c: max_low_pfn = PFN_PHYS(memblock_end_of_DRAM());
What? the latter cannot possibly be right, no? Looks odd at least. Only applies to CONFIG_OF_EARLY_FLATTREE. CCing loongarch maintainer.
Signature · 3 lines
Cheers, David / dhildenb
Quoted 12 lines · David Hildenbrand
Quoted 11 lines · Wei Yang
Current calculation of
max_low_pfnis introduced in commitaf84eab20891("[PATCH] uml: fix LVM crash"). It is intended to setmax_low_pfnto the same value asmax_pfn.But I am not sure why the
max_pfnis set tototalram_pages, which represents the number of usable pages in system instead of an absolute page frame number. (The change history stops there.)While we can get the maximum page frame number from memblock, this looks more reasonable than setting to
totalram_pages.
Quoted 6 lines
Quoted 4 lines
Also this would help changing
totalram_pagesaccounting, since we plan to move the accounting into__free_pages_core(). With this change,totalram_pagesmay not represent the total usable pages at this point, since some pages would be deferred initialized.Question is if deferred page init is even a thing on UM. But it certainly looks odd+suspiciously wrong to rely on
totalram_pages().
As long as there is no HIGHMEM,
max_pfn = max_low_pfn = PFN_DOWN(memblock_end_of_DRAM())
should be ok.
Quoted 16 lines
Quoted 16 lines
Signed-off-by Wei Yang <[email protected]>CC Jason Lunz <[email protected]>CC Jeff Dike <[email protected]>Cc Paolo 'Blaisorblade' Giarrusso <[email protected]>Cc Alasdair G Kergon <[email protected]>Cc Jens Axboe <[email protected]>CC Andrew Morton <[email protected]>CC Mike Rapoport (IBM) <[email protected]>CC David Hildenbrand <[email protected]>---
A simple UML bootup test looks good.--- arch/um/kernel/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 9 lines
arch/um/kernel/mem.c void __init mem_init(void) · line 75
Quoted 9 lines
arch/um/kernel/mem.c +1
-1@@ -73,7 +73,7 @@ void __init mem_init(void)/* this will put all low memory onto the freelists */ memblock_free_all (); - max_low_pfn =totalram_pages (); + max_low_pfn =PFN_DOWN (memblock_end_of_DRAM ());
This assignment seem redundant as there is already
max_low_pfn = min_low_pfn + (map_size >> PAGE_SHIFT);
in setup_physmem
Quoted 22 lines
arch/um/kernel/mem.c void __init mem_init(void) · line 79
Quoted 3 lines
arch/um/kernel/mem.c +0
-0max_pfn = max_low_pfn; kmalloc_ok =1 ; }Matches what a bunch of other archs do.
Randomly staring at other users:
arch/loongarch/kernel/numa.c: max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); arch/loongarch/kernel/setup.c: max_low_pfn = PFN_PHYS(memblock_end_of_DRAM());What? the latter cannot possibly be right, no? Looks odd at least. Only applies to
CONFIG_OF_EARLY_FLATTREE. CCing loongarch maintainer.Signature · 3 lines
Cheers, David / dhildenb
Signature · 2 lines
Sincerely yours, Mike.
Quoted 54 lines · Mike Rapoport
Quoted 12 lines · David Hildenbrand
Quoted 11 lines · Wei Yang
Current calculation of
max_low_pfnis introduced in commitaf84eab20891("[PATCH] uml: fix LVM crash"). It is intended to setmax_low_pfnto the same value asmax_pfn.But I am not sure why the
max_pfnis set tototalram_pages, which represents the number of usable pages in system instead of an absolute page frame number. (The change history stops there.)While we can get the maximum page frame number from memblock, this looks more reasonable than setting to
totalram_pages.Quoted 6 lines
Quoted 4 lines
Also this would help changing
totalram_pagesaccounting, since we plan to move the accounting into__free_pages_core(). With this change,totalram_pagesmay not represent the total usable pages at this point, since some pages would be deferred initialized.Question is if deferred page init is even a thing on UM. But it certainly looks odd+suspiciously wrong to rely on
totalram_pages().As long as there is no HIGHMEM,
max_pfn=max_low_pfn= PFN_DOWN(memblock_end_of_DRAM())should be ok.
Quoted 16 lines
Quoted 16 lines
Signed-off-by Wei Yang <[email protected]>CC Jason Lunz <[email protected]>CC Jeff Dike <[email protected]>Cc Paolo 'Blaisorblade' Giarrusso <[email protected]>Cc Alasdair G Kergon <[email protected]>Cc Jens Axboe <[email protected]>CC Andrew Morton <[email protected]>CC Mike Rapoport (IBM) <[email protected]>CC David Hildenbrand <[email protected]>---
A simple UML bootup test looks good.--- arch/um/kernel/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 9 lines
arch/um/kernel/mem.c void __init mem_init(void) · line 75
Quoted 9 lines
arch/um/kernel/mem.c +1
-1@@ -73,7 +73,7 @@ void __init mem_init(void)/* this will put all low memory onto the freelists */ memblock_free_all (); - max_low_pfn =totalram_pages (); + max_low_pfn =PFN_DOWN (memblock_end_of_DRAM ());This assignment seem redundant as there is already
Quoted 4 lines
max_low_pfn = min_low_pfn + (map_size >> PAGE_SHIFT);in
setup_physmem
Looks right, I added some log and shows they are the same.
Thanks
Quoted 26 lines
Quoted 22 lines
arch/um/kernel/mem.c void __init mem_init(void) · line 79
Quoted 3 lines
arch/um/kernel/mem.c +0
-0max_pfn = max_low_pfn; kmalloc_ok =1 ; }Matches what a bunch of other archs do.
Randomly staring at other users:
arch/loongarch/kernel/numa.c: max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); arch/loongarch/kernel/setup.c: max_low_pfn = PFN_PHYS(memblock_end_of_DRAM());What? the latter cannot possibly be right, no? Looks odd at least. Only applies to
CONFIG_OF_EARLY_FLATTREE. CCing loongarch maintainer.Signature · 3 lines
Cheers, David / dhildenbSignature · 2 lines
Sincerely yours, Mike.
Signature · 2 lines
Wei Yang Help you, Help me