[PATCH v3 12/17] x86/crash: Use num_possible_cpus() for elfcorehdr size
Jinjie Ruan <[email protected]>
| Newsgroups | dev.linux.lists.loongarch,org.infradead.lists.kexec,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm,org.ozlabs.lists.linuxppc-dev |
|---|---|
| Message-ID | <[email protected]> |
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); -- 2.34.1