* [PATCH 0/2] powerpc/kexec: automatically allocating mem for crashkernel=Y @ 2018-08-31 7:30 Pingfan Liu 2018-08-31 7:30 ` [PATCH 1/2] powerpc/prom: move mmu_early_init_devtree() before early_init_dt_scan_cpus() Pingfan Liu 2018-08-31 7:30 ` [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel Pingfan Liu 0 siblings, 2 replies; 4+ messages in thread From: Pingfan Liu @ 2018-08-31 7:30 UTC (permalink / raw) To: linuxppc-dev Cc: Pingfan Liu, Benjamin Herrenschmidt, Michael Ellerman, Hari Bathini, Mahesh Salgaonkar, Anton Blanchard 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() Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Hari Bathini <hbathini@linux.ibm.com> Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Cc: Anton Blanchard <anton@samba.org> 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(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] powerpc/prom: move mmu_early_init_devtree() before early_init_dt_scan_cpus() 2018-08-31 7:30 [PATCH 0/2] powerpc/kexec: automatically allocating mem for crashkernel=Y Pingfan Liu @ 2018-08-31 7:30 ` Pingfan Liu 2018-08-31 7:30 ` [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel Pingfan Liu 1 sibling, 0 replies; 4+ messages in thread From: Pingfan Liu @ 2018-08-31 7:30 UTC (permalink / raw) To: linuxppc-dev Cc: Pingfan Liu, Benjamin Herrenschmidt, Michael Ellerman, Hari Bathini, Mahesh Salgaonkar, Anton Blanchard 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. Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Hari Bathini <hbathini@linux.ibm.com> Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Cc: Anton Blanchard <anton@samba.org> --- arch/powerpc/kernel/prom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index c4d7078..cae4a78 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -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); -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel 2018-08-31 7:30 [PATCH 0/2] powerpc/kexec: automatically allocating mem for crashkernel=Y Pingfan Liu 2018-08-31 7:30 ` [PATCH 1/2] powerpc/prom: move mmu_early_init_devtree() before early_init_dt_scan_cpus() Pingfan Liu @ 2018-08-31 7:30 ` Pingfan Liu 2022-07-07 9:42 ` Christophe Leroy 1 sibling, 1 reply; 4+ messages in thread From: Pingfan Liu @ 2018-08-31 7:30 UTC (permalink / raw) To: linuxppc-dev Cc: Pingfan Liu, Benjamin Herrenschmidt, Michael Ellerman, Hari Bathini, Mahesh Salgaonkar, Anton Blanchard 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() Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Hari Bathini <hbathini@linux.ibm.com> Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Cc: Anton Blanchard <anton@samba.org> --- arch/powerpc/kernel/machine_kexec.c | 24 +++++++++++++++--------- arch/powerpc/kernel/prom.c | 7 +++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c index 63f5a93..78005bf 100644 --- a/arch/powerpc/kernel/machine_kexec.c +++ b/arch/powerpc/kernel/machine_kexec.c @@ -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 diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index cae4a78..8b2ab99 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -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, ...) -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel 2018-08-31 7:30 ` [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel Pingfan Liu @ 2022-07-07 9:42 ` Christophe Leroy 0 siblings, 0 replies; 4+ messages in thread From: Christophe Leroy @ 2022-07-07 9:42 UTC (permalink / raw) To: Pingfan Liu, linuxppc-dev, Sourabh Jain Cc: Mahesh Salgaonkar, Anton Blanchard, Hari Bathini Le 31/08/2018 à 09:30, Pingfan Liu a écrit : > 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() 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 > > Signed-off-by: Pingfan Liu <kernelfans@gmail.com> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> > Cc: Michael Ellerman <mpe@ellerman.id.au> > Cc: Hari Bathini <hbathini@linux.ibm.com> > Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> > Cc: Anton Blanchard <anton@samba.org> > --- > arch/powerpc/kernel/machine_kexec.c | 24 +++++++++++++++--------- > arch/powerpc/kernel/prom.c | 7 +++++-- > 2 files changed, 20 insertions(+), 11 deletions(-) > > diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c > index 63f5a93..78005bf 100644 > --- a/arch/powerpc/kernel/machine_kexec.c > +++ b/arch/powerpc/kernel/machine_kexec.c > @@ -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 > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c > index cae4a78..8b2ab99 100644 > --- a/arch/powerpc/kernel/prom.c > +++ b/arch/powerpc/kernel/prom.c > @@ -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, ...) ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-07 9:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-08-31 7:30 [PATCH 0/2] powerpc/kexec: automatically allocating mem for crashkernel=Y Pingfan Liu 2018-08-31 7:30 ` [PATCH 1/2] powerpc/prom: move mmu_early_init_devtree() before early_init_dt_scan_cpus() Pingfan Liu 2018-08-31 7:30 ` [PATCH 2/2] powerpc/kexec: avoid hard coding when automatically allocating mem for crashkernel Pingfan Liu 2022-07-07 9:42 ` Christophe Leroy
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).