All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] printk: Create pr_<level> functions
@ 2016-06-23 21:58 Joe Perches
  2016-06-24  3:46 ` [PATCH V3] " Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2016-06-23 21:58 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

Using functions instead of macros can reduce overall code size
by eliminating unnecessary "KERN_SOH<digit>" prefixes from
format strings.

defconfig x86-64:

$ size vmlinux*
   text    data     bss      dec     hex  filename
10193570 4331464 1105920 15630954  ee826a vmlinux.new
10192623 4335560 1105920 15634103  ee8eb7 vmlinux.old

As the return value are unimportant and unused in the kernel tree,
these new functions return void.

Miscellanea:

o change pr_<level> macros to call new __pr_<level> functions
o change vprintk_nmi and vprintk_default to add LOGLEVEL_<level> argument

Signed-off-by: Joe Perches <joe@perches.com>
---
changes in V2:

Fix "CONFIG_PRINTK is not set" builds by adding CONFIG_PRINTK blocks
Fix x86-32 builds by setting __pr_<level> functions __asmlinkage and visible

Compile tested cross-compiled sparc, tinyconfig, x86-32 & -64 w/&w/o printk

 include/linux/printk.h   | 48 +++++++++++++++++++++++++++++++++---------------
 kernel/printk/internal.h | 16 ++++++++++------
 kernel/printk/nmi.c      | 13 +++++++++++--
 kernel/printk/printk.c   | 27 ++++++++++++++++++++++++---
 4 files changed, 78 insertions(+), 26 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index f4da695..e6ff22e 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -254,21 +254,39 @@ extern asmlinkage void dump_stack(void) __cold;
  * and other debug macros are compiled out unless either DEBUG is defined
  * or CONFIG_DYNAMIC_DEBUG is set.
  */
-#define pr_emerg(fmt, ...) \
-	printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert(fmt, ...) \
-	printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit(fmt, ...) \
-	printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err(fmt, ...) \
-	printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning(fmt, ...) \
-	printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warn pr_warning
-#define pr_notice(fmt, ...) \
-	printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info(fmt, ...) \
-	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+
+#ifdef CONFIG_PRINTK
+
+asmlinkage __printf(1, 2) __cold void __pr_emerg(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_alert(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_crit(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_err(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_warn(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_notice(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_info(const char *fmt, ...);
+
+#define pr_emerg(fmt, ...)	__pr_emerg(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...)	__pr_alert(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...)	__pr_crit(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...)	__pr_err(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn(fmt, ...)	__pr_warn(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice(fmt, ...)	__pr_notice(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...)	__pr_info(pr_fmt(fmt), ##__VA_ARGS__)
+
+#else
+
+#define pr_emerg(fmt, ...)	printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...)	printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...)	printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...)	printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn(fmt, ...)	printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice(fmt, ...)	printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...)	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+
+#endif
+
+#define pr_warning pr_warn
+
 /*
  * Like KERN_CONT, pr_cont() should only be used when continuing
  * a line with no newline ('\n') enclosed. Otherwise it defaults
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 7fd2838..5d4505f 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -16,9 +16,11 @@
  */
 #include <linux/percpu.h>
 
-typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
+typedef __printf(2, 0) int (*printk_func_t)(int level, const char *fmt,
+					    va_list args);
 
-int __printf(1, 0) vprintk_default(const char *fmt, va_list args);
+__printf(2, 0)
+int vprintk_default(int level, const char *fmt, va_list args);
 
 #ifdef CONFIG_PRINTK_NMI
 
@@ -31,9 +33,10 @@ extern raw_spinlock_t logbuf_lock;
  * via per-CPU variable.
  */
 DECLARE_PER_CPU(printk_func_t, printk_func);
-static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
+__printf(2, 0)
+static inline int vprintk_func(int level, const char *fmt, va_list args)
 {
-	return this_cpu_read(printk_func)(fmt, args);
+	return this_cpu_read(printk_func)(level, fmt, args);
 }
 
 extern atomic_t nmi_message_lost;
@@ -44,9 +47,10 @@ static inline int get_nmi_message_lost(void)
 
 #else /* CONFIG_PRINTK_NMI */
 
-static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
+__printf(2, 0)
+static inline int vprintk_func(int level, const char *fmt, va_list args)
 {
-	return vprintk_default(fmt, args);
+	return vprintk_default(level, fmt, args);
 }
 
 static inline int get_nmi_message_lost(void)
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c
index b69eb8a..bc3eeb1 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);
  * one writer running. But the buffer might get flushed from another
  * CPU, so we need to be careful.
  */
-static int vprintk_nmi(const char *fmt, va_list args)
+static int vprintk_nmi(int level, const char *fmt, va_list args)
 {
 	struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
 	int add = 0;
@@ -79,7 +79,16 @@ again:
 	if (!len)
 		smp_rmb();
 
-	add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
+	if (level != LOGLEVEL_DEFAULT) {
+		add = snprintf(s->buffer + len, sizeof(s->buffer) - len,
+				KERN_SOH "%c", '0' + level);
+		add += vsnprintf(s->buffer + len + add,
+				 sizeof(s->buffer) - len - add,
+				 fmt, args);
+	} else {
+		add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len,
+				fmt, args);
+	}
 
 	/*
 	 * 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 60cdf63..b6201dc 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1802,7 +1802,28 @@ asmlinkage int printk_emit(int facility, int level,
 }
 EXPORT_SYMBOL(printk_emit);
 
-int vprintk_default(const char *fmt, va_list args)
+#ifdef CONFIG_PRINTK
+#define define_pr_level(func, loglevel)				\
+asmlinkage __visible void func(const char *fmt, ...)		\
+{								\
+	va_list args;						\
+								\
+	va_start(args, fmt);					\
+	vprintk_default(loglevel, fmt, args);			\
+	va_end(args);						\
+}								\
+EXPORT_SYMBOL(func)
+
+define_pr_level(__pr_emerg, LOGLEVEL_EMERG);
+define_pr_level(__pr_alert, LOGLEVEL_ALERT);
+define_pr_level(__pr_crit, LOGLEVEL_CRIT);
+define_pr_level(__pr_err, LOGLEVEL_ERR);
+define_pr_level(__pr_warn, LOGLEVEL_WARNING);
+define_pr_level(__pr_notice, LOGLEVEL_NOTICE);
+define_pr_level(__pr_info, LOGLEVEL_NOTICE);
+#endif
+
+int vprintk_default(int level, const char *fmt, va_list args)
 {
 	int r;
 
@@ -1812,7 +1833,7 @@ int vprintk_default(const char *fmt, va_list args)
 		return r;
 	}
 #endif
-	r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
+	r = vprintk_emit(0, level, NULL, 0, fmt, args);
 
 	return r;
 }
@@ -1845,7 +1866,7 @@ asmlinkage __visible int printk(const char *fmt, ...)
 	int r;
 
 	va_start(args, fmt);
-	r = vprintk_func(fmt, args);
+	r = vprintk_func(LOGLEVEL_DEFAULT, fmt, args);
 	va_end(args);
 
 	return r;
-- 
2.8.0.rc4.16.g56331f8

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH V3] printk: Create pr_<level> functions
  2016-06-23 21:58 [PATCH V2] printk: Create pr_<level> functions Joe Perches
@ 2016-06-24  3:46 ` Joe Perches
  2016-08-09 17:01   ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2016-06-24  3:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

