mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: David Howells <dhowells@redhat.com>,
	James Morris <jmorris@namei.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cred: Remove unnecessary kdebug atomic reads
Date: Tue, 25 Aug 2015 13:39:25 -0700	[thread overview]
Message-ID: <20150825133925.654019415dbe3d2083e5f8c7@linux-foundation.org> (raw)
In-Reply-To: <1440521631.2670.100.camel@perches.com>

On Tue, 25 Aug 2015 09:53:51 -0700 Joe Perches <joe@perches.com> wrote:

> commit e0e817392b9a ("CRED: Add some configurable debugging [try #6]")
> added the kdebug mechanism to this file back in 2009.
> 
> The kdebug macro calls no_printk which always evaluates arguments.
> 
> Most of the kdebug uses have an unnecessary call of
> 	atomic_read(&cred->usage)
> 
> Make the kdebug macro do nothing by defining it with
> 	do { if (0) no_printk(...); } while (0)
> when not enabled.
> 
> $ size kernel/cred.o* (defconfig x86-64)
>    text	   data	    bss	    dec	    hex	filename
>    2748	    336	      8	   3092	    c14	kernel/cred.o.new
>    2788	    336	      8	   3132	    c3c	kernel/cred.o.old
> 
> Miscellanea:
> o Neaten the #define kdebug macros while there
> 
> ...
>
> --- a/kernel/cred.c
> +++ b/kernel/cred.c
> @@ -20,11 +20,16 @@
>  #include <linux/cn_proc.h>
>  
>  #if 0
> -#define kdebug(FMT, ...) \
> -	printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
> +#define kdebug(FMT, ...)						\
> +	printk("[%-5.5s%5u] " FMT "\n",					\
> +	       current->comm, current->pid, ##__VA_ARGS__)
>  #else
> -#define kdebug(FMT, ...) \
> -	no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__)
> +#define kdebug(FMT, ...)						\
> +do {									\
> +	if (0)								\
> +		no_printk("[%-5.5s%5u] " FMT "\n",			\
> +			  current->comm, current->pid, ##__VA_ARGS__);	\
> +} while (0)
>  #endif
>  
>  static struct kmem_cache *cred_jar;

Did you consider doing this within no_printk()?  That would break code
which is relying on side-effects in the evaluation of a printk arg but
that's pretty weird and I bet there isn't (and won't be) such code.


  reply	other threads:[~2015-08-25 20:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 16:53 Joe Perches
2015-08-25 20:39 ` Andrew Morton [this message]
2015-08-25 20:51   ` Joe Perches
2015-08-25 20:56     ` Andrew Morton
2015-08-25 21:10       ` Joe Perches
2015-08-25 23:30 ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150825133925.654019415dbe3d2083e5f8c7@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®