From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751892AbcFXNnK (ORCPT ); Fri, 24 Jun 2016 09:43:10 -0400 Received: from smtprelay0201.hostedemail.com ([216.40.44.201]:46723 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751476AbcFXNnI (ORCPT ); Fri, 24 Jun 2016 09:43:08 -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:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3167:3354:3622:3865:3866:3867:3870:3874:4321:5007:6119:6691:7576:7903:8603:10004:10400:10848:11026:11232:11473:11658:11914:12043:12296:12438:12517:12519:12555:12679:12740:13146:13230:13439:13894:14181:14659:14721:21080:30012:30054:30070:30091,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,LFtime:3,LUA_SUMMARY:none X-HE-Tag: rule77_723e4de18c71a X-Filterd-Recvd-Size: 3269 Message-ID: <1466775784.1847.60.camel@perches.com> Subject: Re: [PATCH 2/3] printk: Make the printk*once() variants return a value From: Joe Perches To: Borislav Petkov , LKML Cc: Andrew Morton , Andy Lutomirski , X86 ML Date: Fri, 24 Jun 2016 06:43:04 -0700 In-Reply-To: <20160624083020.26871-3-bp@alien8.de> References: <20160624083020.26871-1-bp@alien8.de> <20160624083020.26871-3-bp@alien8.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2016-06-24 at 10:30 +0200, Borislav Petkov wrote: > From: Borislav Petkov > > Have printk*once() return a bool which denotes whether the string was > printed or not so that calling code can react accordingly. I expected object size to either increase or stay the same with just this change. Oddly, at least with gcc 5.3, some defconfig x86-64 objects _decrease_ in size. for example: drivers/gpu/drm/i915/intel_opregion.o I presume there's some curiosity in the gcc optimizer with the evaluation of statement expression macros that don't return a value. Perhaps the printk_once macros should end with unlikely(__ret_print_once); like the WARN_ONCE variants. > Signed-off-by: Borislav Petkov > Cc: Andrew Morton > --- >  include/linux/printk.h | 17 ++++++++++++----- >  1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/include/linux/printk.h b/include/linux/printk.h > index f4da695fd615..464fcdddb359 100644 > --- a/include/linux/printk.h > +++ b/include/linux/printk.h > @@ -108,11 +108,14 @@ struct va_format { >   * Dummy printk for disabled debugging statements to use whilst maintaining >   * gcc's format checking. >   */ > -#define no_printk(fmt, ...) \ > -do { \ > - if (0) \ > - printk(fmt, ##__VA_ARGS__); \ > -} while (0) > +#define no_printk(fmt, ...) \ > +({ \ > + do { \ > + if (0) \ > + printk(fmt, ##__VA_ARGS__); \ > + } while (0); \ > + 0; \ > +}) >   >  #ifdef CONFIG_EARLY_PRINTK >  extern asmlinkage __printf(1, 2) > @@ -309,20 +312,24 @@ extern asmlinkage void dump_stack(void) __cold; >  #define printk_once(fmt, ...) \ >  ({ \ >   static bool __print_once __read_mostly; \ > + bool __ret_print_once = !__print_once; \ >   \ >   if (!__print_once) { \ >   __print_once = true; \ >   printk(fmt, ##__VA_ARGS__); \ >   } \ > + __ret_print_once; \ >  }) >  #define printk_deferred_once(fmt, ...) \ >  ({ \ >   static bool __print_once __read_mostly; \ > + bool __ret_print_once = !__print_once; \ >   \ >   if (!__print_once) { \ >   __print_once = true; \ >   printk_deferred(fmt, ##__VA_ARGS__); \ >   } \ > + __ret_print_once; \ >  }) >  #else >  #define printk_once(fmt, ...) \