Skip to content

Commit ee13240

Browse files
Feng Tangakpm00
authored andcommitted
panic: add note that panic_print sysctl interface is deprecated
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/[email protected] Signed-off-by: Feng Tang <[email protected]> Suggested-by: Petr Mladek <[email protected]> Cc: John Ogness <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Lance Yang <[email protected]> Cc: "Paul E . McKenney" <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Nathan Chancellor <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 9743d12 commit ee13240

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4578,6 +4578,10 @@
45784578

45794579
This is a human readable alternative to the 'panic_print' option.
45804580

4581+
panic_console_replay
4582+
When panic happens, replay all kernel messages on
4583+
consoles at the end of panic.
4584+
45814585
parkbd.port= [HW] Parallel port number the keyboard adapter is
45824586
connected to, default is 0.
45834587
Format: <parport#>

kernel/panic.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ int panic_on_warn __read_mostly;
6464
unsigned long panic_on_taint;
6565
bool panic_on_taint_nousertaint = false;
6666
static unsigned int warn_limit __read_mostly;
67+
static bool panic_console_replay;
6768

6869
bool panic_triggering_all_cpu_backtrace;
6970

@@ -77,6 +78,13 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
7778
EXPORT_SYMBOL(panic_notifier_list);
7879

7980
#ifdef CONFIG_SYSCTL
81+
static int sysctl_panic_print_handler(const struct ctl_table *table, int write,
82+
void *buffer, size_t *lenp, loff_t *ppos)
83+
{
84+
pr_info_once("Kernel: 'panic_print' sysctl interface will be obsoleted by both 'panic_sys_info' and 'panic_console_replay'\n");
85+
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
86+
}
87+
8088
static const struct ctl_table kern_panic_table[] = {
8189
#ifdef CONFIG_SMP
8290
{
@@ -108,7 +116,7 @@ static const struct ctl_table kern_panic_table[] = {
108116
.data = &panic_print,
109117
.maxlen = sizeof(unsigned long),
110118
.mode = 0644,
111-
.proc_handler = proc_doulongvec_minmax,
119+
.proc_handler = sysctl_panic_print_handler,
112120
},
113121
{
114122
.procname = "panic_on_warn",
@@ -247,12 +255,6 @@ void nmi_panic(struct pt_regs *regs, const char *msg)
247255
}
248256
EXPORT_SYMBOL(nmi_panic);
249257

250-
static void panic_console_replay(void)
251-
{
252-
if (panic_print & SYS_INFO_PANIC_CONSOLE_REPLAY)
253-
console_flush_on_panic(CONSOLE_REPLAY_ALL);
254-
}
255-
256258
void check_panic_on_warn(const char *origin)
257259
{
258260
unsigned int limit;
@@ -427,7 +429,9 @@ void panic(const char *fmt, ...)
427429
debug_locks_off();
428430
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
429431

430-
panic_console_replay();
432+
if ((panic_print & SYS_INFO_PANIC_CONSOLE_REPLAY) ||
433+
panic_console_replay)
434+
console_flush_on_panic(CONSOLE_REPLAY_ALL);
431435

432436
if (!panic_blink)
433437
panic_blink = no_blink;
@@ -869,6 +873,7 @@ core_param(panic_print, panic_print, ulong, 0644);
869873
core_param(pause_on_oops, pause_on_oops, int, 0644);
870874
core_param(panic_on_warn, panic_on_warn, int, 0644);
871875
core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
876+
core_param(panic_console_replay, panic_console_replay, bool, 0644);
872877

873878
static int __init oops_setup(char *s)
874879
{

0 commit comments

Comments
 (0)