Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
PATCH 1/1 Eliminate thousands of warnings in WARN_ON with gcc 3.2 build
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)
--- include/asm-generic/bug.h | 7 ++++--- kernel/panic.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-)
include/asm-generic/bug.h +4 -3
@@ -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
kernel/panic.c +9 -3
@@ -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
Quoted 6 lines · Andi Kleen
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.
Quoted 42 lines
Signed-off-by Andi Kleen <[email protected]>--- 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
===================================================================include/asm-generic/bug.h +4
-3@@ -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
===================================================================kernel/panic.c +1
-1@@ -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 ];
kernel/panic.c line 361
Quoted 5 lines
kernel/panic.c +1
-1@@ -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...
Quoted 8 lines
kernel/panic.c +0
-1va_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);
kernel/panic.c line 381
Quoted 10 lines
kernel/panic.c +7
-0+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:
/^JN - Jesper Nilsson
Signature · 1 line
Jesper Nilsson -- [email protected]
Quoted 11 lines · Jesper Nilsson
Quoted 11 lines
#ifdef
WANT_WARN_ON_SLOWPATHkernel/panic.c +1
-1-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);
Quoted 6 lines
kernel/panic.c line 361
Quoted 2 lines
kernel/panic.c +1
-1-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.
Quoted 2 lines
Acked-by Jesper Nilsson <[email protected]>
Thanks.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Hi Andi,
Quoted 59 lines · Andi Kleen
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 <[email protected]>--- 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
===================================================================include/asm-generic/bug.h +4
-3@@ -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
===================================================================kernel/panic.c +2
-2@@ -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 ();
kernel/panic.c line 378
Quoted 10 lines
kernel/panic.c +7
-1add_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...
Andi Kleen
Acked-by Jesper NilssonQuoted 9 lines · Johannes Weiner
Review
Quoted 4 lines
(quoted diff) +4
-0+{ + 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)
--- include/asm-generic/bug.h | 7 ++++--- kernel/panic.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-)
include/asm-generic/bug.h +4 -3
@@ -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
kernel/panic.c +9 -3
@@ -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
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 17 lines · Andi Kleen
Quoted 9 lines · Johannes Weiner
kernel/panic.c line 378
Quoted 4 lines
kernel/panic.c +4
-0+{ +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
Quoted 8 lines
---
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
Quoted 55 lines
v2: Avoid warning in
warn_slowpath_nullon newer gccs too (J.Weiner)Acked-by Jesper Nilsson <[email protected]>Signed-off-by Andi Kleen <[email protected]>--- 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
===================================================================include/asm-generic/bug.h +4
-3@@ -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
===================================================================kernel/panic.c +2
-2@@ -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 ();
kernel/panic.c line 378
Quoted 10 lines
kernel/panic.c +7
-1add_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 <[email protected]>
Quoted 9 lines · Johannes Weiner
Review
Quoted 5 lines
(quoted diff) +5
-0+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 <[email protected]>
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
--- include/asm-generic/bug.h | 7 ++++--- kernel/panic.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-)
include/asm-generic/bug.h +4 -3
@@ -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
kernel/panic.c +10 -3
@@ -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
Signature · 1 line
[email protected] -- Speaking for myself only.
Arjan van de Ven
Acked-byQuoted 11 lines · Andi Kleen
Quoted 8 lines · Johannes Weiner
kernel/panic.c line 379
Quoted 5 lines
kernel/panic.c +5
-0+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 <[email protected]>
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
Quoted 9 lines · Arjan van de Ven
Quoted 8 lines · Andi Kleen
Quoted 7 lines · Johannes Weiner
kernel/panic.c line 379
Quoted 5 lines
kernel/panic.c +5
-0+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?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Otherwise, Acked-by: Johannes Weiner <[email protected]>
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
Quoted 1 line
Acked-by Arjan van de Ven <[email protected]>
Thanks.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.