Skip to content

Commit 357aa6a

Browse files
committed
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
2 parents be88751 + 47319f7 commit 357aa6a

File tree

4 files changed

+68
-61
lines changed

4 files changed

+68
-61
lines changed

include/linux/printk.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ void __init setup_log_buf(int early);
201201
__printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);
202202
void dump_stack_print_info(const char *log_lvl);
203203
void show_regs_print_info(const char *log_lvl);
204+
extern asmlinkage void dump_stack(void) __cold;
204205
extern void printk_safe_init(void);
205206
extern void printk_safe_flush(void);
206207
extern void printk_safe_flush_on_panic(void);
@@ -264,6 +265,10 @@ static inline void show_regs_print_info(const char *log_lvl)
264265
{
265266
}
266267

268+
static inline asmlinkage void dump_stack(void)
269+
{
270+
}
271+
267272
static inline void printk_safe_init(void)
268273
{
269274
}
@@ -279,8 +284,6 @@ static inline void printk_safe_flush_on_panic(void)
279284

280285
extern int kptr_restrict;
281286

282-
extern asmlinkage void dump_stack(void) __cold;
283-
284287
#ifndef pr_fmt
285288
#define pr_fmt(fmt) fmt
286289
#endif

kernel/printk/printk.c

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include <linux/rculist.h>
4343
#include <linux/poll.h>
4444
#include <linux/irq_work.h>
45-
#include <linux/utsname.h>
4645
#include <linux/ctype.h>
4746
#include <linux/uio.h>
4847
#include <linux/sched/clock.h>
@@ -2162,7 +2161,7 @@ void suspend_console(void)
21622161
{
21632162
if (!console_suspend_enabled)
21642163
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");
21662165
console_lock();
21672166
console_suspended = 1;
21682167
up_console_sem();
@@ -3257,60 +3256,4 @@ void kmsg_dump_rewind(struct kmsg_dumper *dumper)
32573256
}
32583257
EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
32593258

3260-
static 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-
*/
3272-
void __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-
*/
3289-
void 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-
*/
3311-
void show_regs_print_info(const char *log_lvl)
3312-
{
3313-
dump_stack_print_info(log_lvl);
3314-
}
3315-
33163259
#endif

lib/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ KCOV_INSTRUMENT_debugobjects.o := n
1818
KCOV_INSTRUMENT_dynamic_debug.o := n
1919

2020
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\
2222
idr.o int_sqrt.o extable.o \
2323
sha1.o chacha20.o irq_regs.o argv_split.o \
2424
flex_proportions.o ratelimit.o show_mem.o \
2525
is_single_threaded.o plist.o decompress.o kobject_uevent.o \
2626
earlycpio.o seq_buf.o siphash.o \
2727
nmi_backtrace.o nodemask.o win_minmax.o
2828

29+
lib-$(CONFIG_PRINTK) += dump_stack.o
2930
lib-$(CONFIG_MMU) += ioremap.o
3031
lib-$(CONFIG_SMP) += cpumask.o
3132
lib-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o

lib/dump_stack.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,66 @@
1010
#include <linux/sched/debug.h>
1111
#include <linux/smp.h>
1212
#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+
}
1373

1474
static void __dump_stack(void)
1575
{

0 commit comments

Comments
 (0)