Using functions instead of macros can reduce overall code size
by eliminating unnecessary "KERN_SOH<digit>" prefixes from
format strings.

defconfig x86-64:

$ size vmlinux*
   text    data     bss      dec     hex  filename
10193570 4331464 1105920 15630954  ee826a vmlinux.new
10192623 4335560 1105920 15634103  ee8eb7 vmlinux.old

As the return value are unimportant and unused in the kernel tree,
these new functions return void.

Miscellanea:

o change pr_<level> macros to call new __pr_<level> functions
o change vprintk_nmi and vprintk_default to add LOGLEVEL_<level> argument

Signed-off-by: Joe Perches <joe@perches.com>
---
change in v3:

In case anyone didn't notice, Joe can't cut'n'paste.
Fix __pr_info function definition at LOGLEVEL_NOTICE level.

changes in V2:

Fix "CONFIG_PRINTK is not set" builds by adding CONFIG_PRINTK blocks
Fix x86-32 builds by setting __pr_<level> functions __asmlinkage and visible

Compile tested cross-compiled sparc, tinyconfig, x86-32 & -64 w/&w/o printk

 include/linux/printk.h   | 48 +++++++++++++++++++++++++++++++++---------------
 kernel/printk/internal.h | 16 ++++++++++------
 kernel/printk/nmi.c      | 13 +++++++++++--
 kernel/printk/printk.c   | 27 ++++++++++++++++++++++++---
 4 files changed, 78 insertions(+), 26 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index f4da695..e6ff22e 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -254,21 +254,39 @@ extern asmlinkage void dump_stack(void) __cold;
  * and other debug macros are compiled out unless either DEBUG is defined
  * or CONFIG_DYNAMIC_DEBUG is set.
  */
