Re: [PATCH v2 3/6] panic: Allow postponing pre-kdump notifiers
From: Petr Mladek
Date: Tue Oct 20 2026 - 08:35:13 EST
On Mon 2026-09-28 13:55:37, Zack Rusin wrote:
> Provide an escape hatch for debugging kdump failures that may involve
> pre-kdump callbacks. Add panic_pre_kdump_postpone to skip their early
> invocation in crash core without consuming the once-only guard.
>
> When enabled, the chain runs before kdump only when
> crash_kexec_post_notifiers is also enabled. Leave the late panic call
> unchanged so callbacks remain eligible if that path is reached.
> Skipping the callbacks may prevent hypervisor crash handling.
>
> Suggested-by: Guilherme G. Piccoli <gpiccoli@xxxxxxxxxx>
> Link: https://lore.kernel.org/r/bc0bdd14-5e6a-0676-cd04-14fb0bb93cd5@xxxxxxxxxx
> Signed-off-by: Zack Rusin <zack.rusin@xxxxxxxxxxxx>
> ---
> New in v2: optional postponement policy suggested by Guilherme.
>
> Documentation/admin-guide/kernel-parameters.txt | 14 ++++++++++++++
> include/linux/panic_notifier.h | 1 +
> kernel/crash_core.c | 3 ++-
> kernel/panic.c | 2 ++
> 4 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 33cd30996e47..3d722df30838 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -4904,6 +4904,20 @@ Kernel parameters
> This option should only be used for systems with the above
> constraints as it might cause the panic operation to be less reliable.
>
> + panic_pre_kdump_postpone=
> + [KNL] Defer pre-kdump notifiers to the late panic path.
> + They run before kdump only when
> + crash_kexec_post_notifiers is also enabled. If panic
> + reaches the late path without entering kdump, they
> + can still run there.
> + Intended for debugging kexec/crash-dump failures.
> + Skipping these callbacks may prevent correct crash
> + handling by the hypervisor.
> + Format: <bool>
> + Default: 0
> + Writable at runtime via
> + /sys/module/kernel/parameters/panic_pre_kdump_postpone.
> +
> panic_print= Bitmask for printing system info when panic happens.
> User can chose combination of the following bits:
>
> diff --git a/include/linux/panic_notifier.h b/include/linux/panic_notifier.h
> index 3ad390764a41..655ee5c77181 100644
> --- a/include/linux/panic_notifier.h
> +++ b/include/linux/panic_notifier.h
> @@ -11,5 +11,6 @@ extern struct atomic_notifier_head panic_pre_kdump_list;
> void panic_notify_pre_kdump(char *msg);
>
> extern bool crash_kexec_post_notifiers;
> +extern bool panic_pre_kdump_postpone;
>
> #endif /* _LINUX_PANIC_NOTIFIERS_H */
> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index 5d9fe9e00f39..d6b2293dd0fe 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -140,7 +140,8 @@ void __noclone __crash_kexec(struct pt_regs *regs)
> struct pt_regs fixed_regs;
>
> crash_setup_regs(&fixed_regs, regs);
> - panic_notify_pre_kdump(NULL);
> + if (!READ_ONCE(panic_pre_kdump_postpone))
> + panic_notify_pre_kdump(NULL);
Honestly, it looks a bit confusing to me.
The name "postpone" suggests that they will be called later.
But they likely will never be called because the crash kernel
will take over the control and eventually reboot the system.
The panic() path will never run.
Also there is:
void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
{
if (regs && kexec_should_crash(current))
crash_kexec(regs);
where
int kexec_should_crash(struct task_struct *p)
{
/*
* If crash_kexec_post_notifiers is enabled, don't run
* crash_kexec() here yet, which must be run after panic
* notifiers in panic().
*/
if (crash_kexec_post_notifiers)
return 0;
So, when: "crash_kexec_post_notifiers == true" then
kexec_should_crash() returns "0" then
crash_exec() is not called. The system might still
call panic() but remember "crash_kexec_post_notifiers == true"
so the notifiers are called before __crash_kexec().
So panic_notify_pre_kdump() will still get called
before __crash_exec().
Is this intended, please?
What is use case, please?
Maybe, it would make sense to add "panic_pre_kdump_disable"
which would completely disable the notifiers when they cause
problems.
Best Regards,
Petr