powerpc/kexec: automatically allocating mem for crashkernel=Y
cover powerpc/kexec: automatically allocating mem for crashkernel=Y
If no start address is specified for crashkernel, the current program hard code as: crashk_res.start = min(0x8000000ULL, (ppc64_rma_size / 2)); This limits the candidate memory region, and may cause failure while there is enough mem for crashkernel. This patch suggests to find a suitable mem chunk by memblock_find_in_range()
Pingfan Liu (2):
powerpc/prom: move mmu_early_init_devtree() before
early_init_dt_scan_cpus()
powerpc/kexec: avoid hard coding when automatically allocating mem for
crashkernel
arch/powerpc/kernel/machine_kexec.c | 24 +++++++++++++++--------- arch/powerpc/kernel/prom.c | 10 ++++++---- 2 files changed, 21 insertions(+), 13 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 powerpc/prom: move mmu_early_init_devtree() before early_init_dt_scan_cpus()
In early_init_dt_scan_cpus() -> allocate_paca(), using ppc64_bolted_size() to get the limitation. Although MMU_SEGSIZE_256M is enough for boot cpu's paca, but in fact the bolted segment size may be MMU_SEGSIZE_1T. Hence moving mmu_early_init_devtree() a little earlier, and let any callers of ppc64_bolted_size() get the right value.
--- arch/powerpc/kernel/prom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/kernel/prom.c +1 -2
@@ -760,6 +760,7 @@ void __init early_init_devtree(void *params)DBG ("Scanning CPUs ...\n" );dt_cpu_ftrs_scan (); +mmu_early_init_devtree ();/* Retrieve CPU related informations from the flat tree * (altivec support, boot CPU ID, ...)
@@ -777,8 +778,6 @@ void __init early_init_devtree(void *params) spinning_secondaries = boot_cpu_count -1 ;#endif -mmu_early_init_devtree (); -#ifdef CONFIG_PPC_POWERNV /* Scan and build the list of machine check recoverable ranges */ of_scan_flat_dt (early_init_dt_scan_recoverable_ranges,NULL );
Signature · 1 line
2.7.4
PATCH 2/2 powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel
In reply to Pingfan LiuIf no start address is specified for crashkernel, the current program hard code as: crashk_res.start = min(0x8000000ULL, (ppc64_rma_size / 2)); This limits the candidate memory region, and may cause failure while there is enough mem for crashkernel. This patch suggests to find a suitable mem chunk by memblock_find_in_range()
--- arch/powerpc/kernel/machine_kexec.c | 24 +++++++++++++++--------- arch/powerpc/kernel/prom.c | 7 +++++-- 2 files changed, 20 insertions(+), 11 deletions(-)
arch/powerpc/kernel/machine_kexec.c +15 -9
@@ -22,6 +22,9 @@#include <asm/pgalloc.h> #include <asm/prom.h> #include <asm/sections.h> +#include <asm/mmu.h> + +#include "setup.h" void machine_kexec_mask_interrupts (void ) {unsigned int i;
@@ -117,6 +120,7 @@ void machine_kexec(struct kimage *image)void __init reserve_crashkernel (void ) {unsigned long long crash_size, crash_base; +phys_addr_t start, up_boundary;int ret;/* use common parsing */
@@ -146,22 +150,24 @@ void __init reserve_crashkernel(void)#else if (!crashk_res.start) {#ifdef CONFIG_PPC64 -/* -* On 64bit we split the RMO in half but cap it at half of -* a small SLB (128MB) since the crash kernel needs to place -* itself and some stacks to be in the first segment. -*/ - crashk_res.start =min (0x8000000ULL , (ppc64_rma_size /2 )); + up_boundary =min (ppc64_bolted_size (), ppc64_rma_size); + start =memblock_find_in_range (KDUMP_KERNELBASE , up_boundary, + crash_size,PAGE_SIZE ); +if (start ==0 ) { +pr_err ("Failed to reserve memory for crashkernel!\n" ); + crashk_res.start = crashk_res.end =0 ; +return ; + }else + crashk_res.start = start;#else crashk_res.start =KDUMP_KERNELBASE ;#endif } - crash_base =PAGE_ALIGN (crashk_res.start); -if (crash_base != crashk_res.start) { +if (crashk_res.start !=PAGE_ALIGN (crashk_res.start)) {printk ("Crash kernel base must be aligned to 0x%lx\n" ,PAGE_SIZE ); - crashk_res.start = crash_base; + crashk_res.start =PAGE_ALIGN (crashk_res.start); }#endif
arch/powerpc/kernel/prom.c +5 -2
@@ -688,6 +688,7 @@ static void tm_init(void) { }void __init early_init_devtree (void *params) {phys_addr_t limit; +bool fadump_enabled = false;DBG (" -> early_init_devtree(%p)\n" , params);
@@ -737,9 +738,9 @@ void __init early_init_devtree(void *params)* If we fail to reserve memory for firmware-assisted dump then * fallback to kexec based kdump. */ - if (fadump_reserve_mem() == 0) +if (fadump_reserve_mem () ==1 ) + fadump_enabled = true;#endif -reserve_crashkernel ();early_reserve_mem ();/* Ensure that total memory size is page-aligned. */
@@ -761,6 +762,8 @@ void __init early_init_devtree(void *params)dt_cpu_ftrs_scan ();mmu_early_init_devtree (); +if (!fadump_enabled) +reserve_crashkernel ();/* Retrieve CPU related informations from the flat tree * (altivec support, boot CPU ID, ...)
Signature · 1 line
2.7.4
Re: [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel
Le 31/08/2018 à 09:30, Pingfan Liu a écrit :
Quoted 5 lines
If no start address is specified for crashkernel, the current program hard code as: crashk_res.start =
min(0x8000000ULL, (ppc64_rma_size / 2)); This limits the candidate memory region, and may cause failure while there is enough mem for crashkernel. This patch suggests to find a suitable mem chunk bymemblock_find_in_range()
Seems like something more or less similar was done with commit 7c5ed82b800d ("powerpc: Set crashkernel offset to mid of RMA region")
At least your patch conflicts with that commit, so if you think your patch is still relevant, please rebase and resubmit your series.
Thanks
Christophe
Quoted 101 lines
Signed-off-by Pingfan Liu <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Michael Ellerman <[email protected]>Cc Hari Bathini <[email protected]>Cc Mahesh Salgaonkar <[email protected]>Cc Anton Blanchard <[email protected]>--- arch/powerpc/kernel/machine_kexec.c | 24 +++++++++++++++--------- arch/powerpc/kernel/prom.c | 7 +++++-- 2 files changed, 20 insertions(+), 11 deletions(-)arch/powerpc/kernel/machine_kexec.c +15
-9@@ -22,6 +22,9 @@#include <asm/pgalloc.h> #include <asm/prom.h> #include <asm/sections.h> +#include <asm/mmu.h> + +#include "setup.h" void machine_kexec_mask_interrupts (void ) {unsigned int i;@@ -117,6 +120,7 @@ void machine_kexec(struct kimage *image)void __init reserve_crashkernel (void ) {unsigned long long crash_size, crash_base; +phys_addr_t start, up_boundary;int ret;/* use common parsing */ @@ -146,22 +150,24 @@ void __init reserve_crashkernel(void)#else if (!crashk_res.start) {#ifdef CONFIG_PPC64 -/* -* On 64bit we split the RMO in half but cap it at half of -* a small SLB (128MB) since the crash kernel needs to place -* itself and some stacks to be in the first segment. -*/ - crashk_res.start =min (0x8000000ULL , (ppc64_rma_size /2 )); + up_boundary =min (ppc64_bolted_size (), ppc64_rma_size); + start =memblock_find_in_range (KDUMP_KERNELBASE , up_boundary, + crash_size,PAGE_SIZE ); +if (start ==0 ) { +pr_err ("Failed to reserve memory for crashkernel!\n" ); + crashk_res.start = crashk_res.end =0 ; +return ; + }else + crashk_res.start = start;#else crashk_res.start =KDUMP_KERNELBASE ;#endif } - crash_base =PAGE_ALIGN (crashk_res.start); -if (crash_base != crashk_res.start) { +if (crashk_res.start !=PAGE_ALIGN (crashk_res.start)) {printk ("Crash kernel base must be aligned to 0x%lx\n" ,PAGE_SIZE ); - crashk_res.start = crash_base; + crashk_res.start =PAGE_ALIGN (crashk_res.start); }#endif arch/powerpc/kernel/prom.c +5
-2@@ -688,6 +688,7 @@ static void tm_init(void) { }void __init early_init_devtree (void *params) {phys_addr_t limit; +bool fadump_enabled = false;DBG (" -> early_init_devtree(%p)\n" , params);@@ -737,9 +738,9 @@ void __init early_init_devtree(void *params)* If we fail to reserve memory for firmware-assisted dump then * fallback to kexec based kdump. */ - if (fadump_reserve_mem() == 0) +if (fadump_reserve_mem () ==1 ) + fadump_enabled = true;#endif -reserve_crashkernel ();early_reserve_mem ();/* Ensure that total memory size is page-aligned. */ @@ -761,6 +762,8 @@ void __init early_init_devtree(void *params)dt_cpu_ftrs_scan ();mmu_early_init_devtree (); +if (!fadump_enabled) +reserve_crashkernel ();/* Retrieve CPU related informations from the flat tree * (altivec support, boot CPU ID, ...)