Skip to contentSkip to conversation

crash-add-generic-infrastructure-for-crash-hotplug-support.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Aug 24, 2023

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: crash: add generic infrastructure for crash hotplug support
has been removed from the -mm tree. Its filename was
crash-add-generic-infrastructure-for-crash-hotplug-support.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Eric DeVolder <[email protected]>
Subject: crash: add generic infrastructure for crash hotplug support
Date: Mon, 14 Aug 2023 17:44:40 -0400

To support crash hotplug, a mechanism is needed to update the crash elfcorehdr upon CPU or memory changes (eg. hot un/plug or off/ onlining). The crash elfcorehdr describes the CPUs and memory to be written into the vmcore.

To track CPU changes, callbacks are registered with the cpuhp mechanism via cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN). The crash hotplug elfcorehdr update has no explicit ordering requirement (relative to other cpuhp states), so meets the criteria for utilizing CPUHP_BP_PREPARE_DYN. CPUHP_BP_PREPARE_DYN is a dynamic state and avoids the need to introduce a new state for crash hotplug. Also, CPUHP_BP_PREPARE_DYN is the last state in the PREPARE group, just prior to the STARTING group, which is very close to the CPU starting up in a plug/online situation, or stopping in a unplug/ offline situation. This minimizes the window of time during an actual plug/online or unplug/offline situation in which the elfcorehdr would be inaccurate. Note that for a CPU being unplugged or offlined, the CPU will still be present in the list of CPUs generated by crash_prepare_elf64_headers(). However, there is no need to explicitly omit the CPU, see justification in 'crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()'.

To track memory changes, a notifier is registered to capture the memblock MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier().

The CPU callbacks and memory notifiers invoke crash_handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event() to update the elfcorehdr with the current state of CPUs and memory. During the process, the kexec_lock is held.

Cc Akhil Raj <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Borislav Petkov (AMD) <[email protected]>
Cc Boris Ostrovsky <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Dave Young <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Mimi Zohar <[email protected]>
Cc Naveen N. Rao <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Sean Christopherson <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Thomas Weißschuh <[email protected]>
Cc Valentin Schneider <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 include/linux/crash_core.h |    7 +
 include/linux/kexec.h      |   11 ++
 kernel/Kconfig.kexec       |   31 +++++++
 kernel/crash_core.c        |  142 +++++++++++++++++++++++++++++++++++
 kernel/kexec_core.c        |    6 +
 5 files changed, 197 insertions(+)
include/linux/crash_core.h renamed from include/linux/crash_core.h~crash-add-generic-infrastructure-for-crash-hotplug-support +7 -0
@@ -104,4 +104,11 @@ extern int crash_prepare_elf64_headers(s
 struct kimage;
 struct kexec_segment;
 
+#define KEXEC_CRASH_HP_NONE			0
+#define KEXEC_CRASH_HP_ADD_CPU			1
+#define KEXEC_CRASH_HP_REMOVE_CPU		2
+#define KEXEC_CRASH_HP_ADD_MEMORY		3
+#define KEXEC_CRASH_HP_REMOVE_MEMORY		4
+#define KEXEC_CRASH_HP_INVALID_CPU		-1U
+
 #endif /* LINUX_CRASH_CORE_H */
include/linux/kexec.h renamed from include/linux/kexec.h~crash-add-generic-infrastructure-for-crash-hotplug-support +11 -0
@@ -33,6 +33,7 @@ extern note_buf_t __percpu *crash_notes;
 #include <linux/compat.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
+#include <linux/highmem.h>
 #include <asm/kexec.h>
 
 /* Verify architecture specific macros are defined */
@@ -345,6 +346,12 @@ struct kimage {
 	struct purgatory_info purgatory_info;
 #endif
 
+#ifdef CONFIG_CRASH_HOTPLUG
+	int hp_action;
+	int elfcorehdr_index;
+	bool elfcorehdr_updated;
+#endif
+
 #ifdef CONFIG_IMA_KEXEC
 	/* Virtual address of IMA measurement buffer for kexec syscall */
 	void *ima_buffer;
@@ -475,6 +482,10 @@ static inline int arch_kexec_post_alloc_
 static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { }
 #endif
 
+#ifndef arch_crash_handle_hotplug_event
+static inline void arch_crash_handle_hotplug_event(struct kimage *image) { }
+#endif
+
 #else /* !CONFIG_KEXEC_CORE */
 struct pt_regs;
 struct task_struct;
kernel/crash_core.c renamed from kernel/crash_core.c~crash-add-generic-infrastructure-for-crash-hotplug-support +142 -0

157 lines not on this page · raw message

kernel/Kconfig.kexec renamed from kernel/Kconfig.kexec~crash-add-generic-infrastructure-for-crash-hotplug-support +31 -0
@@ -112,4 +112,35 @@ config CRASH_DUMP
 	  For s390, this option also enables zfcpdump.
 	  See also <file:Documentation/s390/zfcpdump.rst>
 
+config CRASH_HOTPLUG
+	bool "Update the crash elfcorehdr on system configuration changes"
+	default y
+	depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG)
+	depends on ARCH_SUPPORTS_CRASH_HOTPLUG
+	help
+	  Enable direct update to the crash elfcorehdr (which contains
+	  the list of CPUs and memory regions to be dumped upon a crash)
+	  in response to hot plug/unplug or online/offline of CPUs or
+	  memory. This is a much more advanced approach than userspace
+	  attempting that.
+
+	  If unsure, say Y.
+
+config CRASH_MAX_MEMORY_RANGES
+	int "Specify the maximum number of memory regions for the elfcorehdr"
+	default 8192
+	depends on CRASH_HOTPLUG
+	help
+	  For the kexec_file_load() syscall path, specify the maximum number of
+	  memory regions that the elfcorehdr buffer/segment can accommodate.
+	  These regions are obtained via walk_system_ram_res(); eg. the
+	  'System RAM' entries in /proc/iomem.
+	  This value is combined with NR_CPUS_DEFAULT and multiplied by
+	  sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/
+	  segment size.
+	  The value 8192, for example, covers a (sparsely populated) 1TiB system
+	  consisting of 128MiB memblocks, while resulting in an elfcorehdr
+	  memory buffer/segment size under 1MiB. This represents a sane choice
+	  to accommodate both baremetal and virtual machine configurations.
+
 endmenu
kernel/kexec_core.c renamed from kernel/kexec_core.c~crash-add-generic-infrastructure-for-crash-hotplug-support +6 -0
@@ -274,6 +274,12 @@ struct kimage *do_kimage_alloc_init(void
 	/* Initialize the list of unusable pages */
 	INIT_LIST_HEAD(&image->unusable_pages);
 
+#ifdef CONFIG_CRASH_HOTPLUG
+	image->hp_action = KEXEC_CRASH_HP_NONE;
+	image->elfcorehdr_index = -1;
+	image->elfcorehdr_updated = false;
+#endif
+
 	return image;
 }
 

_

Patches currently in -mm which might be from [email protected] are