x86/setup: Use a more concise memblock API
PATCH 1/1 x86/setup: Use a more concise memblock API
When executing relocate_initrd(), the memblock.current_limit field has already been set to max_pfn_mapped << PAGE_SHIFT, so we can replace memblock_phys_alloc_range() with memblock_phys_alloc(), which has the same functionality but is more concise.
--- arch/x86/kernel/setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/setup.c +1 -2
@@ -259,8 +259,7 @@ static void __init relocate_initrd(void)u64 area_size =PAGE_ALIGN (ramdisk_size);/* We need to move the initrd down into directly mapped mem */ -u64 relocated_ramdisk =memblock_phys_alloc_range (area_size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); +u64 relocated_ramdisk =memblock_phys_alloc (area_size,PAGE_SIZE );if (!relocated_ramdisk)panic ("Cannot find place for new RAMDISK of size %lld\n" , ramdisk_size);
Signature · 1 line
2.42.1
Quoted 4 lines · Yuntao Wang
When executing
relocate_initrd(), the memblock.current_limit field has already been set tomax_pfn_mapped << PAGE_SHIFT, so we can replacememblock_phys_alloc_range()withmemblock_phys_alloc(), which has the same functionality but is more concise.
Fine to me, do we need consider other places in:
numa_alloc_distance()numa_emulation()
Quoted 23 lines
Signed-off-by Yuntao Wang <[email protected]>--- arch/x86/kernel/setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/x86/kernel/setup.c +1
-2@@ -259,8 +259,7 @@ static void __init relocate_initrd(void)u64 area_size =PAGE_ALIGN (ramdisk_size);/* We need to move the initrd down into directly mapped mem */ -u64 relocated_ramdisk =memblock_phys_alloc_range (area_size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); +u64 relocated_ramdisk =memblock_phys_alloc (area_size,PAGE_SIZE );if (!relocated_ramdisk)panic ("Cannot find place for new RAMDISK of size %lld\n" , ramdisk_size);Signature · 1 line
2.42.1
PATCH v2 1/1 x86/setup: Use a more concise memblock API
When executing relocate_initrd()/numa_emulation()/numa_alloc_distance(), the memblock.current_limit field has already been set to max_pfn_mapped << PAGE_SHIFT, therefore we can replace memblock_phys_alloc_range() with memblock_phys_alloc(), which has the same functionality but is more concise.
---
v1 -> v2:
Also replace memblock_phys_alloc_range() in numa_emulation() and numa_alloc_distance() with memblock_phys_alloc()
arch/x86/kernel/setup.c | 3 +-- arch/x86/mm/numa.c | 3 +-- arch/x86/mm/numa_emulation.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
arch/x86/kernel/setup.c +1 -2
@@ -259,8 +259,7 @@ static void __init relocate_initrd(void)u64 area_size =PAGE_ALIGN (ramdisk_size);/* We need to move the initrd down into directly mapped mem */ -u64 relocated_ramdisk =memblock_phys_alloc_range (area_size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); +u64 relocated_ramdisk =memblock_phys_alloc (area_size,PAGE_SIZE );if (!relocated_ramdisk)panic ("Cannot find place for new RAMDISK of size %lld\n" , ramdisk_size);
arch/x86/mm/numa.c +1 -2
@@ -378,8 +378,7 @@ static int __init numa_alloc_distance(void) cnt++; size = cnt * cnt *sizeof (numa_distance[0 ]); - phys =memblock_phys_alloc_range (size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); + phys =memblock_phys_alloc (size,PAGE_SIZE );if (!phys) {pr_warn ("Warning: can't allocate distance table!\n" );/* don't retry until explicitly reset */
arch/x86/mm/numa_emulation.c +1 -2
@@ -447,8 +447,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)if (numa_dist_cnt) {u64 phys; - phys =memblock_phys_alloc_range (phys_size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); + phys =memblock_phys_alloc (phys_size,PAGE_SIZE );if (!phys) {pr_warn ("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n" ); goto no_emu;
--
2.42.1
Quoted 6 lines · Yuntao Wang
When executing relocate_initrd()/numa_emulation()/numa_alloc_distance(), the memblock.current_limit field has already been set to
max_pfn_mapped << PAGE_SHIFT, therefore we can replacememblock_phys_alloc_range()withmemblock_phys_alloc(), which has the same functionality but is more concise.
Quoted 6 lines
Signed-off-by Yuntao Wang <[email protected]>---
v1 -> v2:Also replace
memblock_phys_alloc_range()innuma_emulation()andnuma_alloc_distance()withmemblock_phys_alloc()
LGTM,
Quoted 51 lines
arch/x86/kernel/setup.c | 3 +-- arch/x86/mm/numa.c | 3 +-- arch/x86/mm/numa_emulation.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)arch/x86/kernel/setup.c +1
-2@@ -259,8 +259,7 @@ static void __init relocate_initrd(void)u64 area_size =PAGE_ALIGN (ramdisk_size);/* We need to move the initrd down into directly mapped mem */ -u64 relocated_ramdisk =memblock_phys_alloc_range (area_size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); +u64 relocated_ramdisk =memblock_phys_alloc (area_size,PAGE_SIZE );if (!relocated_ramdisk)panic ("Cannot find place for new RAMDISK of size %lld\n" , ramdisk_size);arch/x86/mm/numa.c +1
-2@@ -378,8 +378,7 @@ static int __init numa_alloc_distance(void) cnt++; size = cnt * cnt *sizeof (numa_distance[0 ]); - phys =memblock_phys_alloc_range (size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); + phys =memblock_phys_alloc (size,PAGE_SIZE );if (!phys) {pr_warn ("Warning: can't allocate distance table!\n" );/* don't retry until explicitly reset */ arch/x86/mm/numa_emulation.c +1
-3@@ -447,8 +447,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)if (numa_dist_cnt) {u64 phys; - phys =memblock_phys_alloc_range (phys_size,PAGE_SIZE ,0 , -PFN_PHYS (max_pfn_mapped)); + phys =memblock_phys_alloc (phys_size,PAGE_SIZE );if (!phys) {pr_warn ("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n" ); goto no_emu; --2.42.1