From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751390AbcFVWUs (ORCPT ); Wed, 22 Jun 2016 18:20:48 -0400 Received: from smtprelay0057.hostedemail.com ([216.40.44.57]:59786 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750740AbcFVWUq (ORCPT ); Wed, 22 Jun 2016 18:20:46 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:2892:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3870:3871:3873:3874:4321:5007:7808:8603:8660:8828:10004:10400:10848:11026:11232:11658:11783:11914:12043:12296:12438:12517:12519:12740:13069:13071:13148:13161:13229:13230:13311:13357:13439:13894:14180:14659:14721:21080:21433:21434,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:1,LUA_SUMMARY:none X-HE-Tag: rat12_673fa3ca995d X-Filterd-Recvd-Size: 2458 Message-ID: <1466634043.13093.15.camel@perches.com> Subject: Re: [PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% From: Joe Perches To: Jason Gunthorpe Cc: Matan Barak , Leon Romanovsky , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel Date: Wed, 22 Jun 2016 15:20:43 -0700 In-Reply-To: <20160622204056.GB20838@obsidianresearch.com> References: <1466619839.13093.4.camel@perches.com> <20160622204056.GB20838@obsidianresearch.com> 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 Wed, 2016-06-22 at 14:40 -0600, Jason Gunthorpe wrote: > On Wed, Jun 22, 2016 at 11:23:59AM -0700, Joe Perches wrote: > > The output changes now do not include line #, but do include the > > function offset. > I've been using a technique like this in some code with good results: > > struct source_location > { >    const char *file; >    const char *func; >    const char *format; >    uint16_t line; > }; > #define _LOCATION(format) ({static const source_location __location__ > = {\ >              __FILE__,__PRETTY_FUNCTION__,format,__LINE__};\ >      &__location__;}) > > void _mlx5_core_err(const struct source_location *loc,struct > mlx5_core_dev *dev, ...); > #define mlx5_core_err(dev,format,...) > _mlx_core_err(_LOCATION(format),dev,__VA_ARGS__) > > The call site .text overhead is the about same as what you have, but > this still retains the function and line number information in > .rodata. Hello Jason. As far as I know, no kernel code currently uses a _LOCATION like macro. I think your proposal is nearly identical code size to the existing call.  Also, compiler format/argument checking is eliminated and I think that is a significant negative. Using the kernel vsprintf %pS or %ps extension is pretty common. Using printk("%pS", __builtin_return_address(0)); in the called function is no overhead at all and returns almost exactly the same information. Using more expressive messages is generally better than using printk("%d", __LINE__);