Skip to content

Commit 81c9d43

Browse files
ftang1torvalds
authored andcommitted
kernel/sysctl: add panic_print into sysctl
So that we can also runtime chose to print out the needed system info for panic, other than setting the kernel cmdline. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Feng Tang <[email protected]> Suggested-by: Steven Rostedt <[email protected]> Acked-by: Steven Rostedt (VMware) <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kees Cook <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d999bd9 commit 81c9d43

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

Documentation/sysctl/kernel.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ show up in /proc/sys/kernel:
6060
- panic_on_stackoverflow
6161
- panic_on_unrecovered_nmi
6262
- panic_on_warn
63+
- panic_print
6364
- panic_on_rcu_stall
6465
- perf_cpu_time_max_percent
6566
- perf_event_paranoid
@@ -654,6 +655,22 @@ a kernel rebuild when attempting to kdump at the location of a WARN().
654655

655656
==============================================================
656657

658+
panic_print:
659+
660+
Bitmask for printing system info when panic happens. User can chose
661+
combination of the following bits:
662+
663+
bit 0: print all tasks info
664+
bit 1: print system memory info
665+
bit 2: print timer info
666+
bit 3: print locks info if CONFIG_LOCKDEP is on
667+
bit 4: print ftrace buffer
668+
669+
So for example to print tasks and memory info on panic, user can:
670+
echo 3 > /proc/sys/kernel/panic_print
671+
672+
==============================================================
673+
657674
panic_on_rcu_stall:
658675

659676
When set to 1, calls panic() after RCU stall detection messages. This

include/linux/kernel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ static inline u32 int_sqrt64(u64 x)
527527
extern void bust_spinlocks(int yes);
528528
extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
529529
extern int panic_timeout;
530+
extern unsigned long panic_print;
530531
extern int panic_on_oops;
531532
extern int panic_on_unrecovered_nmi;
532533
extern int panic_on_io_nmi;

include/uapi/linux/sysctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ enum
153153
KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
154154
KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
155155
KERN_PANIC_ON_WARN=77, /* int: call panic() in WARN() functions */
156+
KERN_PANIC_PRINT=78, /* ulong: bitmask to print system info on panic */
156157
};
157158

158159

kernel/panic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(panic_timeout);
5151
#define PANIC_PRINT_TIMER_INFO 0x00000004
5252
#define PANIC_PRINT_LOCK_INFO 0x00000008
5353
#define PANIC_PRINT_FTRACE_INFO 0x00000010
54-
static unsigned long panic_print;
54+
unsigned long panic_print;
5555

5656
ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
5757

kernel/sysctl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,13 @@ static struct ctl_table kern_table[] = {
807807
.mode = 0644,
808808
.proc_handler = proc_dointvec,
809809
},
810+
{
811+
.procname = "panic_print",
812+
.data = &panic_print,
813+
.maxlen = sizeof(unsigned long),
814+
.mode = 0644,
815+
.proc_handler = proc_doulongvec_minmax,
816+
},
810817
#if defined CONFIG_PRINTK
811818
{
812819
.procname = "printk",

kernel/sysctl_binary.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ static const struct bin_table bin_kern_table[] = {
140140
{ CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
141141
{ CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
142142
{ CTL_INT, KERN_PANIC_ON_WARN, "panic_on_warn" },
143+
{ CTL_ULONG, KERN_PANIC_PRINT, "panic_print" },
143144
{}
144145
};
145146

0 commit comments

Comments
 (0)