* [PATCH v17 1/6] crash: forward memory_notify arg to arch crash hotplug handler
2024-02-26 8:41 [PATCH v17 0/6] powerpc/crash: Kernel handling of CPU and memory hotplug Sourabh Jain
@ 2024-02-26 8:41 ` Sourabh Jain
0 siblings, 0 replies; 2+ messages in thread
From: Sourabh Jain @ 2024-02-26 8:41 UTC (permalink / raw)
To: linuxppc-dev
Cc: Sourabh Jain, Baoquan He, Akhil Raj, Andrew Morton,
Aneesh Kumar K . V, Borislav Petkov, Boris Ostrovsky,
Christophe Leroy, Dave Hansen, Dave Young, David Hildenbrand,
Greg Kroah-Hartman, Hari Bathini, Laurent Dufour,
Mahesh Salgaonkar, Michael Ellerman, Mimi Zohar, Naveen N Rao,
Oscar Salvador, Thomas Gleixner, Valentin Schneider, Vivek Goyal,
kexec, x86
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 <sourabhjain@linux.ibm.com>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: Akhil Raj <lf32.dev@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Laurent Dufour <laurent.dufour@fr.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mimi Zohar <zohar@linux.ibm.com>
Cc: Naveen N Rao <naveen@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: kexec@lists.infradead.org
Cc: x86@kernel.org
---
arch/x86/include/asm/kexec.h | 2 +-
arch/x86/kernel/crash.c | 4 +++-
include/linux/crash_core.h | 2 +-
kernel/crash_core.c | 14 +++++++-------
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
index 91ca9a9ee3a2..cb1320ebbc23 100644
--- a/arch/x86/include/asm/kexec.h
+++ b/arch/x86/include/asm/kexec.h
@@ -207,7 +207,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image);
extern void kdump_nmi_shootdown_cpus(void);
#ifdef CONFIG_CRASH_HOTPLUG
-void arch_crash_handle_hotplug_event(struct kimage *image);
+void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index e74d0c4286c1..2a682fe86352 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -432,10 +432,12 @@ unsigned int arch_crash_get_elfcorehdr_size(void)
/**
* arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes
* @image: a pointer to kexec_crash_image
+ * @arg: struct memory_notify handler for memory hotplug case and
+ * NULL for CPU hotplug case.
*
* Prepare the new elfcorehdr and replace the existing elfcorehdr.
*/
-void arch_crash_handle_hotplug_event(struct kimage *image)
+void arch_crash_handle_hotplug_event(struct kimage *image, void *arg)
{
void *elfbuf = NULL, *old_elfcorehdr;
unsigned long nr_mem_ranges;
diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
index d33352c2e386..647e928efee8 100644
--- a/include/linux/crash_core.h
+++ b/include/linux/crash_core.h
@@ -37,7 +37,7 @@ static inline void arch_kexec_unprotect_crashkres(void) { }
#ifndef arch_crash_handle_hotplug_event
-static inline void arch_crash_handle_hotplug_event(struct kimage *image) { }
+static inline void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) { }
#endif
int crash_check_update_elfcorehdr(void);
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 78b5dc7cee3a..70fa8111a9d6 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -534,7 +534,7 @@ int crash_check_update_elfcorehdr(void)
* list of segments it checks (since the elfcorehdr changes and thus
* would require an update to purgatory itself to update the digest).
*/
-static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
+static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu, void *arg)
{
struct kimage *image;
@@ -596,7 +596,7 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
image->hp_action = hp_action;
/* Now invoke arch-specific update handler */
- arch_crash_handle_hotplug_event(image);
+ arch_crash_handle_hotplug_event(image, arg);
/* No longer handling a hotplug event */
image->hp_action = KEXEC_CRASH_HP_NONE;
@@ -612,17 +612,17 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
crash_hotplug_unlock();
}
-static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v)
+static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *arg)
{
switch (val) {
case MEM_ONLINE:
crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY,
- KEXEC_CRASH_HP_INVALID_CPU);
+ KEXEC_CRASH_HP_INVALID_CPU, arg);
break;
case MEM_OFFLINE:
crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY,
- KEXEC_CRASH_HP_INVALID_CPU);
+ KEXEC_CRASH_HP_INVALID_CPU, arg);
break;
}
return NOTIFY_OK;
@@ -635,13 +635,13 @@ static struct notifier_block crash_memhp_nb = {
static int crash_cpuhp_online(unsigned int cpu)
{
- crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu);
+ crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu, NULL);
return 0;
}
static int crash_cpuhp_offline(unsigned int cpu)
{
- crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu);
+ crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu, NULL);
return 0;
}
--
2.43.0
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v17 1/6] crash: forward memory_notify arg to arch crash hotplug handler
@ 2024-03-02 13:17 Hari Bathini
0 siblings, 0 replies; 2+ messages in thread
From: Hari Bathini @ 2024-03-02 13:17 UTC (permalink / raw)
To: Sourabh Jain, linuxppc-dev
Cc: Baoquan He, Akhil Raj, Andrew Morton, Aneesh Kumar K . V,
Borislav Petkov, Boris Ostrovsky, Christophe Leroy, Dave Hansen,
Dave Young, David Hildenbrand, Greg Kroah-Hartman, Laurent Dufour,
Mahesh Salgaonkar, Michael Ellerman, Mimi Zohar, Naveen N Rao,
Oscar Salvador, Thomas Gleixner, Valentin Schneider, Vivek Goyal,
kexec, x86
On 26/02/24 2:11 pm, Sourabh Jain wrote:
> 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.
>
Acked-by: Hari Bathini <hbathini@linux.ibm.com>
> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> Acked-by: Baoquan He <bhe@redhat.com>
> Cc: Akhil Raj <lf32.dev@gmail.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
> Cc: Borislav Petkov (AMD) <bp@alien8.de>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Hari Bathini <hbathini@linux.ibm.com>
> Cc: Laurent Dufour <laurent.dufour@fr.ibm.com>
> Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Mimi Zohar <zohar@linux.ibm.com>
> Cc: Naveen N Rao <naveen@kernel.org>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Valentin Schneider <vschneid@redhat.com>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> Cc: kexec@lists.infradead.org
> Cc: x86@kernel.org
> ---
> arch/x86/include/asm/kexec.h | 2 +-
> arch/x86/kernel/crash.c | 4 +++-
> include/linux/crash_core.h | 2 +-
> kernel/crash_core.c | 14 +++++++-------
> 4 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
> index 91ca9a9ee3a2..cb1320ebbc23 100644
> --- a/arch/x86/include/asm/kexec.h
> +++ b/arch/x86/include/asm/kexec.h
> @@ -207,7 +207,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image);
> extern void kdump_nmi_shootdown_cpus(void);
>
> #ifdef CONFIG_CRASH_HOTPLUG
> -void arch_crash_handle_hotplug_event(struct kimage *image);
> +void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
> #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
>
> #ifdef CONFIG_HOTPLUG_CPU
> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
> index e74d0c4286c1..2a682fe86352 100644
> --- a/arch/x86/kernel/crash.c
> +++ b/arch/x86/kernel/crash.c
> @@ -432,10 +432,12 @@ unsigned int arch_crash_get_elfcorehdr_size(void)
> /**
> * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes
> * @image: a pointer to kexec_crash_image
> + * @arg: struct memory_notify handler for memory hotplug case and
> + * NULL for CPU hotplug case.
> *
> * Prepare the new elfcorehdr and replace the existing elfcorehdr.
> */
> -void arch_crash_handle_hotplug_event(struct kimage *image)
> +void arch_crash_handle_hotplug_event(struct kimage *image, void *arg)
> {
> void *elfbuf = NULL, *old_elfcorehdr;
> unsigned long nr_mem_ranges;
> diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
> index d33352c2e386..647e928efee8 100644
> --- a/include/linux/crash_core.h
> +++ b/include/linux/crash_core.h
> @@ -37,7 +37,7 @@ static inline void arch_kexec_unprotect_crashkres(void) { }
>
>
> #ifndef arch_crash_handle_hotplug_event
> -static inline void arch_crash_handle_hotplug_event(struct kimage *image) { }
> +static inline void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) { }
> #endif
>
> int crash_check_update_elfcorehdr(void);
> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index 78b5dc7cee3a..70fa8111a9d6 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -534,7 +534,7 @@ int crash_check_update_elfcorehdr(void)
> * list of segments it checks (since the elfcorehdr changes and thus
> * would require an update to purgatory itself to update the digest).
> */
> -static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
> +static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu, void *arg)
> {
> struct kimage *image;
>
> @@ -596,7 +596,7 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
> image->hp_action = hp_action;
>
> /* Now invoke arch-specific update handler */
> - arch_crash_handle_hotplug_event(image);
> + arch_crash_handle_hotplug_event(image, arg);
>
> /* No longer handling a hotplug event */
> image->hp_action = KEXEC_CRASH_HP_NONE;
> @@ -612,17 +612,17 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu)
> crash_hotplug_unlock();
> }
>
> -static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v)
> +static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *arg)
> {
> switch (val) {
> case MEM_ONLINE:
> crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY,
> - KEXEC_CRASH_HP_INVALID_CPU);
> + KEXEC_CRASH_HP_INVALID_CPU, arg);
> break;
>
> case MEM_OFFLINE:
> crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY,
> - KEXEC_CRASH_HP_INVALID_CPU);
> + KEXEC_CRASH_HP_INVALID_CPU, arg);
> break;
> }
> return NOTIFY_OK;
> @@ -635,13 +635,13 @@ static struct notifier_block crash_memhp_nb = {
>
> static int crash_cpuhp_online(unsigned int cpu)
> {
> - crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu);
> + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu, NULL);
> return 0;
> }
>
> static int crash_cpuhp_offline(unsigned int cpu)
> {
> - crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu);
> + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu, NULL);
> return 0;
> }
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-02 13:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-02 13:17 [PATCH v17 1/6] crash: forward memory_notify arg to arch crash hotplug handler Hari Bathini
-- strict thread matches above, loose matches on Subject: below --
2024-02-26 8:41 [PATCH v17 0/6] powerpc/crash: Kernel handling of CPU and memory hotplug Sourabh Jain
2024-02-26 8:41 ` [PATCH v17 1/6] crash: forward memory_notify arg to arch crash hotplug handler Sourabh Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox