Thread (31 messages) 31 messages, 5 authors, 2026-09-02

Re: [PATCH v3 12/17] x86/crash: Use num_possible_cpus() for elfcorehdr size

flat view

From: Jinjie Ruan <hidden>
Date: 2026-09-02 10:01:25
Also in: kexec, linux-fsdevel, linux-mm, lkml, loongarch


在 2026/9/2 14:14, Sourabh Jain 写道:
Hello Jinjie,

This patch makes the below patch redundant..
https://lore.kernel.org/all/20260826073527.21487-2-
ionut.nechita@windriver.com/

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.
Agreed. This approach makes sense to me.

I will update it in v4.
- Sourabh Jain


On 26/08/26 14:55, Jinjie Ruan wrote:
quoted
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 <redacted>
---
  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);
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help