Re: [PATCH v3 12/17] x86/crash: Use num_possible_cpus() for elfcorehdr size
Sourabh Jain <[email protected]>
| Newsgroups | gmane.linux.ports.ppc.embedded |
|---|---|
| Message-ID | <99b1121d-4277-4764-8c3a-b3f6d9a47ab0__1271.59404089383$1788329751$gmane$org@linux.ibm.com> |
Hello Jinjie, This patch makes the below patch redundant.. https://lore.kernel.org/all/[email protected]/ I suggest dropping the first patch from the above series and including the second patch from that series in this patch series with the updated comment. - Sourabh Jain On 26/08/26 14:55, Jinjie Ruan wrote: > Use num_possible_cpus() instead of CONFIG_NR_CPUS to calculate the > elfcorehdr buffer size, matching what crash_prepare_elf64_headers() > already uses for the actual header content. > > This avoids over-allocation when the system has fewer possible CPUs > than the compile-time limit, and aligns x86 with PowerPC. > > Signed-off-by: Jinjie Ruan <[email protected]> > --- > arch/x86/kernel/crash.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c > index a3bf786286d4..afe2aea19f47 100644 > --- a/arch/x86/kernel/crash.c > +++ b/arch/x86/kernel/crash.c > @@ -369,9 +369,9 @@ int crash_load_segments(struct kimage *image) > * maximum CPUs and maximum memory ranges. > */ > if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) > - pnum = 2 + CONFIG_NR_CPUS + CONFIG_CRASH_MAX_MEMORY_RANGES; > + pnum = 2 + num_possible_cpus() + CONFIG_CRASH_MAX_MEMORY_RANGES; > else > - pnum += 2 + CONFIG_NR_CPUS; > + pnum += 2 + num_possible_cpus(); > > if (pnum < (unsigned long)PN_XNUM) { > kbuf.memsz = elf64_phdr_size(pnum); > @@ -429,7 +429,7 @@ unsigned int arch_crash_get_elfcorehdr_size(void) > unsigned int sz; > > /* kernel_map, VMCOREINFO and maximum CPUs */ > - sz = 2 + CONFIG_NR_CPUS; > + sz = 2 + num_possible_cpus(); > if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) > sz += CONFIG_CRASH_MAX_MEMORY_RANGES; > sz *= sizeof(Elf64_Phdr);