public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
	linux-ia64@vger.kernel.org, "Al Viro" <viro@zeniv.linux.org.uk>,
	"Borislav Petkov" <bp@suse.de>,
	"Fenghua Yu" <fenghua.yu@intel.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Hans-Christian Noren Egtvedt" <egtvedt@samfundet.no>,
	"Ingo Molnar" <mingo@kernel.org>, "Jörg Rödel" <jroedel@suse.de>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Robert Richter" <rrichter@cavium.com>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Tony Luck" <tony.luck@intel.com>,
	"Toshi Kani" <toshi.kani@hpe.com>,
	"Vineet Gupta" <vgupta@synopsys.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show()
Date: Sat, 22 Oct 2016 20:07:36 +0000	[thread overview]
Message-ID: <1477166856.3817.4.camel@perches.com> (raw)
In-Reply-To: <c3e12189-6122-e806-6cb2-b2518e64e983@users.sourceforge.net>

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?

  reply	other threads:[~2016-10-22 20:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-22 19:50 [PATCH 0/6] IA64: Fine-tuning for five function implementations SF Markus Elfring
2016-10-22 19:53 ` [PATCH 1/6] IA64-sba_iommu: Use seq_puts() in ioc_show() SF Markus Elfring
2016-10-22 19:54 ` [PATCH 2/6] IA64-sba_iommu: Combine four seq_printf() calls into two calls " SF Markus Elfring
2016-10-22 19:55 ` [PATCH 3/6] IA64-simserial: Use seq_puts() in rs_proc_show() SF Markus Elfring
2016-10-22 19:56 ` [PATCH 4/6] IA64-setup: Use seq_putc() in show_cpuinfo() SF Markus Elfring
2016-10-22 19:57 ` [PATCH 5/6] IA64-sn_hwperf: Use seq_puts() in sn_topology_show() SF Markus Elfring
2016-10-22 19:58 ` [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() SF Markus Elfring
2016-10-22 20:07   ` Joe Perches [this message]
2016-10-22 20:48     ` SF Markus Elfring
2016-10-23  5:42       ` Julia Lawall
2016-10-23  6:33         ` SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477166856.3817.4.camel@perches.com \
    --to=joe@perches.com \
    --cc=bp@suse.de \
    --cc=egtvedt@samfundet.no \
    --cc=elfring@users.sourceforge.net \
    --cc=fenghua.yu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jroedel@suse.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rrichter@cavium.com \
    --cc=tony.luck@intel.com \
    --cc=toshi.kani@hpe.com \
    --cc=vgupta@synopsys.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox