diff options
author | Joe Perches <joe@perches.com> | 2008-02-26 22:08:42 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-19 22:10:19 -0400 |
commit | 1429db83e276c2a16c7ea83bdcf0dcd3a36e406d (patch) | |
tree | e3960d6e7c19f5c29accbf5db11edb93d2cea28f /include/linux/device.h | |
parent | 00a41db522c77af33ea5ee9837d4f043ce150249 (diff) |
driver core: Convert debug functions declared inline __attribute__((format (printf,x,y) to statement expression macros
When DEBUG is not defined, pr_debug and dev_dbg and some
other local debugging functions are specified as:
"inline __attribute__((format (printf, x, y)))"
This is done to validate printk arguments when not debugging.
Converting these functions to macros or statement expressions
"do { if (0) printk(fmt, ##arg); } while (0)"
or
"({ if (0) printk(fmt, ##arg); 0; })
makes at least gcc 4.2.2 produce smaller objects.
This has the additional benefit of allowing the optimizer to
avoid calling functions like print_mac that might have been
arguments to the printk.
defconfig x86 current:
$ size vmlinux
text data bss dec hex filename
4716770 474560 618496 5809826 58a6a2 vmlinux
all converted: (More patches follow)
$ size vmlinux
text data bss dec hex filename
4716642 474560 618496 5809698 58a622 vmlinux
Even kernel/sched.o, which doesn't even use these
functions, becomes smaller.
It appears that merely having an indirect include
of <linux/device.h> can cause bigger objects.
$ size sched.inline.o sched.if0.o
text data bss dec hex filename
31385 2854 328 34567 8707 sched.inline.o
31366 2854 328 34548 86f4 sched.if0.o
The current preprocessed only kernel/sched.i file contains:
# 612 "include/linux/device.h"
static inline __attribute__((always_inline)) int __attribute__ ((format (printf, 2, 3)))
dev_dbg(struct device *dev, const char *fmt, ...)
{
return 0;
}
# 628 "include/linux/device.h"
static inline __attribute__((always_inline)) int __attribute__ ((format (printf, 2, 3)))
dev_vdbg(struct device *dev, const char *fmt, ...)
{
return 0;
}
Removing these unused inlines from sched.i shrinks sched.o
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 2258d89bf523..d57661129cb2 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -608,21 +608,16 @@ extern const char *dev_driver_string(struct device *dev); | |||
608 | #define dev_dbg(dev, format, arg...) \ | 608 | #define dev_dbg(dev, format, arg...) \ |
609 | dev_printk(KERN_DEBUG , dev , format , ## arg) | 609 | dev_printk(KERN_DEBUG , dev , format , ## arg) |
610 | #else | 610 | #else |
611 | static inline int __attribute__ ((format (printf, 2, 3))) | 611 | #define dev_dbg(dev, format, arg...) \ |
612 | dev_dbg(struct device *dev, const char *fmt, ...) | 612 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) |
613 | { | ||
614 | return 0; | ||
615 | } | ||
616 | #endif | 613 | #endif |
617 | 614 | ||
618 | #ifdef VERBOSE_DEBUG | 615 | #ifdef VERBOSE_DEBUG |
619 | #define dev_vdbg dev_dbg | 616 | #define dev_vdbg dev_dbg |
620 | #else | 617 | #else |
621 | static inline int __attribute__ ((format (printf, 2, 3))) | 618 | |
622 | dev_vdbg(struct device *dev, const char *fmt, ...) | 619 | #define dev_vdbg(dev, format, arg...) \ |
623 | { | 620 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) |
624 | return 0; | ||
625 | } | ||
626 | #endif | 621 | #endif |
627 | 622 | ||
628 | /* Create alias, so I can be autoloaded. */ | 623 | /* Create alias, so I can be autoloaded. */ |