From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753954AbdCBF67 (ORCPT ); Thu, 2 Mar 2017 00:58:59 -0500 Received: from smtprelay0130.hostedemail.com ([216.40.44.130]:49652 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750771AbdCBF66 (ORCPT ); Thu, 2 Mar 2017 00:58:58 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 30,2,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:960:967:973:981: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:2525:2553:2560:2563:2682:2685:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3622:3865:3867:3868:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4605:5007:6119:6120:7903:8603:8660:8828:8985:9025:10010:10400:10450:10455:10848:11026:11232:11658:11854:11914:12043:12296:12438:12555:12663:12740:12760:12895:12986:13148:13230:13439:14180:14181:14659:14721:19904:19999:21080:21433:21451:30054:30090: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:1:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: music46_30d53c6b34814 X-Filterd-Recvd-Size: 3299 Message-ID: <1488434334.2179.1.camel@perches.com> Subject: Re: [RFC PATCH] printk: Make functions of pr_ macros From: Joe Perches To: Sergey Senozhatsky Cc: Petr Mladek , Steven Rostedt , linux-kernel@vger.kernel.org, Sergey Senozhatsky Date: Wed, 01 Mar 2017 21:58:54 -0800 In-Reply-To: <20170302053509.GA398@jagdpanzerIV.localdomain> References: <20170302053509.GA398@jagdpanzerIV.localdomain> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.3-0ubuntu0.1 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 Thu, 2017-03-02 at 14:35 +0900, Sergey Senozhatsky wrote: > Hello Joe, > > On (02/28/17 19:17), Joe Perches wrote: > > Can save the space that the KERN_ headers require. > > > > The biggest negative here is the %pV use which needs > > recursion and adds stack depth. > > > > $ size vmlinux.o* (defconfig, x86-64) > > text data bss dec hex filename > > 12586135 1909841 777528 15273504 e90e20 vmlinux.o.new > > 12590348 1909841 777528 15277717 e91e95 vmlinux.o.old > > interesting. 4K. Yeah, more when more calls are converted, Maybe more like 12k, still the goal is to create singletons for the pr_fmt prefixes and whatever __func__ uses that are most common via a SOH + flag and using __builtin_return_address where possible and appropriate. That could shrink another 10k or so. > [..] > > +#define define_pr_func(func, level) \ > > +asmlinkage __visible int func(const char *fmt, ...) \ > > +{ \ > > + va_list args; \ > > + int r; \ > > + struct va_format vaf; \ > > + \ > > + va_start(args, fmt); \ > > + vaf.fmt = fmt; \ > > + vaf.va = &args; \ > > + \ > > + r = printk(level "%pV", &vaf); \ > > + \ > > + va_end(args); \ > > + \ > > + return r; \ > > +} \ > > hm. that's really hacky (which is a compliment) and a bit complicated. > my quick thought was to tweak vprintk_emit() for 'facility != 0' so it > could get loglevel (and adjust lflags) from the passed level, not from > the text, and then do something like this > #define define_pr_func(func, level) asmlinkage __visible int func(const char *fmt, ...) > { > va_start(args, fmt); > r = vprintk_emit(level[0], level[1], NULL, 0, fmt, args); > va_end(); > } > > but this won't do the trick. because func()->vprintk_emit() shortcut > disables the printk-safe mechanism: > func()->printk()->vprintk_func()->this_cpu(printk_context)::print() That was what I had done originally a while ago https://lkml.org/lkml/2016/6/23/652 Now the with "safe" version, it's a bit more complicated. [stack depth can be high, ~400 bytes per recursion] > dunno, at the moment I'm not really comfortable with %pV recursion > for every pr_foo() call Me neither really. I'd much prefer a direct vprintk_emit.