Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1506599

Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show()

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show()
Date 2016-10-22 22:10 +0200
Message-ID <svaMa-824-7@gated-at.bofh.it> (permalink)
References <svaCt-7IO-3@gated-at.bofh.it> <svaCu-7IO-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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?

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] IA64: Fine-tuning for five function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-22 22:00 +0200
  [PATCH 4/6] IA64-setup: Use seq_putc() in show_cpuinfo() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-22 22:00 +0200
  [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one  call in sn2_ptc_seq_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-22 22:00 +0200
    Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into  one call in sn2_ptc_seq_show() Joe Perches <joe@perches.com> - 2016-10-22 22:10 +0200
      Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one  call in sn2_ptc_seq_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-22 22:50 +0200
        Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into  one call in sn2_ptc_seq_show() Julia Lawall <julia.lawall@lip6.fr> - 2016-10-23 07:50 +0200
          Re: IA64-sn2_smp: Combine two seq_printf() calls into one call in  sn2_ptc_seq_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-23 08:40 +0200
  [PATCH 3/6] IA64-simserial: Use seq_puts() in rs_proc_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-22 22:00 +0200

csiph-web