Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1506595 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2016-10-22 22:00 +0200 |
| Last post | 2016-10-22 22:00 +0200 |
| Articles | 8 — 3 participants |
Back to article view | Back to linux.kernel
[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
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-22 22:00 +0200 |
| Subject | [PATCH 0/6] IA64: Fine-tuning for five function implementations |
| Message-ID | <svaCt-7IO-3@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sat, 22 Oct 2016 21:27:32 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (6): sba_iommu: Use seq_puts() in ioc_show() sba_iommu: Combine four seq_printf() calls into two calls in ioc_show() simserial: Use seq_puts() in rs_proc_show() setup: Use seq_putc() in show_cpuinfo() sn_hwperf: Use seq_puts() in sn_topology_show() sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() arch/ia64/hp/common/sba_iommu.c | 16 +++++++++++----- arch/ia64/hp/sim/simserial.c | 2 +- arch/ia64/kernel/setup.c | 3 +-- arch/ia64/sn/kernel/sn2/sn2_smp.c | 9 ++++----- arch/ia64/sn/kernel/sn2/sn_hwperf.c | 6 +++--- 5 files changed, 20 insertions(+), 16 deletions(-) -- 2.10.1
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-22 22:00 +0200 |
| Subject | [PATCH 4/6] IA64-setup: Use seq_putc() in show_cpuinfo() |
| Message-ID | <svaCu-7IO-17@gated-at.bofh.it> |
| In reply to | #1506595 |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sat, 22 Oct 2016 20:42:20 +0200 A single character (line break) should be put into a sequence. Thus use the corresponding function "seq_putc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- arch/ia64/kernel/setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 7ec7acc..28741f7 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -705,8 +705,7 @@ show_cpuinfo (struct seq_file *m, void *v) "thread id : %u\n", c->core_id, c->thread_id); #endif - seq_printf(m,"\n"); - + seq_putc(m, '\n'); return 0; } -- 2.10.1
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-22 22:00 +0200 |
| Subject | [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() |
| Message-ID | <svaCu-7IO-15@gated-at.bofh.it> |
| In reply to | #1506595 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Oct 2016 21:19:03 +0200
Some data were printed into a sequence by two separate function calls.
Print the same data by a single function call instead.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/ia64/sn/kernel/sn2/sn2_smp.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/ia64/sn/kernel/sn2/sn2_smp.c b/arch/ia64/sn/kernel/sn2/sn2_smp.c
index c98dc96..1beac3c 100644
--- 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);
--
2.10.1
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-10-22 22:10 +0200 |
| Subject | Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() |
| Message-ID | <svaMa-824-7@gated-at.bofh.it> |
| In reply to | #1506597 |
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?
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-22 22:50 +0200 |
| Subject | Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() |
| Message-ID | <svboS-8gX-7@gated-at.bofh.it> |
| In reply to | #1506599 |
>> @@ -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.
Would you prefer to use this function also at this source code place?
Regards,
Markus
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2016-10-23 07:50 +0200 |
| Subject | Re: [PATCH 6/6] IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() |
| Message-ID | <svjPs-5hn-3@gated-at.bofh.it> |
| In reply to | #1506603 |
On Sat, 22 Oct 2016, SF Markus Elfring wrote:
> >> @@ -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.
>
> Would you prefer to use this function also at this source code place?
I think that he is expecting that you will figure out the answer by
yourself.
julia
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-23 08:40 +0200 |
| Subject | Re: IA64-sn2_smp: Combine two seq_printf() calls into one call in sn2_ptc_seq_show() |
| Message-ID | <svkBQ-5Qe-1@gated-at.bofh.it> |
| In reply to | #1506633 |
>> Would you prefer to use this function also at this source code place? > > I think that he is expecting that you will figure out the answer by yourself. I know some answer possibilities for the potential usage of the function "seq_puts" also within the implementation of the function "sn2_ptc_seq_show". I am unsure about the consensus of the involved developers for this software module as usual. Regards, Markus
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-22 22:00 +0200 |
| Subject | [PATCH 3/6] IA64-simserial: Use seq_puts() in rs_proc_show() |
| Message-ID | <svaCu-7IO-19@gated-at.bofh.it> |
| In reply to | #1506595 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Oct 2016 20:35:28 +0200
A string which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/ia64/hp/sim/simserial.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 21fd50d..59b8d6d 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -439,7 +439,7 @@ static int rs_proc_show(struct seq_file *m, void *v)
{
int i;
- seq_printf(m, "simserinfo:1.0\n");
+ seq_puts(m, "simserinfo:1.0\n");
for (i = 0; i < NR_PORTS; i++)
seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n",
i, rs_table[i].irq);
--
2.10.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web