From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756000AbbHYU43 (ORCPT ); Tue, 25 Aug 2015 16:56:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36545 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751315AbbHYU42 (ORCPT ); Tue, 25 Aug 2015 16:56:28 -0400 Date: Tue, 25 Aug 2015 13:56:27 -0700 From: Andrew Morton To: Joe Perches Cc: David Howells , James Morris , LKML , Julia Lawall Subject: Re: [PATCH] cred: Remove unnecessary kdebug atomic reads Message-Id: <20150825135627.0b842b18ae9cc0045cad580f@linux-foundation.org> In-Reply-To: <1440535866.2670.164.camel@perches.com> References: <1440521631.2670.100.camel@perches.com> <20150825133925.654019415dbe3d2083e5f8c7@linux-foundation.org> <1440535866.2670.164.camel@perches.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Aug 2015 13:51:06 -0700 Joe Perches wrote: > On Tue, 2015-08-25 at 13:39 -0700, Andrew Morton wrote: > > On Tue, 25 Aug 2015 09:53:51 -0700 Joe Perches 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. 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 #define kdebug(FMT, ...) \ __kdebug(...)