From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756088AbcJVUHo (ORCPT ); Sat, 22 Oct 2016 16:07:44 -0400 Received: from smtprelay0108.hostedemail.com ([216.40.44.108]:50717 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751816AbcJVUHm (ORCPT ); Sat, 22 Oct 2016 16:07:42 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:960:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3871:3872:4321:5007:6737:7903:8660:10004:10400:10848:11026:11232:11657:11658:11914:12043:12048:12296:12740:12760:13069:13073:13148:13230:13255:13311:13357:13439:14659:14721:21080:21212:21324:21451:30054:30064: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:1,LUA_SUMMARY:none X-HE-Tag: snake37_7cd7882854e36 X-Filterd-Recvd-Size: 2758 Message-ID: <1477166856.3817.4.camel@perches.com> Subject: Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() From: Joe Perches To: SF Markus Elfring , linux-ia64@vger.kernel.org, Al Viro , Borislav Petkov , Fenghua Yu , Greg Kroah-Hartman , Hans-Christian Noren Egtvedt , Ingo Molnar , =?ISO-8859-1?Q?J=F6rg_R=F6del?= , Krzysztof Kozlowski , Robert Richter , Robin Murphy , Tony Luck , Toshi Kani , Vineet Gupta Cc: LKML , kernel-janitors@vger.kernel.org Date: Sat, 22 Oct 2016 13:07:36 -0700 In-Reply-To: References: <8daf03e1-5f6d-fc3b-c2db-397e6d4a9a1c@users.sourceforge.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.0-2ubuntu1 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 Sat, 2016-10-22 at 21:58 +0200, SF Markus Elfring wrote: > Some data were printed into a sequence by two separate function calls. > Print the same data by a single function call instead. [] > diff --git a/arch/ia64/sn/kernel/sn2/sn2_smp.c b/arch/ia64/sn/kernel/sn2/sn2_smp.c [] > @@ -494,12 +494,11 @@ static int sn2_ptc_seq_show(struct seq_file *file, void *data) > int cpu; > > cpu = *(loff_t *) data; > - > - if (!cpu) { > + if (!cpu) > seq_printf(file, > - "# cpu ptc_l newrid ptc_flushes nodes_flushed deadlocks lock_nsec shub_nsec shub_nsec_max not_my_mm deadlock2 ipi_fluches ipi_nsec\n"); > - seq_printf(file, "# ptctest %d, flushopt %d\n", sn2_ptctest, sn2_flush_opt); > - } > + "# cpu ptc_l newrid ptc_flushes nodes_flushed deadlocks lock_nsec shub_nsec shub_nsec_max not_my_mm deadlock2 ipi_fluches ipi_nsec\n" > + "# ptctest %d, flushopt %d\n", > + sn2_ptctest, sn2_flush_opt); > > if (cpu < nr_cpu_ids && cpu_online(cpu)) { > stat = &per_cpu(ptcstats, cpu); Please think more. printf has to inspect character by character looking for a vsprintf % character and 0 termination. seq_puts does a strlen then memcpy. Which is faster? When is it better to call 2 functions? When does readability matter more than efficiency?