]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
panic: add note that panic_print sysctl interface is deprecated
authorFeng Tang <feng.tang@linux.alibaba.com>
Thu, 3 Jul 2025 02:10:04 +0000 (10:10 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 20 Jul 2025 02:08:25 +0000 (19:08 -0700)
Add a dedicated core parameter 'panic_console_replay' for controlling
console replay, and add note that 'panic_print' sysctl interface will be
obsoleted by 'panic_sys_info' and 'panic_console_replay'.  When it
happens, the SYS_INFO_PANIC_CONSOLE_REPLAY can be removed as well.

Link: https://lkml.kernel.org/r/20250703021004.42328-6-feng.tang@linux.alibaba.com
Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
Suggested-by: Petr Mladek <pmladek@suse.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: "Paul E . McKenney" <paulmck@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/admin-guide/kernel-parameters.txt
kernel/panic.c

index 55a887d6309c9897fd78f20c62785f88d309798d..3d1e55ed438289b4101c9496febe35df61506fc2 100644 (file)
 
                         This is a human readable alternative to the 'panic_print' option.
 
+       panic_console_replay
+                       When panic happens, replay all kernel messages on
+                       consoles at the end of panic.
+
        parkbd.port=    [HW] Parallel port number the keyboard adapter is
                        connected to, default is 0.
                        Format: <parport#>
index d9d4fcd5e3184f1b912eba6c9b888f752a78eeee..bb16f254cd023015d5fc9cd6a4f13ec058e57c9d 100644 (file)
@@ -64,6 +64,7 @@ int panic_on_warn __read_mostly;
 unsigned long panic_on_taint;
 bool panic_on_taint_nousertaint = false;
 static unsigned int warn_limit __read_mostly;
+static bool panic_console_replay;
 
 bool panic_triggering_all_cpu_backtrace;
 
@@ -77,6 +78,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
 EXPORT_SYMBOL(panic_notifier_list);
 
 #ifdef CONFIG_SYSCTL
+static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
+                          void *buffer, size_t *lenp, loff_t *ppos)
+{
+       pr_info_once("Kernel: 'panic_print' sysctl interface will be obsoleted by both 'panic_sys_info' and 'panic_console_replay'\n");
+       return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
+}
+
 static const struct ctl_table kern_panic_table[] = {
 #ifdef CONFIG_SMP
        {
@@ -108,7 +116,7 @@ static const struct ctl_table kern_panic_table[] = {
                .data           = &panic_print,
                .maxlen         = sizeof(unsigned long),
                .mode           = 0644,
-               .proc_handler   = proc_doulongvec_minmax,
+               .proc_handler   = sysctl_panic_print_handler,
        },
        {
                .procname       = "panic_on_warn",
@@ -247,12 +255,6 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
 }
 EXPORT_SYMBOL(nmi_panic);
 
-static void panic_console_replay(void)
-{
-       if (panic_print & SYS_INFO_PANIC_CONSOLE_REPLAY)
-               console_flush_on_panic(CONSOLE_REPLAY_ALL);
-}
-
 void check_panic_on_warn(const char *origin)
 {
        unsigned int limit;
@@ -427,7 +429,9 @@ void panic(const char *fmt, ...)
        debug_locks_off();
        console_flush_on_panic(CONSOLE_FLUSH_PENDING);
 
-       panic_console_replay();
+       if ((panic_print & SYS_INFO_PANIC_CONSOLE_REPLAY) ||
+               panic_console_replay)
+               console_flush_on_panic(CONSOLE_REPLAY_ALL);
 
        if (!panic_blink)
                panic_blink = no_blink;
@@ -869,6 +873,7 @@ core_param(panic_print, panic_print, ulong, 0644);
 core_param(pause_on_oops, pause_on_oops, int, 0644);
 core_param(panic_on_warn, panic_on_warn, int, 0644);
 core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
+core_param(panic_console_replay, panic_console_replay, bool, 0644);
 
 static int __init oops_setup(char *s)
 {