* [PATCH] kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...)
@ 2009-10-14 2:56 Joe Perches
2009-10-14 3:34 ` David Rientjes
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2009-10-14 2:56 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML
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.
Signed-off-by: Joe Perches <joe@perches.com>
include/linux/kernel.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f4e3184..2ad0396 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -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__)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...)
2009-10-14 2:56 [PATCH] kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...) Joe Perches
@ 2009-10-14 3:34 ` David Rientjes
2009-10-14 4:21 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2009-10-14 3:34 UTC (permalink / raw)
To: Joe Perches; +Cc: Andrew Morton, LKML
On Tue, 13 Oct 2009, Joe Perches wrote:
> 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.
>
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)).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...)
2009-10-14 3:34 ` David Rientjes
@ 2009-10-14 4:21 ` Joe Perches
2009-10-14 4:28 ` David Rientjes
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2009-10-14 4:21 UTC (permalink / raw)
To: David Rientjes; +Cc: Andrew Morton, LKML
On Tue, 2009-10-13 at 20:34 -0700, David Rientjes wrote:
> On Tue, 13 Oct 2009, Joe Perches wrote:
> > 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.
> 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.
> 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.
> I'd suggest pr_debug_force(), even though it's much longer (although still
> shorter than printk(KERN_DEBUG)).
pr_dbg allows longer format strings without exceeding 80 chars.
printk(KERN_DEBUG
pr_debug_force
pr_dbg_always
pr_dbg_noopt
Other suggestions?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...)
2009-10-14 4:21 ` Joe Perches
@ 2009-10-14 4:28 ` David Rientjes
2009-10-14 4:44 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2009-10-14 4:28 UTC (permalink / raw)
To: Joe Perches; +Cc: Andrew Morton, linux-kernel
On Tue, 13 Oct 2009, Joe Perches wrote:
> > 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.
> > I'd suggest pr_debug_force(), even though it's much longer (although still
> > shorter than printk(KERN_DEBUG)).
>
> pr_dbg allows longer format strings without exceeding 80 chars.
>
> printk(KERN_DEBUG
> pr_debug_force
> pr_dbg_always
> pr_dbg_noopt
>
> Other 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).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...)
2009-10-14 4:28 ` David Rientjes
@ 2009-10-14 4:44 ` Joe Perches
0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2009-10-14 4:44 UTC (permalink / raw)
To: David Rientjes; +Cc: Andrew Morton, linux-kernel
On Tue, 2009-10-13 at 21:28 -0700, David Rientjes wrote:
> The pr_dbg_* variations seem reasonable if the current pr_debug() were
> changed to pr_dbg().
I think that's unlikely to happen.
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-10-14 4:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-14 2:56 [PATCH] kernel.h: Add a never optimized away pr_dbg for printk(KERN_DEBUG pr_fmt(fmt)...) Joe Perches
2009-10-14 3:34 ` David Rientjes
2009-10-14 4:21 ` Joe Perches
2009-10-14 4:28 ` David Rientjes
2009-10-14 4:44 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®