Skip to content

Commit 1180057

Browse files
sourabhjainsmpe
authored andcommitted
crash: forward memory_notify arg to arch crash hotplug handler
In the event of memory hotplug or online/offline events, the crash memory hotplug notifier `crash_memhp_notifier()` receives a `memory_notify` object but doesn't forward that object to the generic and architecture-specific crash hotplug handler. The `memory_notify` object contains the starting PFN (Page Frame Number) and the number of pages in the hot-removed memory. This information is necessary for architectures like PowerPC to update/recreate the kdump image, specifically `elfcorehdr`. So update the function signature of `crash_handle_hotplug_event()` and `arch_crash_handle_hotplug_event()` to accept the `memory_notify` object as an argument from crash memory hotplug notifier. Since no such object is available in the case of CPU hotplug event, the crash CPU hotplug notifier `crash_cpuhp_online()` passes NULL to the crash hotplug handler. Signed-off-by: Sourabh Jain <[email protected]> Acked-by: Baoquan He <[email protected]> Acked-by: Hari Bathini <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 39cd87c commit 1180057

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

arch/x86/include/asm/kexec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image);
207207
extern void kdump_nmi_shootdown_cpus(void);
208208

209209
#ifdef CONFIG_CRASH_HOTPLUG
210-
void arch_crash_handle_hotplug_event(struct kimage *image);
210+
void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
211211
#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
212212

213213
#ifdef CONFIG_HOTPLUG_CPU

arch/x86/kernel/crash.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,12 @@ unsigned int arch_crash_get_elfcorehdr_size(void)
432432
/**
433433
* arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes
434434
* @image: a pointer to kexec_crash_image
435+
* @arg: struct memory_notify handler for memory hotplug case and
436+
* NULL for CPU hotplug case.
435437
*
436438
* Prepare the new elfcorehdr and replace the existing elfcorehdr.
437439
*/
438-
void arch_crash_handle_hotplug_event(struct kimage *image)
440+
void arch_crash_handle_hotplug_event(struct kimage *image, void *arg)
439441
{
440442
void *elfbuf = NULL, *old_elfcorehdr;
441443
unsigned long nr_mem_ranges;

include/linux/crash_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static inline void arch_kexec_unprotect_crashkres(void) { }
3737

3838

3939
#ifndef arch_crash_handle_hotplug_event
40-
static inline void arch_crash_handle_hotplug_event(struct kimage *image) { }
40+
static inline void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) { }
4141
#endif
4242

4343
int crash_check_update_elfcorehdr(void);

kernel/crash_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ int crash_check_update_elfcorehdr(void)
534534
* list of segments it checks (since the elfcorehdr changes and thus
535535
* would require an update to purgatory itself to update the digest).
536536
*/
537-
static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
537+
static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu, void *arg)
538538
{
539539
struct kimage *image;
540540

@@ -596,7 +596,7 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
596596
image->hp_action = hp_action;
597597

598598
/* Now invoke arch-specific update handler */
599-
arch_crash_handle_hotplug_event(image);
599+
arch_crash_handle_hotplug_event(image, arg);
600600

601601
/* No longer handling a hotplug event */
602602
image->hp_action = KEXEC_CRASH_HP_NONE;
@@ -612,17 +612,17 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
612612
crash_hotplug_unlock();
613613
}
614614

615-
static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v)
615+
static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *arg)
616616
{
617617
switch (val) {
618618
case MEM_ONLINE:
619619
crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY,
620-
KEXEC_CRASH_HP_INVALID_CPU);
620+
KEXEC_CRASH_HP_INVALID_CPU, arg);
621621
break;
622622

623623
case MEM_OFFLINE:
624624
crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY,
625-
KEXEC_CRASH_HP_INVALID_CPU);
625+
KEXEC_CRASH_HP_INVALID_CPU, arg);
626626
break;
627627
}
628628
return NOTIFY_OK;
@@ -635,13 +635,13 @@ static struct notifier_block crash_memhp_nb = {
635635

636636
static int crash_cpuhp_online(unsigned int cpu)
637637
{
638-
crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu);
638+
crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu, NULL);
639639
return 0;
640640
}
641641

642642
static int crash_cpuhp_offline(unsigned int cpu)
643643
{
644-
crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu);
644+
crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu, NULL);
645645
return 0;
646646
}
647647

0 commit comments

Comments
 (0)