public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Resurrect old pr_debug() semantics as pr_devel()
@ 2009-04-06  4:30 Michael Ellerman
  2009-04-06 21:24 ` Jason Baron
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2009-04-06  4:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, gnb, jbaron

pr_debug() used to produce zero code unless DEBUG was #defined. This is
now no longer the case in practice[1].

There are places where it's useful to have debugging printks, but we
don't want them to generate any code in production kernels.

So add a new macro, pr_devel(), for _devel_opment, to provide the old
semantics, ie. if the programmer doesn't explicitly enable debugging,
no code is produced.

[1]: You can turn CONFIG_DYNAMIC_DEBUG off, but it's enabled in at least
     one distro kernel, so it's not really a solution.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 include/linux/kernel.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d9e75ec..883cd44 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -377,6 +377,15 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
 #define pr_cont(fmt, ...) \
 	printk(KERN_CONT fmt, ##__VA_ARGS__)
 
+/* pr_devel() should produce zero code unless DEBUG is defined */
+#ifdef DEBUG
+#define pr_devel(fmt, ...) \
+	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_devel(fmt, ...) \
+	({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#endif
+
 /* If you are writing a driver, please use dev_dbg instead */
 #if defined(DEBUG)
 #define pr_debug(fmt, ...) \
-- 
1.6.1.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Resurrect old pr_debug() semantics as pr_devel()
  2009-04-06  4:30 [PATCH] Resurrect old pr_debug() semantics as pr_devel() Michael Ellerman
@ 2009-04-06 21:24 ` Jason Baron
  2009-04-07  2:08   ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Baron @ 2009-04-06 21:24 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linux-kernel, Andrew Morton, gnb

On Mon, Apr 06, 2009 at 02:30:03PM +1000, Michael Ellerman wrote:
> pr_debug() used to produce zero code unless DEBUG was #defined. This is
> now no longer the case in practice[1].
> 
> There are places where it's useful to have debugging printks, but we
> don't want them to generate any code in production kernels.
> 
> So add a new macro, pr_devel(), for _devel_opment, to provide the old
> semantics, ie. if the programmer doesn't explicitly enable debugging,
> no code is produced.
> 
> [1]: You can turn CONFIG_DYNAMIC_DEBUG off, but it's enabled in at least
>      one distro kernel, so it's not really a solution.
> 

hmm...its designed to have low overhead when CONFIG_DYNAMIC_DEBUG
is on, but none of the debugging printks are enabled. Is there a
specific benchmark or test case that is unaccpetable?

thanks,

-Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Resurrect old pr_debug() semantics as pr_devel()
  2009-04-06 21:24 ` Jason Baron
@ 2009-04-07  2:08   ` Michael Ellerman
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2009-04-07  2:08 UTC (permalink / raw)
  To: Jason Baron; +Cc: linux-kernel, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]

On Mon, 2009-04-06 at 17:24 -0400, Jason Baron wrote:
> On Mon, Apr 06, 2009 at 02:30:03PM +1000, Michael Ellerman wrote:
> > pr_debug() used to produce zero code unless DEBUG was #defined. This is
> > now no longer the case in practice[1].
> > 
> > There are places where it's useful to have debugging printks, but we
> > don't want them to generate any code in production kernels.
> > 
> > So add a new macro, pr_devel(), for _devel_opment, to provide the old
> > semantics, ie. if the programmer doesn't explicitly enable debugging,
> > no code is produced.
> > 
> > [1]: You can turn CONFIG_DYNAMIC_DEBUG off, but it's enabled in at least
> >      one distro kernel, so it's not really a solution.
> > 
> 
> hmm...its designed to have low overhead when CONFIG_DYNAMIC_DEBUG
> is on, but none of the debugging printks are enabled. 

Sure, it does that fairly well, and there are places where it's a good
trade off to have the debug available at the cost of a bit more code.

> Is there a specific benchmark or test case that is unaccpetable?

Yes. Compiling with DYNAMIC_DEBUG=y generates a non-zero amount of code
for each pr_debug(), and in some places that is unacceptable.  :)

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-04-07  2:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-06  4:30 [PATCH] Resurrect old pr_debug() semantics as pr_devel() Michael Ellerman
2009-04-06 21:24 ` Jason Baron
2009-04-07  2:08   ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox