Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dev_printk: Add and use dev_no_printk()

When printk-indexing is enabled, each dev_printk() invocation emits a
pi_entry structure. This is even true when the dev_printk() is
protected by an always-false check, as is typically the case for debug
messages: while the actual code to print the message is optimized out by
the compiler, the pi_entry structure is still emitted.

Avoid emitting pi_entry structures for unavailable dev_printk() kernel
messages by:
1. Introducing a dev_no_printk() helper, mimicked after the existing
no_printk() helper, which calls _dev_printk() instead of
dev_printk(),
2. Replacing all "if (0) dev_printk(...)" constructs by calls to the
new helper.

This reduces the size of an arm64 defconfig kernel with
CONFIG_PRINTK_INDEX=y by 957 KiB.

Fixes: ad7d61f159db7397 ("printk: index: Add indexing support to dev_printk")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Chris Down <chris@chrisdown.name>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/8583d54f1687c801c6cda8edddf2cf0344c6e883.1709127473.git.geert+renesas@glider.be
Signed-off-by: Petr Mladek <pmladek@suse.com>

authored by

Geert Uytterhoeven and committed by
Petr Mladek
c26ec799 8522f6b7

+13 -12
+13 -12
include/linux/dev_printk.h
··· 130 130 }) 131 131 132 132 /* 133 + * Dummy dev_printk for disabled debugging statements to use whilst maintaining 134 + * gcc's format checking. 135 + */ 136 + #define dev_no_printk(level, dev, fmt, ...) \ 137 + ({ \ 138 + if (0) \ 139 + _dev_printk(level, dev, fmt, ##__VA_ARGS__); \ 140 + }) 141 + 142 + /* 133 143 * #defines for all the dev_<level> macros to prefix with whatever 134 144 * possible use of #define dev_fmt(fmt) ... 135 145 */ ··· 168 158 dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) 169 159 #else 170 160 #define dev_dbg(dev, fmt, ...) \ 171 - ({ \ 172 - if (0) \ 173 - dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ 174 - }) 161 + dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) 175 162 #endif 176 163 177 164 #ifdef CONFIG_PRINTK ··· 254 247 } while (0) 255 248 #else 256 249 #define dev_dbg_ratelimited(dev, fmt, ...) \ 257 - do { \ 258 - if (0) \ 259 - dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ 260 - } while (0) 250 + dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) 261 251 #endif 262 252 263 253 #ifdef VERBOSE_DEBUG 264 254 #define dev_vdbg dev_dbg 265 255 #else 266 256 #define dev_vdbg(dev, fmt, ...) \ 267 - ({ \ 268 - if (0) \ 269 - dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \ 270 - }) 257 + dev_no_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__) 271 258 #endif 272 259 273 260 /*