Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7528065imm; Tue, 28 Aug 2018 13:50:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYZndm1V0RRAVVaId9Fh7zGW1ArySTluGkulrfwpNKZ9SDy7wtAIo2eTJRkVTUxXd5A68O8 X-Received: by 2002:a62:1815:: with SMTP id 21-v6mr3000015pfy.227.1535489447470; Tue, 28 Aug 2018 13:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535489447; cv=none; d=google.com; s=arc-20160816; b=mYHsnJt53aHk/HLETlpMvBNfE7QJMKzITtkKcZPeURX3ZFyx5Ngj8zm/vLXNW+1oc0 dqcWesFlcZOaUqcTCXodNDrLEhGi3NSVYtKy7pTC/S9qgD2aQFBOvzUq1nsjfpAcDVou RbZNUNiLVvDgc3qnjB2FJA23Wsr9lyCnsWz5BkRb8abC4RAR+43o9PcKxH6d2i7azRxD yVFHvug2JRSbER8bD7Zqe71cQAuyyv9ungKJ5MGYXHolP7s9gVP3inmiHfmlnRn6njfZ UU/2I4lw81YKK4eIkN4G5GnOj0YO+CBDHLcqPCzmzj7MvMS8/CLhhOXCjk29JtNxbbtZ +Btw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=enUdOZlA4lVU1pQvisKGDzuhuAvXA96ZNTj5JHvECVE=; b=mQ2Nvvl9ulcQsAXnngvAQWafdVapaWqu9X4z0FyIZwcBpYe9bR8gY1Fr7VoPx/8gBi oYc3l1X7iUQ1fpVo39+L5S4I4VsM02XLa0FaqzzIlh6w4fnkao0uJJPn6T22cCiDfeMR X0t+1mvXbNXD7l7dTagykgECvoXMJicmtgW1cmzljlgE2zdI7szTIAIfG+Cgvbv2gWnu L27R+3cuFtWXm/FYe+WzcYfN923TdsAXPqjNLZ3DJGyiRWjj1lo/PZrADS6DOt9fIV6O zYm3bI8WIgXAHY4nJu1fdhckHnhmHB01xa9lYG/td+rMEwnqpZzNcPVTc/20crB5j2ac zYFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a186-v6si1795087pge.408.2018.08.28.13.50.31; Tue, 28 Aug 2018 13:50:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727607AbeH2AmD (ORCPT + 99 others); Tue, 28 Aug 2018 20:42:03 -0400 Received: from smtprelay0224.hostedemail.com ([216.40.44.224]:47691 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727162AbeH2AmC (ORCPT ); Tue, 28 Aug 2018 20:42:02 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 7EC0618225657; Tue, 28 Aug 2018 20:48:39 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:69:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2740:2828:3138:3139:3140:3141:3142:3354:3622:3653:3865:3866:3868:3871:4321:4605:5007:6119:7514:7903:8603:9040:9592:10004:10400:10848:11026:11232:11658:11914:12043:12296:12438:12555:12679:12740:12760:12895:12986:13184:13229:13439:14096:14097:14181:14659:14721:21080:21433:21451:21611:21627:30034:30054:30090:30091,0,RBL:172.56.41.215:@perches.com:.lbl8.mailshell.net-62.8.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:32,LUA_SUMMARY:none X-HE-Tag: grain87_2e4ba5c233342 X-Filterd-Recvd-Size: 3673 Received: from XPS-9350 (unknown [172.56.41.215]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Tue, 28 Aug 2018 20:48:37 +0000 (UTC) Message-ID: <556a35cbccc36ef4f5a03a82e6f938d283046919.camel@perches.com> Subject: Re: [PATCH 01/13] seq_file: rewrite seq_puts() in terms of seq_write() From: Joe Perches To: Alexey Dobriyan , akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org Date: Tue, 28 Aug 2018 13:48:35 -0700 In-Reply-To: <9229927125ab9d36bd38cf0c20fb5dfb45802fcb.camel@perches.com> References: <20180827231503.26899-1-adobriyan@gmail.com> <9229927125ab9d36bd38cf0c20fb5dfb45802fcb.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-08-28 at 11:24 -0700, Joe Perches wrote: > On Tue, 2018-08-28 at 02:14 +0300, Alexey Dobriyan wrote: > > Space savings -- 42 bytes! > > > > seq_puts 71 29 [-42] > > > > Signed-off-by: Alexey Dobriyan > > --- > > fs/seq_file.c | 9 +-------- > > 1 file changed, 1 insertion(+), 8 deletions(-) > > > > diff --git a/fs/seq_file.c b/fs/seq_file.c > > index 1dea7a8a5255..0c282a88a896 100644 > > --- a/fs/seq_file.c > > +++ b/fs/seq_file.c > > @@ -653,14 +653,7 @@ EXPORT_SYMBOL(seq_putc); > > > > void seq_puts(struct seq_file *m, const char *s) > > { > > - int len = strlen(s); > > - > > - if (m->count + len >= m->size) { > > - seq_set_overflow(m); > > - return; > > - } > > - memcpy(m->buf + m->count, s, len); > > - m->count += len; > > + seq_write(m, s, strlen(s)); > > } > > EXPORT_SYMBOL(seq_puts); > > > > If execution speed is really an issue, as > almost all of the uses are for const strings, > why not use a #define and avoid the runtime > cost of strlen where possible. fyi: an x86-64 defconfig increases < .5 kb and presumably is faster for most all seq_puts uses $ size vmlinux.new vmlinux.old text data bss dec hex filename 17342316 4982128 999628 23324072 163e5a8 vmlinux.new 17341857 4982128 999628 23323613 163e3dd vmlinux.old with --- fs/seq_file.c | 13 ------------- include/linux/seq_file.h | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index 1dea7a8a5255..97d474b6788e 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -651,19 +651,6 @@ void seq_putc(struct seq_file *m, char c) } EXPORT_SYMBOL(seq_putc); -void seq_puts(struct seq_file *m, const char *s) -{ - int len = strlen(s); - - if (m->count + len >= m->size) { - seq_set_overflow(m); - return; - } - memcpy(m->buf + m->count, s, len); - m->count += len; -} -EXPORT_SYMBOL(seq_puts); - /** * A helper routine for putting decimal numbers without rich format of printf(). * only 'unsigned long long' is supported. diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index a121982af0f5..722028805df6 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -117,7 +117,7 @@ void seq_vprintf(struct seq_file *m, const char *fmt, va_list args); __printf(2, 3) void seq_printf(struct seq_file *m, const char *fmt, ...); void seq_putc(struct seq_file *m, char c); -void seq_puts(struct seq_file *m, const char *s); +#define seq_puts(m, s) seq_write(m, s, strlen(s)) void seq_put_decimal_ull_width(struct seq_file *m, const char *delimiter, unsigned long long num, unsigned int width); void seq_put_decimal_ull(struct seq_file *m, const char *delimiter,