aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-05 22:53:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-05 22:53:30 -0400
commit357aa6aefebe888c712152cb83c9e700f98eebd1 (patch)
tree5adac02fbfd232e8df56563c3ab2facde669ba9c
parentbe88751f320a716a4327596adfe834e162c14532 (diff)
parent47319f7186b8746521b0ee674054b29d7b35578b (diff)
Merge branch 'for-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk
Pull printk updates from Petr Mladek: - Add info about loaded kdump kernel into the dump stack header - Move dump-stack related code from printk.c to lib/dump_stack.c - Write message about suspending consoles in KERN_INFO log level * 'for-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk: printk: change message to pr_info printk: move dump stack related code to lib/dump_stack.c print kdump kernel loaded status in stack dump
-rw-r--r--include/linux/printk.h7
-rw-r--r--kernel/printk/printk.c59
-rw-r--r--lib/Makefile3
-rw-r--r--lib/dump_stack.c60
4 files changed, 68 insertions, 61 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h
index e9b603ee9953..6d7e800affd8 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -201,6 +201,7 @@ void __init setup_log_buf(int early);
201__printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...); 201__printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
202void dump_stack_print_info(const char *log_lvl); 202void dump_stack_print_info(const char *log_lvl);
203void show_regs_print_info(const char *log_lvl); 203void show_regs_print_info(const char *log_lvl);
204extern asmlinkage void dump_stack(void) __cold;
204extern void printk_safe_init(void); 205extern void printk_safe_init(void);
205extern void printk_safe_flush(void); 206extern void printk_safe_flush(void);
206extern void printk_safe_flush_on_panic(void); 207extern void printk_safe_flush_on_panic(void);
@@ -264,6 +265,10 @@ static inline void show_regs_print_info(const char *log_lvl)
264{ 265{
265} 266}
266 267
268static inline asmlinkage void dump_stack(void)
269{
270}
271
267static inline void printk_safe_init(void) 272static inline void printk_safe_init(void)
268{ 273{
269} 274}
@@ -279,8 +284,6 @@ static inline void printk_safe_flush_on_panic(void)
279 284
280extern int kptr_restrict; 285extern int kptr_restrict;
281 286
282extern asmlinkage void dump_stack(void) __cold;
283
284#ifndef pr_fmt 287#ifndef pr_fmt
285#define pr_fmt(fmt) fmt 288#define pr_fmt(fmt) fmt
286#endif 289#endif
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f274fbef821d..704e55129c3a 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -42,7 +42,6 @@
42#include <linux/rculist.h> 42#include <linux/rculist.h>
43#include <linux/poll.h> 43#include <linux/poll.h>
44#include <linux/irq_work.h> 44#include <linux/irq_work.h>
45#include <linux/utsname.h>
46#include <linux/ctype.h> 45#include <linux/ctype.h>
47#include <linux/uio.h> 46#include <linux/uio.h>
48#include <linux/sched/clock.h> 47#include <linux/sched/clock.h>
@@ -2162,7 +2161,7 @@ void suspend_console(void)
2162{ 2161{
2163 if (!console_suspend_enabled) 2162 if (!console_suspend_enabled)
2164 return; 2163 return;
2165 printk("Suspending console(s) (use no_console_suspend to debug)\n"); 2164 pr_info("Suspending console(s) (use no_console_suspend to debug)\n");
2166 console_lock(); 2165 console_lock();
2167 console_suspended = 1; 2166 console_suspended = 1;
2168 up_console_sem(); 2167 up_console_sem();
@@ -3257,60 +3256,4 @@ void kmsg_dump_rewind(struct kmsg_dumper *dumper)
3257} 3256}
3258EXPORT_SYMBOL_GPL(kmsg_dump_rewind); 3257EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
3259 3258
3260static char dump_stack_arch_desc_str[128];
3261
3262/**
3263 * dump_stack_set_arch_desc - set arch-specific str to show with task dumps
3264 * @fmt: printf-style format string
3265 * @...: arguments for the format string
3266 *
3267 * The configured string will be printed right after utsname during task
3268 * dumps. Usually used to add arch-specific system identifiers. If an
3269 * arch wants to make use of such an ID string, it should initialize this
3270 * as soon as possible during boot.
3271 */
3272void __init dump_stack_set_arch_desc(const char *fmt, ...)
3273{
3274 va_list args;
3275
3276 va_start(args, fmt);
3277 vsnprintf(dump_stack_arch_desc_str, sizeof(dump_stack_arch_desc_str),
3278 fmt, args);
3279 va_end(args);
3280}
3281
3282/**
3283 * dump_stack_print_info - print generic debug info for dump_stack()
3284 * @log_lvl: log level
3285 *
3286 * Arch-specific dump_stack() implementations can use this function to
3287 * print out the same debug information as the generic dump_stack().
3288 */
3289void dump_stack_print_info(const char *log_lvl)
3290{
3291 printk("%sCPU: %d PID: %d Comm: %.20s %s %s %.*s\n",
3292 log_lvl, raw_smp_processor_id(), current->pid, current->comm,
3293 print_tainted(), init_utsname()->release,
3294 (int)strcspn(init_utsname()->version, " "),
3295 init_utsname()->version);
3296
3297 if (dump_stack_arch_desc_str[0] != '\0')
3298 printk("%sHardware name: %s\n",
3299 log_lvl, dump_stack_arch_desc_str);
3300
3301 print_worker_info(log_lvl, current);
3302}
3303
3304/**
3305 * show_regs_print_info - print generic debug info for show_regs()
3306 * @log_lvl: log level
3307 *
3308 * show_regs() implementations can use this function to print out generic
3309 * debug information.
3310 */
3311void show_regs_print_info(const char *log_lvl)
3312{
3313 dump_stack_print_info(log_lvl);
3314}
3315
3316#endif 3259#endif
diff --git a/lib/Makefile b/lib/Makefile
index a90d4fcd748f..0bd50d71f423 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -18,7 +18,7 @@ KCOV_INSTRUMENT_debugobjects.o := n
18KCOV_INSTRUMENT_dynamic_debug.o := n 18KCOV_INSTRUMENT_dynamic_debug.o := n
19 19
20lib-y := ctype.o string.o vsprintf.o cmdline.o \ 20lib-y := ctype.o string.o vsprintf.o cmdline.o \
21 rbtree.o radix-tree.o dump_stack.o timerqueue.o\ 21 rbtree.o radix-tree.o timerqueue.o\
22 idr.o int_sqrt.o extable.o \ 22 idr.o int_sqrt.o extable.o \
23 sha1.o chacha20.o irq_regs.o argv_split.o \ 23 sha1.o chacha20.o irq_regs.o argv_split.o \
24 flex_proportions.o ratelimit.o show_mem.o \ 24 flex_proportions.o ratelimit.o show_mem.o \
@@ -26,6 +26,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
26 earlycpio.o seq_buf.o siphash.o \ 26 earlycpio.o seq_buf.o siphash.o \
27 nmi_backtrace.o nodemask.o win_minmax.o 27 nmi_backtrace.o nodemask.o win_minmax.o
28 28
29lib-$(CONFIG_PRINTK) += dump_stack.o
29lib-$(CONFIG_MMU) += ioremap.o 30lib-$(CONFIG_MMU) += ioremap.o
30lib-$(CONFIG_SMP) += cpumask.o 31lib-$(CONFIG_SMP) += cpumask.o
31lib-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o 32lib-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o
diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index c5edbedd364d..5cff72f18c4a 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -10,6 +10,66 @@
10#include <linux/sched/debug.h> 10#include <linux/sched/debug.h>
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <linux/atomic.h> 12#include <linux/atomic.h>
13#include <linux/kexec.h>
14#include <linux/utsname.h>
15
16static char dump_stack_arch_desc_str[128];
17
18/**
19 * dump_stack_set_arch_desc - set arch-specific str to show with task dumps
20 * @fmt: printf-style format string
21 * @...: arguments for the format string
22 *
23 * The configured string will be printed right after utsname during task
24 * dumps. Usually used to add arch-specific system identifiers. If an
25 * arch wants to make use of such an ID string, it should initialize this
26 * as soon as possible during boot.
27 */
28void __init dump_stack_set_arch_desc(const char *fmt, ...)
29{
30 va_list args;
31
32 va_start(args, fmt);
33 vsnprintf(dump_stack_arch_desc_str, sizeof(dump_stack_arch_desc_str),
34 fmt, args);
35 va_end(args);
36}
37
38/**
39 * dump_stack_print_info - print generic debug info for dump_stack()
40 * @log_lvl: log level
41 *
42 * Arch-specific dump_stack() implementations can use this function to
43 * print out the same debug information as the generic dump_stack().
44 */
45void dump_stack_print_info(const char *log_lvl)
46{
47 printk("%sCPU: %d PID: %d Comm: %.20s %s%s %s %.*s\n",
48 log_lvl, raw_smp_processor_id(), current->pid, current->comm,
49 kexec_crash_loaded() ? "Kdump: loaded " : "",
50 print_tainted(),
51 init_utsname()->release,
52 (int)strcspn(init_utsname()->version, " "),
53 init_utsname()->version);
54
55 if (dump_stack_arch_desc_str[0] != '\0')
56 printk("%sHardware name: %s\n",
57 log_lvl, dump_stack_arch_desc_str);
58
59 print_worker_info(log_lvl, current);
60}
61
62/**
63 * show_regs_print_info - print generic debug info for show_regs()
64 * @log_lvl: log level
65 *
66 * show_regs() implementations can use this function to print out generic
67 * debug information.
68 */
69void show_regs_print_info(const char *log_lvl)
70{
71 dump_stack_print_info(log_lvl);
72}
13 73
14static void __dump_stack(void) 74static void __dump_stack(void)
15{ 75{