diff options
author | Dave Young <dyoung@redhat.com> | 2018-02-13 02:28:34 -0500 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2018-03-15 08:25:36 -0400 |
commit | e36df28f532f882965404d58e240f2e058b61f45 (patch) | |
tree | 1fed8801f8f82a7a53e2c7005c03de8095f255bd /lib | |
parent | 097114aa6eb2aa206c8cf136de77ebffe424234c (diff) |
printk: move dump stack related code to lib/dump_stack.c
dump_stack related stuff should belong to lib/dump_stack.c thus move them
there. Also conditionally compile lib/dump_stack.c since dump_stack code
does not make sense if printk is disabled.
Link: http://lkml.kernel.org/r/20180213072834.GA24784@dhcp-128-65.nay.redhat.com
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org
Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Dave Young <dyoung@redhat.com>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Suggested-by: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile | 3 | ||||
-rw-r--r-- | lib/dump_stack.c | 60 |
2 files changed, 62 insertions, 1 deletions
diff --git a/lib/Makefile b/lib/Makefile index 7adb066692b3..6ae3bd481379 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -18,7 +18,7 @@ KCOV_INSTRUMENT_debugobjects.o := n | |||
18 | KCOV_INSTRUMENT_dynamic_debug.o := n | 18 | KCOV_INSTRUMENT_dynamic_debug.o := n |
19 | 19 | ||
20 | lib-y := ctype.o string.o vsprintf.o cmdline.o \ | 20 | lib-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 | ||
29 | lib-$(CONFIG_PRINTK) += dump_stack.o | ||
29 | lib-$(CONFIG_MMU) += ioremap.o | 30 | lib-$(CONFIG_MMU) += ioremap.o |
30 | lib-$(CONFIG_SMP) += cpumask.o | 31 | lib-$(CONFIG_SMP) += cpumask.o |
31 | lib-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o | 32 | lib-$(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 | |||
16 | static 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 | */ | ||
28 | void __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 | */ | ||
45 | void 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 | */ | ||
69 | void show_regs_print_info(const char *log_lvl) | ||
70 | { | ||
71 | dump_stack_print_info(log_lvl); | ||
72 | } | ||
13 | 73 | ||
14 | static void __dump_stack(void) | 74 | static void __dump_stack(void) |
15 | { | 75 | { |