public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Howells <dhowells@redhat.com>,
	James Morris <jmorris@namei.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH] cred: Remove unnecessary kdebug atomic reads
Date: Tue, 25 Aug 2015 14:10:03 -0700	[thread overview]
Message-ID: <1440537003.2670.169.camel@perches.com> (raw)
In-Reply-To: <20150825135627.0b842b18ae9cc0045cad580f@linux-foundation.org>

On Tue, 2015-08-25 at 13:56 -0700, Andrew Morton wrote:
> On Tue, 25 Aug 2015 13:51:06 -0700 Joe Perches <joe@perches.com> wrote:
> 
> > On Tue, 2015-08-25 at 13:39 -0700, Andrew Morton wrote:
> > > 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.
> > []
> > > Did you consider doing this within no_printk()?
> > 
> > Yes.
> > 
> > > 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.
> > 
> > I'll bet you there is more than a little and I don't want to
> > experiment with it unconditionally.
> > 
> > All printks would need to be evaluated for that side-effect.
> > 
> > Safer would be to create a new no_eval_printk macro and convert
> > the no_printk uses over to that as appropriate and possibly create
> > a CONFIG_ option to use no_eval_printk instead of no_printk/printk
> > and let the adventurous find the side-effects.
> > 
> > Maybe a coccinelle script can be written to find all the locations
> > with evaluated non-constant expression arguments with side-effects.
> 
> wimp.

twice shy...

Coccinelle isn't very good at calling tree analysis, so it'd
be a difficult thing for it to do well anyway.

btw; I seems to recall suggestions around the same thing when
no_printk was moved from subsystems to kernel.h by David Howells
in 2010.

> That duplicated printk in cred.c is nasty.  We could do this?
> 
> #if 0
> #define __kdebug printk
> #else
> #define __kdebug if (0) no_printk
> #endif

You could, but what's there is a very common idiom and what
you suggest is unsafe for if/else



  reply	other threads:[~2015-08-25 21:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 16:53 [PATCH] cred: Remove unnecessary kdebug atomic reads Joe Perches
2015-08-25 20:39 ` Andrew Morton
2015-08-25 20:51   ` Joe Perches
2015-08-25 20:56     ` Andrew Morton
2015-08-25 21:10       ` Joe Perches [this message]
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=1440537003.2670.169.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=julia.lawall@lip6.fr \
    --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