kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...)
PATCH 1/1 kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...)
Many developers use a logging message that is printed at KERN_DEBUG level that is always printed regardless of #define DEBUG levels.
pr_debug can be optimized away to a null statement.
Add a pr_dbg message that prints at KERN_DEBUG level that uses pr_fmt() that can not be optimized to nothing.
include/linux/kernel.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/kernel.h +0 -0
@@ -380,6 +380,8 @@ static inline char *pack_hex_byte(char *buf, u8
byte)
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, ...) \
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)+#define pr_dbg(fmt, ...) \
+ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_cont(fmt, ...) \
printk(KERN_CONT fmt, ##__VA_ARGS__)
Quoted 10 lines · Joe Perches
Many developers use a logging message that is printed at
KERN_DEBUGlevel that is always printed regardless of #define DEBUG levels.
pr_debugcan be optimized away to a null statement.Add a
pr_dbgmessage that prints atKERN_DEBUGlevel that usespr_fmt()that can not be optimized to nothing.
pr_dbg() is horribly misnamed, it doesn't indicate why it exists vs. pr_debug() at all. Future users will undoubtedly use it by mistake when they only really mean for the message to be emitted on DEBUG because they've seen it in other places and haven't checked the implementation.
I'd suggest pr_debug_force(), even though it's much longer (although still shorter than printk(KERN_DEBUG)).
Quoted 10 lines · David Rientjes
Quoted 7 lines · Joe Perches
Many developers use a logging message that is printed at
KERN_DEBUGlevel that is always printed regardless of #define DEBUG levels.pr_debugcan be optimized away to a null statement. Add apr_dbgmessage that prints atKERN_DEBUGlevel that usespr_fmt()that can not be optimized to nothing.
pr_dbg()is horribly misnamed, it doesn't indicate why it exists vs.pr_debug()at all.
Partially true, it's reasonably named because it's very short.
Quoted 3 lines
Future users will undoubtedly use it by mistake when
they only really mean for the message to be emitted on DEBUG because they've seen it in other places and haven't checked the implementation.
The cost of using pr_dbg instead of pr_debug isn't high.
The primary benefit is getting an automatic pr_fmt and shorter code.
Quoted 2 lines
I'd suggest
pr_debug_force(), even though it's much longer (although still shorter thanprintk(KERN_DEBUG)).
pr_dbg allows longer format strings without exceeding 80 chars.
printk(KERN_DEBUGpr_debug_forcepr_dbg_alwayspr_dbg_noopt
Other suggestions?
Quoted 5 lines · Joe Perches
Quoted 2 lines
pr_dbg()is horribly misnamed, it doesn't indicate why it exists vs.pr_debug()at all.Partially true, it's reasonably named because it's very short.
It doesn't really matter how long it is if it doesn't accurately describe what it does.
Quoted 12 lines
Quoted 2 lines
I'd suggest
pr_debug_force(), even though it's much longer (although still shorter thanprintk(KERN_DEBUG)).
pr_dbgallows longer format strings without exceeding 80 chars.printk(KERN_DEBUG
pr_debug_forcepr_dbg_alwayspr_dbg_nooptOther suggestions?
The pr_dbg_* variations seem reasonable if the current pr_debug() were changed to pr_dbg().
I suggest converting some mainline code to use whatever you end up calling the !DEBUG variant, though, because this discussion is irrelevant if there are no current use cases (in which case the patch is pointless).
Quoted 2 lines · David Rientjes
The pr_dbg_* variations seem reasonable if the current
pr_debug()were changed topr_dbg().
I think that's unlikely to happen.
Quoted 2 lines
this discussion is irrelevant if there
are no current use cases (in which case the patch is pointless).
Yeah, right. It's alway irrelevant to add new
facilities when where are no current use cases.
I sent a 21 deep patchset over a week ago.
http://lkml.org/lkml/2009/10/4/198