-#define pr_emerg(fmt, ...) \
-	printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert(fmt, ...) \
-	printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit(fmt, ...) \
-	printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err(fmt, ...) \
-	printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning(fmt, ...) \
-	printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warn pr_warning
-#define pr_notice(fmt, ...) \
-	printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info(fmt, ...) \
-	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+
+#ifdef CONFIG_PRINTK
+
+asmlinkage __printf(1, 2) __cold void __pr_emerg(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_alert(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_crit(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_err(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_warn(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_notice(const char *fmt, ...);
+asmlinkage __printf(1, 2) __cold void __pr_info(const char *fmt, ...);
+
+#define pr_emerg(fmt, ...)	__pr_emerg(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...)	__pr_alert(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...)	__pr_crit(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...)	__pr_err(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn(fmt, ...)	__pr_warn(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice(fmt, ...)	__pr_notice(pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...)	__pr_info(pr_fmt(fmt), ##__VA_ARGS__)
+
+#else
+
+#define pr_emerg(fmt, ...)	printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...)	printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...)	printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...)	printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn(fmt, ...)	printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice(fmt, ...)	printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...)	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+
+#endif
+
+#define pr_warning pr_warn
+
 /*
  * Like KERN_CONT, pr_cont() should only be used when continuing
  * a line with no newline ('\n') enclosed. Otherwise it defaults
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 7fd2838..5d4505f 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -16,9 +16,11 @@
  */
 #include <linux/percpu.h>
 
-typedef __printf(1, 0) int (*printk_func_t)(const char *fmt, va_list args);
+typedef __printf(2, 0) int (*printk_func_t)(int level, const char *fmt,
+					    va_list args);
 
-int __printf(1, 0) vprintk_default(const char *fmt, va_list args);
+__printf(2, 0)
+int vprintk_default(int level, const char *fmt, va_list args);
 
 #ifdef CONFIG_PRINTK_NMI
 
@@ -31,9 +33,10 @@ extern raw_spinlock_t logbuf_lock;
  * via per-CPU variable.
  */
 DECLARE_PER_CPU(printk_func_t, printk_func);
-static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
+__printf(2, 0)
+static inline int vprintk_func(int level, const char *fmt, va_list args)
 {
-	return this_cpu_read(printk_func)(fmt, args);
+	return this_cpu_read(printk_func)(level, fmt, args);
 }
 
 extern atomic_t nmi_message_lost;
@@ -44,9 +47,10 @@ static inline int get_nmi_message_lost(void)
 
 #else /* CONFIG_PRINTK_NMI */
 
-static inline __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
+__printf(2, 0)
+static inline int vprintk_func(int level, const char *fmt, va_list args)
 {
-	return vprintk_default(fmt, args);
+	return vprintk_default(level, fmt, args);
 }
 
 static inline int get_nmi_message_lost(void)
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c
index b69eb8a..bc3eeb1 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);
  * one writer running. But the buffer might get flushed from another
  * CPU, so we need to be careful.
  */
-static int vprintk_nmi(const char *fmt, va_list args)
+static int vprintk_nmi(int level, const char *fmt, va_list args)
 {
 	struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
 	int add = 0;
@@ -79,7 +79,16 @@ again:
 	if (!len)
 		smp_rmb();
 
-	add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
+	if (level != LOGLEVEL_DEFAULT) {
+		add = snprintf(s->buffer + len, sizeof(s->buffer) - len,
+				KERN_SOH "%c", '0' + level);
+		add += vsnprintf(s->buffer + len + add,
+				 sizeof(s->buffer) - len - add,
+				 fmt, args);
+	} else {
+		add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len,
+				fmt, args);
+	}
 
 	/*
 	 * 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 60cdf63..b6201dc 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1802,7 +1802,28 @@ asmlinkage int printk_emit(int facility, int level,
 }
 EXPORT_SYMBOL(printk_emit);
 
-int vprintk_default(const char *fmt, va_list args)
+#ifdef CONFIG_PRINTK
+#define define_pr_level(func, loglevel)				\
+asmlinkage __visible void func(const char *fmt, ...)		\
+{								\
+	va_list args;						\
+								\
+	va_start(args, fmt);					\
+	vprintk_default(loglevel, fmt, args);			\
+	va_end(args);						\
+}								\
+EXPORT_SYMBOL(func)
+
+define_pr_level(__pr_emerg, LOGLEVEL_EMERG);
+define_pr_level(__pr_alert, LOGLEVEL_ALERT);
+define_pr_level(__pr_crit, LOGLEVEL_CRIT);
+define_pr_level(__pr_err, LOGLEVEL_ERR);
+define_pr_level(__pr_warn, LOGLEVEL_WARNING);
+define_pr_level(__pr_notice, LOGLEVEL_NOTICE);
+define_pr_level(__pr_info, LOGLEVEL_INFO);
+#endif
+
+int vprintk_default(int level, const char *fmt, va_list args)
 {
 	int r;
 
@@ -1812,7 +1833,7 @@ int vprintk_default(const char *fmt, va_list args)
 		return r;
 	}
 #endif
-	r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
+	r = vprintk_emit(0, level, NULL, 0, fmt, args);
 
 	return r;
 }
@@ -1845,7 +1866,7 @@ asmlinkage __visible int printk(const char *fmt, ...)
 	int r;
 
 	va_start(args, fmt);
-	r = vprintk_func(fmt, args);
+	r = vprintk_func(LOGLEVEL_DEFAULT, fmt, args);
 	va_end(args);
 
 	return r;
-- 
2.8.0.rc4.16.g56331f8

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V3] printk: Create pr_<level> functions
  2016-06-24  3:46 ` [PATCH V3] " Joe Perches
@ 2016-08-09 17:01   ` Geert Uytterhoeven
  2016-08-09 17:09     ` Joe Perches
  2016-08-09 17:38     ` Joe Perches
  0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2016-08-09 17:01 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andrew Morton, linux-kernel

Hi Joe,

On Fri, Jun 24, 2016 at 5:46 AM, Joe Perches <joe@perches.com> wrote:
> Using functions instead of macros can reduce overall code size
> by eliminating unnecessary "KERN_SOH<digit>" prefixes from
> format strings.

This change, commit 874f9c7da9a4acbc1 upstream, 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)

I don't know why this is happening, hence I had to use git bisect to find
the offending commit.

Was this change intentional?
I guess it wouldn't hurt to send patches to add an explicit trailing newline
characters to messages that lack it?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V3] printk: Create pr_<level> functions
  2016-08-09 17:01   ` Geert Uytterhoeven
@ 2016-08-09 17:09     ` Joe Perches
  2016-08-09 17:38     ` Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2016-08-09 17:09 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Andrew Morton, linux-kernel

On Tue, 2016-08-09 at 19:01 +0200, Geert Uytterhoeven wrote:
> Hi Joe,

Hi Geert

> On Fri, Jun 24, 2016 at 5:46 AM, Joe Perches <joe@perches.com> wrote:
> > Using functions instead of macros can reduce overall code size
> > by eliminating unnecessary "KERN_SOH" prefixes from
> > format strings.

> This change, commit 874f9c7da9a4acbc1 upstream, 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)
> 
> I don't know why this is happening, hence I had to use git bisect to find
> the offending commit.
> 
> Was this change intentional?

No, that is not intentional.
Thanks for the report, I'll look at it.

> I guess it wouldn't hurt to send patches to add an explicit trailing newline
> characters to messages that lack it?

Always true.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V3] printk: Create pr_<level> functions
  2016-08-09 17:01   ` Geert Uytterhoeven
  2016-08-09 17:09     ` Joe Perches
@ 2016-08-09 17:38     ` Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2016-08-09 17:38 UTC (permalink / raw)
  To: Geert Uytterhoeven, Linus Torvalds; +Cc: Andrew Morton, linux-kernel

On Tue, 2016-08-09 at 19:01 +0200, Geert Uytterhoeven wrote:
> On Fri, Jun 24, 2016 at 5:46 AM, Joe Perches <joe@perches.com> wrote:
> > Using functions instead of macros can reduce overall code size
> > by eliminating unnecessary "KERN_SOH" prefixes from
> > format strings.
> This change, commit 874f9c7da9a4acbc1 upstream, 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)
> 
> I don't know why this is happening, hence I had to use git bisect to find
> the offending commit.

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-09 17:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-23 21:58 [PATCH V2] printk: Create pr_<level> functions Joe Perches
2016-06-24  3:46 ` [PATCH V3] " Joe Perches
2016-08-09 17:01   ` Geert Uytterhoeven
2016-08-09 17:09     ` Joe Perches
2016-08-09 17:38     ` Joe Perches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.