aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-08-09 13:48:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-09 13:48:18 -0400
commita0cba2179ea4c1820fce2ee046b6ed90ecc56196 (patch)
treec98500be5e39c6c06d72eaec1ca46eb970f99ca3
parent84bd8d33a9604256ce0d86ca6d035295e874fa99 (diff)
Revert "printk: create pr_<level> functions"
This reverts commit 874f9c7da9a4acbc1b9e12ca722579fb50e4d142. Geert Uytterhoeven reports: "This change seems to have an (unintendent?) side-effect. Before, pr_*() calls without a trailing newline characters would be printed with a newline character appended, both on the console and in the output of the dmesg command. After this commit, no new line character is appended, and the output of the next pr_*() call of the same type may be appended, like in: - Truncating RAM at 0x0000000040000000-0x00000000c0000000 to -0x0000000070000000 - Ignoring RAM at 0x0000000200000000-0x0000000240000000 (!CONFIG_HIGHMEM) + Truncating RAM at 0x0000000040000000-0x00000000c0000000 to -0x0000000070000000Ignoring RAM at 0x0000000200000000-0x0000000240000000 (!CONFIG_HIGHMEM)" Joe Perches says: "No, that is not intentional. The newline handling code inside vprintk_emit is a bit involved and for now I suggest a revert until this has all the same behavior as earlier" Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Requested-by: Joe Perches <joe@perches.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/printk.h48
-rw-r--r--kernel/printk/internal.h16
-rw-r--r--kernel/printk/nmi.c13
-rw-r--r--kernel/printk/printk.c25
4 files changed, 26 insertions, 76 deletions
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 8dc155dab3ed..696a56be7d3e 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -266,39 +266,21 @@ extern asmlinkage void dump_stack(void) __cold;
266 * and other debug macros are compiled out unless either DEBUG is defined 266 * and other debug macros are compiled out unless either DEBUG is defined
267 * or CONFIG_DYNAMIC_DEBUG is set. 267 * or CONFIG_DYNAMIC_DEBUG is set.
268 */ 268 */
269 269#define pr_emerg(fmt, ...) \
270#ifdef CONFIG_PRINTK 270 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
271 271#define pr_alert(fmt, ...) \
272asmlinkage __printf(1, 2) __cold void __pr_emerg(const char *fmt, ...); 272 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
273asmlinkage __printf(1, 2) __cold void __pr_alert(const char *fmt, ...); 273#define pr_crit(fmt, ...) \
274asmlinkage __printf(1, 2) __cold void __pr_crit(const char *fmt, ...); 274 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
275asmlinkage __printf(1, 2) __cold void __pr_err(const char *fmt, ...); 275#define pr_err(fmt, ...) \
276asmlinkage __printf(1, 2) __cold void __pr_warn(const char *fmt, ...); 276 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
277asmlinkage __printf(1, 2) __cold void __pr_notice(const char *fmt, ...); 277#define pr_warning(fmt, ...) \
278asmlinkage __printf(1, 2) __cold void __pr_info(const char *fmt, ...); 278 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
279 279#define pr_warn pr_warning
280#define pr_emerg(fmt, ...) __pr_emerg(pr_fmt(fmt), ##__VA_ARGS__) 280#define pr_notice(fmt, ...) \
281#define pr_alert(fmt, ...) __pr_alert(pr_fmt(fmt), ##__VA_ARGS__) 281 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
282#define pr_crit(fmt, ...) __pr_crit(pr_fmt(fmt), ##__VA_ARGS__) 282#define pr_info(fmt, ...) \
283#define pr_err(fmt, ...) __pr_err(pr_fmt(fmt), ##__VA_ARGS__) 283 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
284#define pr_warn(fmt, ...) __pr_warn(pr_fmt(fmt), ##__VA_ARGS__)
285#define pr_notice(fmt, ...) __pr_notice(pr_fmt(fmt), ##__VA_ARGS__)
286#define pr_info(fmt, ...) __pr_info(pr_fmt(fmt), ##__VA_ARGS__)
287
288#else
289
290#define pr_emerg(fmt, ...) printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
291#define pr_alert(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
292#define pr_crit(fmt, ...) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
293#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
294#define pr_warn(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
295#define pr_notice(fmt, ...) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
296#define pr_info(fmt, ...) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
297
298#endif
299
300#define pr_warning pr_warn
301
302/* 284/*
303 * Like KERN_CONT, pr_cont() should only be used when continuing 285 * Like KERN_CONT, pr_cont() should only be used when continuing
304 * a line with no newline ('\n') enclosed. Otherwise it defaults 286 * a line with no newline ('\n') enclosed. Otherwise it defaults
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 5d4505f30083..7fd2838fa417 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -16,11 +16,9 @@
16 */ 16 */
17#include <linux/percpu.h> 17#include <linux/percpu.h>
18 18
19typedef __printf(2, 0) int (*printk_func_t)(int level, const char *fmt, 19typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
20 va_list args);
21 20
22__printf(2, 0) 21int __printf(1, 0) vprintk_default(const char *fmt, va_list args);
23int vprintk_default(int level, const char *fmt, va_list args);
24 22
25#ifdef CONFIG_PRINTK_NMI 23#ifdef CONFIG_PRINTK_NMI
26 24
@@ -33,10 +31,9 @@ extern raw_spinlock_t logbuf_lock;
33 * via per-CPU variable. 31 * via per-CPU variable.
34 */ 32 */
35DECLARE_PER_CPU(printk_func_t, printk_func); 33DECLARE_PER_CPU(printk_func_t, printk_func);
36__printf(2, 0) 34static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
37static inline int vprintk_func(int level, const char *fmt, va_list args)
38{ 35{
39 return this_cpu_read(printk_func)(level, fmt, args); 36 return this_cpu_read(printk_func)(fmt, args);
40} 37}
41 38
42extern atomic_t nmi_message_lost; 39extern atomic_t nmi_message_lost;
@@ -47,10 +44,9 @@ static inline int get_nmi_message_lost(void)
47 44
48#else /* CONFIG_PRINTK_NMI */ 45#else /* CONFIG_PRINTK_NMI */
49 46
50__printf(2, 0) 47static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
51static inline int vprintk_func(int level, const char *fmt, va_list args)
52{ 48{
53 return vprintk_default(level, fmt, args); 49 return vprintk_default(fmt, args);
54} 50}
55 51
56static inline int get_nmi_message_lost(void) 52static inline int get_nmi_message_lost(void)
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c
index bc3eeb1ae6da..b69eb8a2876f 100644
--- a/kernel/printk/nmi.c
+++ b/kernel/printk/nmi.c
@@ -58,7 +58,7 @@ static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq);
58 * one writer running. But the buffer might get flushed from another 58 * one writer running. But the buffer might get flushed from another
59 * CPU, so we need to be careful. 59 * CPU, so we need to be careful.
60 */ 60 */
61static int vprintk_nmi(int level, const char *fmt, va_list args) 61static int vprintk_nmi(const char *fmt, va_list args)
62{ 62{
63 struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq); 63 struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
64 int add = 0; 64 int add = 0;
@@ -79,16 +79,7 @@ again:
79 if (!len) 79 if (!len)
80 smp_rmb(); 80 smp_rmb();
81 81
82 if (level != LOGLEVEL_DEFAULT) { 82 add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
83 add = snprintf(s->buffer + len, sizeof(s->buffer) - len,
84 KERN_SOH "%c", '0' + level);
85 add += vsnprintf(s->buffer + len + add,
86 sizeof(s->buffer) - len - add,
87 fmt, args);
88 } else {
89 add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len,
90 fmt, args);
91 }
92 83
93 /* 84 /*
94 * Do it once again if the buffer has been flushed in the meantime. 85 * Do it once again if the buffer has been flushed in the meantime.
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index a37fc8cf8e84..eea6dbc2d8cf 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1930,26 +1930,7 @@ asmlinkage int printk_emit(int facility, int level,
1930} 1930}
1931EXPORT_SYMBOL(printk_emit); 1931EXPORT_SYMBOL(printk_emit);
1932 1932
1933#define define_pr_level(func, loglevel) \ 1933int vprintk_default(const char *fmt, va_list args)
1934asmlinkage __visible void func(const char *fmt, ...) \
1935{ \
1936 va_list args; \
1937 \
1938 va_start(args, fmt); \
1939 vprintk_default(loglevel, fmt, args); \
1940 va_end(args); \
1941} \
1942EXPORT_SYMBOL(func)
1943
1944define_pr_level(__pr_emerg, LOGLEVEL_EMERG);
1945define_pr_level(__pr_alert, LOGLEVEL_ALERT);
1946define_pr_level(__pr_crit, LOGLEVEL_CRIT);
1947define_pr_level(__pr_err, LOGLEVEL_ERR);
1948define_pr_level(__pr_warn, LOGLEVEL_WARNING);
1949define_pr_level(__pr_notice, LOGLEVEL_NOTICE);
1950define_pr_level(__pr_info, LOGLEVEL_INFO);
1951
1952int vprintk_default(int level, const char *fmt, va_list args)
1953{ 1934{
1954 int r; 1935 int r;
1955 1936
@@ -1959,7 +1940,7 @@ int vprintk_default(int level, const char *fmt, va_list args)
1959 return r; 1940 return r;
1960 } 1941 }
1961#endif 1942#endif
1962 r = vprintk_emit(0, level, NULL, 0, fmt, args); 1943 r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
1963 1944
1964 return r; 1945 return r;
1965} 1946}
@@ -1992,7 +1973,7 @@ asmlinkage __visible int printk(const char *fmt, ...)
1992 int r; 1973 int r;
1993 1974
1994 va_start(args, fmt); 1975 va_start(args, fmt);
1995 r = vprintk_func(LOGLEVEL_DEFAULT, fmt, args); 1976 r = vprintk_func(fmt, args);
1996 va_end(args); 1977 va_end(args);
1997 1978
1998 return r; 1979 return r;