From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by kanga.kvack.org (Postfix) with ESMTP id 06D0283099 for ; Thu, 18 Aug 2016 11:23:35 -0400 (EDT) Received: by mail-oi0-f69.google.com with SMTP id p18so52655668oic.0 for ; Thu, 18 Aug 2016 08:23:34 -0700 (PDT) Received: from smtprelay.hostedemail.com (smtprelay0141.hostedemail.com. [216.40.44.141]) by mx.google.com with ESMTPS id j63si76880ith.70.2016.08.18.08.23.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Aug 2016 08:23:33 -0700 (PDT) Message-ID: <1471533810.4319.50.camel@perches.com> Subject: Re: [PATCH] proc, smaps: reduce printing overhead From: Joe Perches Date: Thu, 18 Aug 2016 08:23:30 -0700 In-Reply-To: <20160818145835.GP30162@dhcp22.suse.cz> References: <1471519888-13829-1-git-send-email-mhocko@kernel.org> <1471526765.4319.31.camel@perches.com> <20160818142616.GN30162@dhcp22.suse.cz> <20160818144149.GO30162@dhcp22.suse.cz> <1471531563.4319.41.camel@perches.com> <20160818145835.GP30162@dhcp22.suse.cz> Content-Type: text/plain; charset="ISO-8859-1" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Andrew Morton , linux-mm@kvack.org, LKML , Jann Horn On Thu, 2016-08-18 at 16:58 +0200, Michal Hocko wrote: > On Thu 18-08-16 07:46:03, Joe Perches wrote: > > > > On Thu, 2016-08-18 at 16:41 +0200, Michal Hocko wrote: > > > > > > On Thu 18-08-16 16:26:16, Michal Hocko wrote: > > > > > > > > b) doesn't it try to be overly clever when doing that in the caller > > > > doesn't cost all that much? Sure you can save few bytes in the spaces > > > > but then I would just argue to use \t rather than fixed string length. > > > ohh, I misread the code. It tries to emulate the width formater. But is > > > this really necessary? Do we know about any tools doing a fixed string > > > parsing? > > I don't, but it's proc and all the output formatting > > shouldn't be changed. > > > > Appended to is generally OK, but whitespace changed is > > not good. > OK fair enough, I will > - seq_write(m, s, 16); > + seq_puts(m, s); > > because smaps needs more than 16 chars and export it in > fs/proc/internal.h > > will retest and repost. The shift in the meminfo case uses PAGE_SHIFT too. I suggest you make a local static instead and for that one 17 byte line do seq_printf(m, "Private_Hugetlb: %7lu kB\n", mss.private_hugetlb >> 10); Another possible thing is to speed up all seq_puts uses with fixed chars strings by avoiding the runtime strlen and use the compiler known string length: https://lkml.org/lkml/2016/8/11/607 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754452AbcHSA6Y (ORCPT ); Thu, 18 Aug 2016 20:58:24 -0400 Received: from smtprelay0253.hostedemail.com ([216.40.44.253]:53968 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754416AbcHSA6T (ORCPT ); Thu, 18 Aug 2016 20:58:19 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:967:973:981:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2525:2560:2563:2682:2685:2693:2740:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:5007:6119:7903:9025:10004:10400:10848:11232:11658:11783:11914:12043:12296:12517:12519:12740:13069:13161:13229:13311:13357:13439:13845:13894:14181:14659:14721:21080:21434:30012:30054: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:2,LUA_SUMMARY:none X-HE-Tag: night54_761a578358109 X-Filterd-Recvd-Size: 2453 Message-ID: <1471533810.4319.50.camel@perches.com> Subject: Re: [PATCH] proc, smaps: reduce printing overhead From: Joe Perches To: Michal Hocko Cc: Andrew Morton , linux-mm@kvack.org, LKML , Jann Horn Date: Thu, 18 Aug 2016 08:23:30 -0700 In-Reply-To: <20160818145835.GP30162@dhcp22.suse.cz> References: <1471519888-13829-1-git-send-email-mhocko@kernel.org> <1471526765.4319.31.camel@perches.com> <20160818142616.GN30162@dhcp22.suse.cz> <20160818144149.GO30162@dhcp22.suse.cz> <1471531563.4319.41.camel@perches.com> <20160818145835.GP30162@dhcp22.suse.cz> 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 Thu, 2016-08-18 at 16:58 +0200, Michal Hocko wrote: > On Thu 18-08-16 07:46:03, Joe Perches wrote: > > > > On Thu, 2016-08-18 at 16:41 +0200, Michal Hocko wrote: > > > > > > On Thu 18-08-16 16:26:16, Michal Hocko wrote: > > > > > > > > b) doesn't it try to be overly clever when doing that in the caller > > > > doesn't cost all that much? Sure you can save few bytes in the spaces > > > > but then I would just argue to use \t rather than fixed string length. > > > ohh, I misread the code. It tries to emulate the width formater. But is > > > this really necessary? Do we know about any tools doing a fixed string > > > parsing? > > I don't, but it's proc and all the output formatting > > shouldn't be changed. > > > > Appended to is generally OK, but whitespace changed is > > not good. > OK fair enough, I will > -       seq_write(m, s, 16); > +       seq_puts(m, s); > > because smaps needs more than 16 chars and export it in > fs/proc/internal.h > > will retest and repost. The shift in the meminfo case uses PAGE_SHIFT too. I suggest you make a local static instead and for that one 17 byte line do seq_printf(m, "Private_Hugetlb: %7lu kB\n",  mss.private_hugetlb >> 10); Another possible thing is to speed up all seq_puts uses with fixed chars strings by avoiding the runtime strlen and use the compiler known string length: https://lkml.org/lkml/2016/8/11/607