From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933016AbbHYUja (ORCPT ); Tue, 25 Aug 2015 16:39:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35682 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbbHYUj0 (ORCPT ); Tue, 25 Aug 2015 16:39:26 -0400 Date: Tue, 25 Aug 2015 13:39:25 -0700 From: Andrew Morton To: Joe Perches Cc: David Howells , James Morris , LKML Subject: Re: [PATCH] cred: Remove unnecessary kdebug atomic reads Message-Id: <20150825133925.654019415dbe3d2083e5f8c7@linux-foundation.org> In-Reply-To: <1440521631.2670.100.camel@perches.com> References: <1440521631.2670.100.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 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. > > $ 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 > > #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.