From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932530AbbHYVKI (ORCPT ); Tue, 25 Aug 2015 17:10:08 -0400 Received: from smtprelay0111.hostedemail.com ([216.40.44.111]:42560 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755424AbbHYVKG (ORCPT ); Tue, 25 Aug 2015 17:10:06 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:5007:6119:6261:6691:7903:8660:10004:10400:10450:10455:10848:10967:11026:11232:11658:11914:12296:12517:12519:12555:12700:12737:12740:13148:13230:14096:14097:19904:19999:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: moon05_a0879beaa4a X-Filterd-Recvd-Size: 3245 Message-ID: <1440537003.2670.169.camel@perches.com> Subject: Re: [PATCH] cred: Remove unnecessary kdebug atomic reads From: Joe Perches To: Andrew Morton Cc: David Howells , James Morris , LKML , Julia Lawall Date: Tue, 25 Aug 2015 14:10:03 -0700 In-Reply-To: <20150825135627.0b842b18ae9cc0045cad580f@linux-foundation.org> References: <1440521631.2670.100.camel@perches.com> <20150825133925.654019415dbe3d2083e5f8c7@linux-foundation.org> <1440535866.2670.164.camel@perches.com> <20150825135627.0b842b18ae9cc0045cad580f@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2015-08-25 at 13:56 -0700, Andrew Morton wrote: > 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. 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