All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
@ 2009-04-22 22:11 Andi Kleen
  2009-04-23 11:58 ` Jesper Nilsson
  2009-04-23 12:02 ` Johannes Weiner
  0 siblings, 2 replies; 9+ messages in thread
From: Andi Kleen @ 2009-04-22 22:11 UTC (permalink / raw)
  To: arjan, linux-kernel, torvalds, akpm

Eliminate thousands of warnings with gcc 3.2 build

When building with gcc 3.2 I get thousands of warnings about passing
a NULL format string to warn_on_slowpath(). Split this case out
into a separate call. This should also shrink the kernel
slightly in theory (haven't done numbers)

Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
 include/asm-generic/bug.h |    7 ++++---
 kernel/panic.c            |   12 +++++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

Index: linux-2.6.30-rc2-ak/include/asm-generic/bug.h
===================================================================
--- linux-2.6.30-rc2-ak.orig/include/asm-generic/bug.h	2009-01-11 20:20:40.000000000 +0100
+++ linux-2.6.30-rc2-ak/include/asm-generic/bug.h	2009-04-22 23:52:48.000000000 +0200
@@ -58,12 +58,13 @@
  */
 #ifndef __WARN
 #ifndef __ASSEMBLY__
-extern void warn_slowpath(const char *file, const int line,
+extern void warn_slowpath_fmt(const char *file, const int line,
 		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+extern void warn_slowpath_null(const char *file, const int line);
 #define WANT_WARN_ON_SLOWPATH
 #endif
-#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)
-#define __WARN_printf(arg...)	warn_slowpath(__FILE__, __LINE__, arg)
+#define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
+#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
 #else
 #define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
 #endif
Index: linux-2.6.30-rc2-ak/kernel/panic.c
===================================================================
--- linux-2.6.30-rc2-ak.orig/kernel/panic.c	2009-04-19 19:29:07.000000000 +0200
+++ linux-2.6.30-rc2-ak/kernel/panic.c	2009-04-22 23:53:55.000000000 +0200
@@ -342,7 +342,7 @@
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
-void warn_slowpath(const char *file, int line, const char *fmt, ...)
+void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
 	char function[KSYM_SYMBOL_LEN];
@@ -358,7 +358,7 @@
 	if (board)
 		printk(KERN_WARNING "Hardware name: %s\n", board);
 
-	if (fmt) {
+	if (*fmt) {
 		va_start(args, fmt);
 		vprintk(fmt, args);
 		va_end(args);
@@ -369,7 +369,13 @@
 	print_oops_end_marker();
 	add_taint(TAINT_WARN);
 }
-EXPORT_SYMBOL(warn_slowpath);
+EXPORT_SYMBOL(warn_slowpath_fmt);
+
+void warn_slowpath_null(const char *file, int line)
+{
+	warn_slowpath_fmt(file, line, "");
+}
+EXPORT_SYMBOL(warn_slowpath_null);
 #endif
 
 #ifdef CONFIG_CC_STACKPROTECTOR

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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-22 22:11 [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build Andi Kleen
@ 2009-04-23 11:58 ` Jesper Nilsson
  2009-04-23 12:18   ` Andi Kleen
  2009-04-23 12:02 ` Johannes Weiner
  1 sibling, 1 reply; 9+ messages in thread
From: Jesper Nilsson @ 2009-04-23 11:58 UTC (permalink / raw)
  To: Andi Kleen; +Cc: arjan, linux-kernel, torvalds, akpm

On Thu, Apr 23, 2009 at 12:11:34AM +0200, Andi Kleen wrote:
> Eliminate thousands of warnings with gcc 3.2 build
> 
> When building with gcc 3.2 I get thousands of warnings about passing
> a NULL format string to warn_on_slowpath(). Split this case out
> into a separate call. This should also shrink the kernel
> slightly in theory (haven't done numbers)

I've run into this also, it would be good to get rid of all those warnings.

> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 
> ---
>  include/asm-generic/bug.h |    7 ++++---
>  kernel/panic.c            |   12 +++++++++---
>  2 files changed, 13 insertions(+), 6 deletions(-)
> 
> Index: linux-2.6.30-rc2-ak/include/asm-generic/bug.h
> ===================================================================
> --- linux-2.6.30-rc2-ak.orig/include/asm-generic/bug.h	2009-01-11 20:20:40.000000000 +0100
> +++ linux-2.6.30-rc2-ak/include/asm-generic/bug.h	2009-04-22 23:52:48.000000000 +0200
> @@ -58,12 +58,13 @@
>   */
>  #ifndef __WARN
>  #ifndef __ASSEMBLY__
> -extern void warn_slowpath(const char *file, const int line,
> +extern void warn_slowpath_fmt(const char *file, const int line,
>  		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
> +extern void warn_slowpath_null(const char *file, const int line);
>  #define WANT_WARN_ON_SLOWPATH
>  #endif
> -#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)
> -#define __WARN_printf(arg...)	warn_slowpath(__FILE__, __LINE__, arg)
> +#define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
> +#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
>  #else
>  #define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
>  #endif
> Index: linux-2.6.30-rc2-ak/kernel/panic.c
> ===================================================================
> --- linux-2.6.30-rc2-ak.orig/kernel/panic.c	2009-04-19 19:29:07.000000000 +0200
> +++ linux-2.6.30-rc2-ak/kernel/panic.c	2009-04-22 23:53:55.000000000 +0200
> @@ -342,7 +342,7 @@
>  }
>  
>  #ifdef WANT_WARN_ON_SLOWPATH
> -void warn_slowpath(const char *file, int line, const char *fmt, ...)
> +void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
>  {
>  	va_list args;
>  	char function[KSYM_SYMBOL_LEN];
> @@ -358,7 +358,7 @@
>  	if (board)
>  		printk(KERN_WARNING "Hardware name: %s\n", board);
>  
> -	if (fmt) {
> +	if (*fmt) {

Is this completely safe? If somebody is stupid enough to call
WARN(condition, NULL); this won't work as it did before.
OTOH, it would still be useless in debugging...

>  		va_start(args, fmt);
>  		vprintk(fmt, args);
>  		va_end(args);
> @@ -369,7 +369,13 @@
>  	print_oops_end_marker();
>  	add_taint(TAINT_WARN);
>  }
> -EXPORT_SYMBOL(warn_slowpath);
> +EXPORT_SYMBOL(warn_slowpath_fmt);
> +
> +void warn_slowpath_null(const char *file, int line)
> +{
> +	warn_slowpath_fmt(file, line, "");
> +}
> +EXPORT_SYMBOL(warn_slowpath_null);
>  #endif
>  
>  #ifdef CONFIG_CC_STACKPROTECTOR

Otherwise:

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-22 22:11 [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build Andi Kleen
  2009-04-23 11:58 ` Jesper Nilsson
@ 2009-04-23 12:02 ` Johannes Weiner
  2009-04-23 12:23   ` Andi Kleen
  1 sibling, 1 reply; 9+ messages in thread
From: Johannes Weiner @ 2009-04-23 12:02 UTC (permalink / raw)
  To: Andi Kleen; +Cc: arjan, linux-kernel, torvalds, akpm

Hi Andi,

On Thu, Apr 23, 2009 at 12:11:34AM +0200, Andi Kleen wrote:
> Eliminate thousands of warnings with gcc 3.2 build
> 
> When building with gcc 3.2 I get thousands of warnings about passing
> a NULL format string to warn_on_slowpath(). Split this case out
> into a separate call. This should also shrink the kernel
> slightly in theory (haven't done numbers)
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 
> ---
>  include/asm-generic/bug.h |    7 ++++---
>  kernel/panic.c            |   12 +++++++++---
>  2 files changed, 13 insertions(+), 6 deletions(-)
> 
> Index: linux-2.6.30-rc2-ak/include/asm-generic/bug.h
> ===================================================================
> --- linux-2.6.30-rc2-ak.orig/include/asm-generic/bug.h	2009-01-11 20:20:40.000000000 +0100
> +++ linux-2.6.30-rc2-ak/include/asm-generic/bug.h	2009-04-22 23:52:48.000000000 +0200
> @@ -58,12 +58,13 @@
>   */
>  #ifndef __WARN
>  #ifndef __ASSEMBLY__
> -extern void warn_slowpath(const char *file, const int line,
> +extern void warn_slowpath_fmt(const char *file, const int line,
>  		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
> +extern void warn_slowpath_null(const char *file, const int line);
>  #define WANT_WARN_ON_SLOWPATH
>  #endif
> -#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)
> -#define __WARN_printf(arg...)	warn_slowpath(__FILE__, __LINE__, arg)
> +#define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
> +#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
>  #else
>  #define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
>  #endif
> Index: linux-2.6.30-rc2-ak/kernel/panic.c
> ===================================================================
> --- linux-2.6.30-rc2-ak.orig/kernel/panic.c	2009-04-19 19:29:07.000000000 +0200
> +++ linux-2.6.30-rc2-ak/kernel/panic.c	2009-04-22 23:53:55.000000000 +0200
> @@ -342,7 +342,7 @@
>  }
>  
>  #ifdef WANT_WARN_ON_SLOWPATH
> -void warn_slowpath(const char *file, int line, const char *fmt, ...)
> +void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
>  {
>  	va_list args;
>  	char function[KSYM_SYMBOL_LEN];
> @@ -358,7 +358,7 @@
>  	if (board)
>  		printk(KERN_WARNING "Hardware name: %s\n", board);
>  
> -	if (fmt) {
> +	if (*fmt) {
>  		va_start(args, fmt);
>  		vprintk(fmt, args);
>  		va_end(args);
> @@ -369,7 +369,13 @@
>  	print_oops_end_marker();
>  	add_taint(TAINT_WARN);
>  }
> -EXPORT_SYMBOL(warn_slowpath);
> +EXPORT_SYMBOL(warn_slowpath_fmt);
> +
> +void warn_slowpath_null(const char *file, int line)
> +{
> +	warn_slowpath_fmt(file, line, "");
> +}
> +EXPORT_SYMBOL(warn_slowpath_null);

That should still emit a warning due to passing in a zero-length
format string.  Using (const char *){ 0 } as the literal would
suppress it (on gcc 4.3.3 at least) but I'm not sure if it's worth the
uglyness...

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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-23 11:58 ` Jesper Nilsson
@ 2009-04-23 12:18   ` Andi Kleen
  0 siblings, 0 replies; 9+ messages in thread
From: Andi Kleen @ 2009-04-23 12:18 UTC (permalink / raw)
  To: Jesper Nilsson; +Cc: Andi Kleen, arjan, linux-kernel, torvalds, akpm

On Thu, Apr 23, 2009 at 01:58:46PM +0200, Jesper Nilsson wrote:
> >  
> >  #ifdef WANT_WARN_ON_SLOWPATH
> > -void warn_slowpath(const char *file, int line, const char *fmt, ...)
> > +void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
> >  {
> >  	va_list args;
> >  	char function[KSYM_SYMBOL_LEN];
> > @@ -358,7 +358,7 @@
> >  	if (board)
> >  		printk(KERN_WARNING "Hardware name: %s\n", board);
> >  
> > -	if (fmt) {
> > +	if (*fmt) {
> 
> Is this completely safe? If somebody is stupid enough to call
> WARN(condition, NULL); this won't work as it did before.
> OTOH, it would still be useless in debugging...

Noone in tree does according to grep. I would also argue
anyone doing that to be really broken.

> 
> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>

Thanks.

-Andi
-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-23 12:02 ` Johannes Weiner
@ 2009-04-23 12:23   ` Andi Kleen
  2009-04-23 14:38     ` Johannes Weiner
  0 siblings, 1 reply; 9+ messages in thread
From: Andi Kleen @ 2009-04-23 12:23 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: Andi Kleen, arjan, linux-kernel, torvalds, akpm

On Thu, Apr 23, 2009 at 02:02:19PM +0200, Johannes Weiner wrote:
> > +{
> > +	warn_slowpath_fmt(file, line, "");
> > +}
> > +EXPORT_SYMBOL(warn_slowpath_null);
> 
> That should still emit a warning due to passing in a zero-length
> format string.  Using (const char *){ 0 } as the literal would
> suppress it (on gcc 4.3.3 at least) but I'm not sure if it's worth the
> uglyness...

Hmm, you're right 3.3 generates a warning for that, 3.2 doesn't
But at least it's only a single one, not thousands.
Your trick would make sense. Updated patch attached.

-Andi

---

Eliminate thousands of warnings with gcc 3.2 build v2

When building with gcc 3.2 I get thousands of warnings about passing
a NULL format string to warn_on_slowpath(). Split this case out
into a separate call. This should also shrink the kernel
slightly.

v2: Avoid warning in warn_slowpath_null on newer gccs too (J.Weiner)

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
 include/asm-generic/bug.h |    7 ++++---
 kernel/panic.c            |   12 +++++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

Index: linux-2.6.30-rc2-ak/include/asm-generic/bug.h
===================================================================
--- linux-2.6.30-rc2-ak.orig/include/asm-generic/bug.h	2009-01-11 20:20:40.000000000 +0100
+++ linux-2.6.30-rc2-ak/include/asm-generic/bug.h	2009-04-22 23:52:48.000000000 +0200
@@ -58,12 +58,13 @@
  */
 #ifndef __WARN
 #ifndef __ASSEMBLY__
-extern void warn_slowpath(const char *file, const int line,
+extern void warn_slowpath_fmt(const char *file, const int line,
 		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+extern void warn_slowpath_null(const char *file, const int line);
 #define WANT_WARN_ON_SLOWPATH
 #endif
-#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)
-#define __WARN_printf(arg...)	warn_slowpath(__FILE__, __LINE__, arg)
+#define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
+#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
 #else
 #define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
 #endif
Index: linux-2.6.30-rc2-ak/kernel/panic.c
===================================================================
--- linux-2.6.30-rc2-ak.orig/kernel/panic.c	2009-04-19 19:29:07.000000000 +0200
+++ linux-2.6.30-rc2-ak/kernel/panic.c	2009-04-23 14:17:34.000000000 +0200
@@ -342,7 +342,7 @@
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
-void warn_slowpath(const char *file, int line, const char *fmt, ...)
+void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
 	char function[KSYM_SYMBOL_LEN];
@@ -358,7 +358,7 @@
 	if (board)
 		printk(KERN_WARNING "Hardware name: %s\n", board);
 
-	if (fmt) {
+	if (*fmt) {
 		va_start(args, fmt);
 		vprintk(fmt, args);
 		va_end(args);
@@ -369,7 +369,13 @@
 	print_oops_end_marker();
 	add_taint(TAINT_WARN);
 }
-EXPORT_SYMBOL(warn_slowpath);
+EXPORT_SYMBOL(warn_slowpath_fmt);
+
+void warn_slowpath_null(const char *file, int line)
+{
+	warn_slowpath_fmt(file, line, (const char *) { 0 });
+}
+EXPORT_SYMBOL(warn_slowpath_null);
 #endif
 
 #ifdef CONFIG_CC_STACKPROTECTOR


-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-23 12:23   ` Andi Kleen
@ 2009-04-23 14:38     ` Johannes Weiner
  2009-04-23 15:10       ` Andi Kleen
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Weiner @ 2009-04-23 14:38 UTC (permalink / raw)
  To: Andi Kleen; +Cc: arjan, linux-kernel, torvalds, akpm

On Thu, Apr 23, 2009 at 02:23:27PM +0200, Andi Kleen wrote:
> On Thu, Apr 23, 2009 at 02:02:19PM +0200, Johannes Weiner wrote:
> > > +{
> > > +	warn_slowpath_fmt(file, line, "");
> > > +}
> > > +EXPORT_SYMBOL(warn_slowpath_null);
> > 
> > That should still emit a warning due to passing in a zero-length
> > format string.  Using (const char *){ 0 } as the literal would
> > suppress it (on gcc 4.3.3 at least) but I'm not sure if it's worth the
> > uglyness...
> 
> Hmm, you're right 3.3 generates a warning for that, 3.2 doesn't
> But at least it's only a single one, not thousands.
> Your trick would make sense. Updated patch attached.
> 
> -Andi
> 
> ---
> 
> Eliminate thousands of warnings with gcc 3.2 build v2
> 
> When building with gcc 3.2 I get thousands of warnings about passing
> a NULL format string to warn_on_slowpath(). Split this case out
> into a separate call. This should also shrink the kernel
> slightly.

You are right:

	   text    data     bss     dec     hex filename
	4802274  707668  712704 6222646  5ef336 vmlinux
	   text    data     bss     dec     hex filename
	4799027  703572  712704 6215303  5ed687 vmlinux

> v2: Avoid warning in warn_slowpath_null on newer gccs too (J.Weiner)
> 
> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 
> ---
>  include/asm-generic/bug.h |    7 ++++---
>  kernel/panic.c            |   12 +++++++++---
>  2 files changed, 13 insertions(+), 6 deletions(-)
> 
> Index: linux-2.6.30-rc2-ak/include/asm-generic/bug.h
> ===================================================================
> --- linux-2.6.30-rc2-ak.orig/include/asm-generic/bug.h	2009-01-11 20:20:40.000000000 +0100
> +++ linux-2.6.30-rc2-ak/include/asm-generic/bug.h	2009-04-22 23:52:48.000000000 +0200
> @@ -58,12 +58,13 @@
>   */
>  #ifndef __WARN
>  #ifndef __ASSEMBLY__
> -extern void warn_slowpath(const char *file, const int line,
> +extern void warn_slowpath_fmt(const char *file, const int line,
>  		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
> +extern void warn_slowpath_null(const char *file, const int line);
>  #define WANT_WARN_ON_SLOWPATH
>  #endif
> -#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)
> -#define __WARN_printf(arg...)	warn_slowpath(__FILE__, __LINE__, arg)
> +#define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
> +#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
>  #else
>  #define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
>  #endif
> Index: linux-2.6.30-rc2-ak/kernel/panic.c
> ===================================================================
> --- linux-2.6.30-rc2-ak.orig/kernel/panic.c	2009-04-19 19:29:07.000000000 +0200
> +++ linux-2.6.30-rc2-ak/kernel/panic.c	2009-04-23 14:17:34.000000000 +0200
> @@ -342,7 +342,7 @@
>  }
>  
>  #ifdef WANT_WARN_ON_SLOWPATH
> -void warn_slowpath(const char *file, int line, const char *fmt, ...)
> +void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
>  {
>  	va_list args;
>  	char function[KSYM_SYMBOL_LEN];
> @@ -358,7 +358,7 @@
>  	if (board)
>  		printk(KERN_WARNING "Hardware name: %s\n", board);
>  
> -	if (fmt) {
> +	if (*fmt) {
>  		va_start(args, fmt);
>  		vprintk(fmt, args);
>  		va_end(args);
> @@ -369,7 +369,13 @@
>  	print_oops_end_marker();
>  	add_taint(TAINT_WARN);
>  }
> -EXPORT_SYMBOL(warn_slowpath);
> +EXPORT_SYMBOL(warn_slowpath_fmt);
> +
> +void warn_slowpath_null(const char *file, int line)
> +{
> +	warn_slowpath_fmt(file, line, (const char *) { 0 });
> +}
> +EXPORT_SYMBOL(warn_slowpath_null);

I would WTF here without knowing the warning.  Can you add a comment?

Otherwise, Acked-by: Johannes Weiner <hannes@cmpxchg.org>

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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-23 15:10       ` Andi Kleen
@ 2009-04-23 15:07         ` Arjan van de Ven
  2009-04-23 15:23           ` Andi Kleen
  0 siblings, 1 reply; 9+ messages in thread
From: Arjan van de Ven @ 2009-04-23 15:07 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Johannes Weiner, linux-kernel, torvalds, akpm

Andi Kleen wrote:
> On Thu, Apr 23, 2009 at 04:38:59PM +0200, Johannes Weiner wrote:
>>> +void warn_slowpath_null(const char *file, int line)
>>> +{
>>> +	warn_slowpath_fmt(file, line, (const char *) { 0 });
>>> +}
>>> +EXPORT_SYMBOL(warn_slowpath_null);
>> I would WTF here without knowing the warning.  Can you add a comment?
>>
>> Otherwise, Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> 
> Ok version with comment.

Makes sense if we plan to keep gcc 3.2 supported; if we plan to drop it then we shouldn't bother.

Anyway

Acked-by: Arjan van de Ven <arjan@linux.intel.com>


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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-23 14:38     ` Johannes Weiner
@ 2009-04-23 15:10       ` Andi Kleen
  2009-04-23 15:07         ` Arjan van de Ven
  0 siblings, 1 reply; 9+ messages in thread
From: Andi Kleen @ 2009-04-23 15:10 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: Andi Kleen, arjan, linux-kernel, torvalds, akpm

On Thu, Apr 23, 2009 at 04:38:59PM +0200, Johannes Weiner wrote:
> > +void warn_slowpath_null(const char *file, int line)
> > +{
> > +	warn_slowpath_fmt(file, line, (const char *) { 0 });
> > +}
> > +EXPORT_SYMBOL(warn_slowpath_null);
> 
> I would WTF here without knowing the warning.  Can you add a comment?
> 
> Otherwise, Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Ok version with comment.

-Andi

---


Eliminate thousands of warnings with gcc 3.2 build v3

When building with gcc 3.2 I get thousands of warnings about passing
a NULL format string to warn_on_slowpath(). Split this case out
into a separate call. This also shrinks the kernel slightly:

          text    data     bss     dec     hex filename
       4802274  707668  712704 6222646  5ef336 vmlinux
          text    data     bss     dec     hex filename
       4799027  703572  712704 6215303  5ed687 vmlinux

v2: Avoid warning in warn_slowpath_null on newer gccs too (J.Weiner)
v3: add comment, size numbers

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
 include/asm-generic/bug.h |    7 ++++---
 kernel/panic.c            |   13 ++++++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

Index: linux-2.6.30-rc2-ak/include/asm-generic/bug.h
===================================================================
--- linux-2.6.30-rc2-ak.orig/include/asm-generic/bug.h	2009-01-11 20:20:40.000000000 +0100
+++ linux-2.6.30-rc2-ak/include/asm-generic/bug.h	2009-04-22 23:52:48.000000000 +0200
@@ -58,12 +58,13 @@
  */
 #ifndef __WARN
 #ifndef __ASSEMBLY__
-extern void warn_slowpath(const char *file, const int line,
+extern void warn_slowpath_fmt(const char *file, const int line,
 		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+extern void warn_slowpath_null(const char *file, const int line);
 #define WANT_WARN_ON_SLOWPATH
 #endif
-#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)
-#define __WARN_printf(arg...)	warn_slowpath(__FILE__, __LINE__, arg)
+#define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
+#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
 #else
 #define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
 #endif
Index: linux-2.6.30-rc2-ak/kernel/panic.c
===================================================================
--- linux-2.6.30-rc2-ak.orig/kernel/panic.c	2009-04-19 19:29:07.000000000 +0200
+++ linux-2.6.30-rc2-ak/kernel/panic.c	2009-04-23 17:05:01.000000000 +0200
@@ -342,7 +342,7 @@
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
-void warn_slowpath(const char *file, int line, const char *fmt, ...)
+void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
 	char function[KSYM_SYMBOL_LEN];
@@ -358,7 +358,7 @@
 	if (board)
 		printk(KERN_WARNING "Hardware name: %s\n", board);
 
-	if (fmt) {
+	if (*fmt) {
 		va_start(args, fmt);
 		vprintk(fmt, args);
 		va_end(args);
@@ -369,7 +369,14 @@
 	print_oops_end_marker();
 	add_taint(TAINT_WARN);
 }
-EXPORT_SYMBOL(warn_slowpath);
+EXPORT_SYMBOL(warn_slowpath_fmt);
+
+void warn_slowpath_null(const char *file, int line)
+{
+	/* The { 0 } avoids a gcc format warning */
+	warn_slowpath_fmt(file, line, (const char *) { 0 });
+}
+EXPORT_SYMBOL(warn_slowpath_null);
 #endif
 
 #ifdef CONFIG_CC_STACKPROTECTOR

-- 
ak@linux.intel.com -- Speaking for myself only.

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

* Re: [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
  2009-04-23 15:07         ` Arjan van de Ven
@ 2009-04-23 15:23           ` Andi Kleen
  0 siblings, 0 replies; 9+ messages in thread
From: Andi Kleen @ 2009-04-23 15:23 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Andi Kleen, Johannes Weiner, linux-kernel, torvalds, akpm

On Thu, Apr 23, 2009 at 08:07:51AM -0700, Arjan van de Ven wrote:
> Andi Kleen wrote:
> >On Thu, Apr 23, 2009 at 04:38:59PM +0200, Johannes Weiner wrote:
> >>>+void warn_slowpath_null(const char *file, int line)
> >>>+{
> >>>+	warn_slowpath_fmt(file, line, (const char *) { 0 });
> >>>+}
> >>>+EXPORT_SYMBOL(warn_slowpath_null);
> >>I would WTF here without knowing the warning.  Can you add a comment?
> >>
> >>Otherwise, Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> >
> >Ok version with comment.
> 
> Makes sense if we plan to keep gcc 3.2 supported; if we plan to drop it 
> then we shouldn't bother.

It helps even for other compilers for code size, at least it shrunk Johannes' 
kernel by about 3k

> Acked-by: Arjan van de Ven <arjan@linux.intel.com>

Thanks.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

end of thread, other threads:[~2009-04-23 15:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-22 22:11 [PATCH] Eliminate thousands of warnings in WARN_ON with gcc 3.2 build Andi Kleen
2009-04-23 11:58 ` Jesper Nilsson
2009-04-23 12:18   ` Andi Kleen
2009-04-23 12:02 ` Johannes Weiner
2009-04-23 12:23   ` Andi Kleen
2009-04-23 14:38     ` Johannes Weiner
2009-04-23 15:10       ` Andi Kleen
2009-04-23 15:07         ` Arjan van de Ven
2009-04-23 15:23           ` Andi Kleen

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.