kernel/sysctl: add panic_print into sysctl
authorFeng Tang <feng.tang@intel.com>
Thu, 3 Jan 2019 23:28:20 +0000 (15:28 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Jan 2019 21:13:47 +0000 (13:13 -0800)
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/1543398842-19295-3-git-send-email-feng.tang@intel.com
Signed-off-by: Feng Tang <feng.tang@intel.com>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Documentation/sysctl/kernel.txt
include/linux/kernel.h
include/uapi/linux/sysctl.h
kernel/panic.c
kernel/sysctl.c
kernel/sysctl_binary.c

index 1b8775298cf7a0223c04aa7098cf1d1e4d24fefd..c0527d8a468a1dbcd401270c3127d3998b4f2c05 100644 (file)
@@ -60,6 +60,7 @@ show up in /proc/sys/kernel:
 - panic_on_stackoverflow
 - panic_on_unrecovered_nmi
 - panic_on_warn
+- panic_print
 - panic_on_rcu_stall
 - perf_cpu_time_max_percent
 - perf_event_paranoid
@@ -654,6 +655,22 @@ a kernel rebuild when attempting to kdump at the location of a WARN().
 
 ==============================================================
 
+panic_print:
+
+Bitmask for printing system info when panic happens. User can chose
+combination of the following bits:
+
+bit 0: print all tasks info
+bit 1: print system memory info
+bit 2: print timer info
+bit 3: print locks info if CONFIG_LOCKDEP is on
+bit 4: print ftrace buffer
+
+So for example to print tasks and memory info on panic, user can:
+  echo 3 > /proc/sys/kernel/panic_print
+
+==============================================================
+
 panic_on_rcu_stall:
 
 When set to 1, calls panic() after RCU stall detection messages. This
index d6aac75b51baab469d05ad6ca816b46bcd590906..8f0e68e250a760abbc2dc134c7c3b76760a2c764 100644 (file)
@@ -527,6 +527,7 @@ static inline u32 int_sqrt64(u64 x)
 extern void bust_spinlocks(int yes);
 extern int oops_in_progress;           /* If set, an oops, panic(), BUG() or die() is in progress */
 extern int panic_timeout;
+extern unsigned long panic_print;
 extern int panic_on_oops;
 extern int panic_on_unrecovered_nmi;
 extern int panic_on_io_nmi;
index d71013fffaf65b520420a4d04d2347f450c2f598..87aa2a6d91256654cacc38c98658ff908ab4e86c 100644 (file)
@@ -153,6 +153,7 @@ enum
        KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
        KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
        KERN_PANIC_ON_WARN=77, /* int: call panic() in WARN() functions */
+       KERN_PANIC_PRINT=78, /* ulong: bitmask to print system info on panic */
 };
 
 
index 855f66738bc7b1bf2cf2d7a6e46320cec48767b6..f121e6ba7e114e10e7e11ac3fa1cd24ab8fef0c1 100644 (file)
@@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(panic_timeout);
 #define PANIC_PRINT_TIMER_INFO         0x00000004
 #define PANIC_PRINT_LOCK_INFO          0x00000008
 #define PANIC_PRINT_FTRACE_INFO                0x00000010
-static unsigned long panic_print;
+unsigned long panic_print;
 
 ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
 
index 7f6c1a3b3485f17029c8a239e64eefc46fdb2852..ba4d9e85feb8ca69fb533049ab8a3a4a556bec9d 100644 (file)
@@ -807,6 +807,13 @@ static struct ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
        },
+       {
+               .procname       = "panic_print",
+               .data           = &panic_print,
+               .maxlen         = sizeof(unsigned long),
+               .mode           = 0644,
+               .proc_handler   = proc_doulongvec_minmax,
+       },
 #if defined CONFIG_PRINTK
        {
                .procname       = "printk",
index 07148b4974516cec45b934e5ed5881e1554e7af0..73c132095a7bd4330813eb741c2f9630086e6c8f 100644 (file)
@@ -140,6 +140,7 @@ static const struct bin_table bin_kern_table[] = {
        { CTL_INT,      KERN_MAX_LOCK_DEPTH,            "max_lock_depth" },
        { CTL_INT,      KERN_PANIC_ON_NMI,              "panic_on_unrecovered_nmi" },
        { CTL_INT,      KERN_PANIC_ON_WARN,             "panic_on_warn" },
+       { CTL_ULONG,    KERN_PANIC_PRINT,               "panic_print" },
        {}
 };