[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230131224236.122805-6-eric.devolder@oracle.com>
Date: Tue, 31 Jan 2023 17:42:34 -0500
From: Eric DeVolder <eric.devolder@...cle.com>
To: linux-kernel@...r.kernel.org, x86@...nel.org,
kexec@...ts.infradead.org, ebiederm@...ssion.com,
dyoung@...hat.com, bhe@...hat.com, vgoyal@...hat.com
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, hpa@...or.com,
nramas@...ux.microsoft.com, thomas.lendacky@....com,
robh@...nel.org, efault@....de, rppt@...nel.org, david@...hat.com,
sourabhjain@...ux.ibm.com, konrad.wilk@...cle.com,
boris.ostrovsky@...cle.com, eric.devolder@...cle.com
Subject: [PATCH v18 5/7] kexec: exclude hot remove cpu from elfcorehdr notes
In crash_prepare_elf64_headers(), the for_each_present_cpu() is
utilized to create the new elfcorehdr. When handling CPU hot
unplug/offline events, the CPU is still on the for_each_present_cpu()
list (not until the cpuhp state processing reaches CPUHP_OFFLINE does
the CPU exit the list). Thus the CPU must be explicitly excluded when
building the new list of CPUs.
This change identifies in handle_hotplug_event() the CPU to be
excluded, and the check for excluding the CPU in
crash_prepare_elf64_headers().
Signed-off-by: Eric DeVolder <eric.devolder@...cle.com>
Acked-by: Baoquan He <bhe@...hat.com>
---
kernel/crash_core.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 5545de4597d0..d985d334fae4 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -366,6 +366,14 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem,
/* Prepare one phdr of type PT_NOTE for each present CPU */
for_each_present_cpu(cpu) {
+#ifdef CONFIG_CRASH_HOTPLUG
+ if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) {
+ /* Skip the soon-to-be offlined cpu */
+ if ((image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU) &&
+ (cpu == image->offlinecpu))
+ continue;
+ }
+#endif
phdr->p_type = PT_NOTE;
notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu));
phdr->p_offset = phdr->p_paddr = notes_addr;
@@ -769,6 +777,14 @@ static void handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
/* Differentiate between normal load and hotplug update */
image->hp_action = hp_action;
+ /*
+ * Record which CPU is being unplugged/offlined, so that it
+ * is explicitly excluded in crash_prepare_elf64_headers().
+ */
+ image->offlinecpu =
+ (hp_action == KEXEC_CRASH_HP_REMOVE_CPU) ?
+ cpu : KEXEC_CRASH_HP_INVALID_CPU;
+
/* Now invoke arch-specific update handler */
arch_crash_handle_hotplug_event(image);
--
2.31.1
Powered by blists - more mailing lists