* [PATCH 13/13] sh/irq: use seq_put_decimal_ull_width() for decimal values
@ 2024-11-08 16:26 David Wang
2024-11-30 12:41 ` John Paul Adrian Glaubitz
0 siblings, 1 reply; 6+ messages in thread
From: David Wang @ 2024-11-08 16:26 UTC (permalink / raw)
To: ysato, dalias, glaubitz; +Cc: linux-kernel, linux-sh, David Wang
Performance improvement for reading /proc/interrupts on arch sh
Signed-off-by: David Wang <00107082@163.com>
---
arch/sh/kernel/irq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 4e6835de54cf..9022d8af9d68 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
{
int j;
- seq_printf(p, "%*s: ", prec, "NMI");
+ seq_printf(p, "%*s:", prec, "NMI");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat.__nmi_count, j));
+ seq_put_decimal_ull_width(p, " ", per_cpu(irq_stat.__nmi_count, j), 10);
seq_printf(p, " Non-maskable interrupts\n");
seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 13/13] sh/irq: use seq_put_decimal_ull_width() for decimal values
2024-11-08 16:26 [PATCH 13/13] sh/irq: use seq_put_decimal_ull_width() for decimal values David Wang
@ 2024-11-30 12:41 ` John Paul Adrian Glaubitz
2024-11-30 12:44 ` John Paul Adrian Glaubitz
0 siblings, 1 reply; 6+ messages in thread
From: John Paul Adrian Glaubitz @ 2024-11-30 12:41 UTC (permalink / raw)
To: David Wang, ysato, dalias; +Cc: linux-kernel, linux-sh
Hi David,
On Sat, 2024-11-09 at 00:26 +0800, David Wang wrote:
> Performance improvement for reading /proc/interrupts on arch sh
>
> Signed-off-by: David Wang <00107082@163.com>
> ---
> arch/sh/kernel/irq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
> index 4e6835de54cf..9022d8af9d68 100644
> --- a/arch/sh/kernel/irq.c
> +++ b/arch/sh/kernel/irq.c
> @@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
> {
> int j;
>
> - seq_printf(p, "%*s: ", prec, "NMI");
> + seq_printf(p, "%*s:", prec, "NMI");
> for_each_online_cpu(j)
> - seq_printf(p, "%10u ", per_cpu(irq_stat.__nmi_count, j));
> + seq_put_decimal_ull_width(p, " ", per_cpu(irq_stat.__nmi_count, j), 10);
> seq_printf(p, " Non-maskable interrupts\n");
>
> seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
Sorry for the very late reply!
I don't quite understand why seq_put_decimal_ull_width() should be faster than seq_printf().
Can you elaborate on this a bit more?
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 13/13] sh/irq: use seq_put_decimal_ull_width() for decimal values
2024-11-30 12:41 ` John Paul Adrian Glaubitz
@ 2024-11-30 12:44 ` John Paul Adrian Glaubitz
2024-11-30 13:34 ` David Wang
2024-11-30 13:49 ` [PATCH v2] " David Wang
0 siblings, 2 replies; 6+ messages in thread
From: John Paul Adrian Glaubitz @ 2024-11-30 12:44 UTC (permalink / raw)
To: David Wang, ysato, dalias; +Cc: linux-kernel, linux-sh
Hi David,
On Sat, 2024-11-30 at 13:41 +0100, John Paul Adrian Glaubitz wrote:
> On Sat, 2024-11-09 at 00:26 +0800, David Wang wrote:
> > Performance improvement for reading /proc/interrupts on arch sh
> >
> > Signed-off-by: David Wang <00107082@163.com>
> > ---
> > arch/sh/kernel/irq.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
> > index 4e6835de54cf..9022d8af9d68 100644
> > --- a/arch/sh/kernel/irq.c
> > +++ b/arch/sh/kernel/irq.c
> > @@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
> > {
> > int j;
> >
> > - seq_printf(p, "%*s: ", prec, "NMI");
> > + seq_printf(p, "%*s:", prec, "NMI");
> > for_each_online_cpu(j)
> > - seq_printf(p, "%10u ", per_cpu(irq_stat.__nmi_count, j));
> > + seq_put_decimal_ull_width(p, " ", per_cpu(irq_stat.__nmi_count, j), 10);
> > seq_printf(p, " Non-maskable interrupts\n");
> >
> > seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
>
> Sorry for the very late reply!
>
> I don't quite understand why seq_put_decimal_ull_width() should be faster than seq_printf().
>
> Can you elaborate on this a bit more?
I just checked existing merges of this patch for other architectures which include
a more elaborate patch description. If you could do that for SH as well, I can pick
the patch for v6.14.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 13/13] sh/irq: use seq_put_decimal_ull_width() for decimal values
2024-11-30 12:44 ` John Paul Adrian Glaubitz
@ 2024-11-30 13:34 ` David Wang
2024-11-30 13:49 ` [PATCH v2] " David Wang
1 sibling, 0 replies; 6+ messages in thread
From: David Wang @ 2024-11-30 13:34 UTC (permalink / raw)
To: John Paul Adrian Glaubitz; +Cc: ysato, dalias, linux-kernel, linux-sh
At 2024-11-30 20:44:26, "John Paul Adrian Glaubitz" <glaubitz@physik.fu-berlin.de> wrote:
>Hi David,
>
>On Sat, 2024-11-30 at 13:41 +0100, John Paul Adrian Glaubitz wrote:
>> On Sat, 2024-11-09 at 00:26 +0800, David Wang wrote:
>> > Performance improvement for reading /proc/interrupts on arch sh
>> >
>> > Signed-off-by: David Wang <00107082@163.com>
>> > ---
>> > arch/sh/kernel/irq.c | 4 ++--
>> > 1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
>> > index 4e6835de54cf..9022d8af9d68 100644
>> > --- a/arch/sh/kernel/irq.c
>> > +++ b/arch/sh/kernel/irq.c
>> > @@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
>> > {
>> > int j;
>> >
>> > - seq_printf(p, "%*s: ", prec, "NMI");
>> > + seq_printf(p, "%*s:", prec, "NMI");
>> > for_each_online_cpu(j)
>> > - seq_printf(p, "%10u ", per_cpu(irq_stat.__nmi_count, j));
>> > + seq_put_decimal_ull_width(p, " ", per_cpu(irq_stat.__nmi_count, j), 10);
>> > seq_printf(p, " Non-maskable interrupts\n");
>> >
>> > seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
>>
>> Sorry for the very late reply!
>>
>> I don't quite understand why seq_put_decimal_ull_width() should be faster than seq_printf().
>>
>> Can you elaborate on this a bit more?
>
>I just checked existing merges of this patch for other architectures which include
>a more elaborate patch description. If you could do that for SH as well, I can pick
>the patch for v6.14.
>
>Adrian
>
>--
> .''`. John Paul Adrian Glaubitz
>: :' : Debian Developer
>`. `' Physicist
> `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Sure, I will make the change.
To be honest, I do not have a SH platform to confirm the performance changes.
If convenient, a simple `strace -T -e read cat /proc/interrupts > /dev/null`
can be used to verify any improvement, and the core change in commit
f9ed1f7c2e26fcd1978(genirq/proc: Use seq_put_decimal_ull_width() for decimal values)
is needed.
Thanks
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] sh/irq: use seq_put_decimal_ull_width() for decimal values
2024-11-30 12:44 ` John Paul Adrian Glaubitz
2024-11-30 13:34 ` David Wang
@ 2024-11-30 13:49 ` David Wang
2025-01-30 8:28 ` John Paul Adrian Glaubitz
1 sibling, 1 reply; 6+ messages in thread
From: David Wang @ 2024-11-30 13:49 UTC (permalink / raw)
To: glaubitz; +Cc: dalias, linux-kernel, linux-sh, David Wang
On a system with n CPUs and m interrupts, there will be n*m decimal
values yielded via seq_printf(.."%10u "..) which has significant costs
parsing format string and is less efficient than
seq_put_decimal_ull_width(). Stress reading /proc/interrupts
indicates ~30% performance improvement with this patch.
Signed-off-by: David Wang <00107082@163.com>
---
arch/sh/kernel/irq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 4e6835de54cf..9022d8af9d68 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
{
int j;
- seq_printf(p, "%*s: ", prec, "NMI");
+ seq_printf(p, "%*s:", prec, "NMI");
for_each_online_cpu(j)
- seq_printf(p, "%10u ", per_cpu(irq_stat.__nmi_count, j));
+ seq_put_decimal_ull_width(p, " ", per_cpu(irq_stat.__nmi_count, j), 10);
seq_printf(p, " Non-maskable interrupts\n");
seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] sh/irq: use seq_put_decimal_ull_width() for decimal values
2024-11-30 13:49 ` [PATCH v2] " David Wang
@ 2025-01-30 8:28 ` John Paul Adrian Glaubitz
0 siblings, 0 replies; 6+ messages in thread
From: John Paul Adrian Glaubitz @ 2025-01-30 8:28 UTC (permalink / raw)
To: David Wang; +Cc: dalias, linux-kernel, linux-sh
Hi David,
On Sat, 2024-11-30 at 21:49 +0800, David Wang wrote:
> On a system with n CPUs and m interrupts, there will be n*m decimal
> values yielded via seq_printf(.."%10u "..) which has significant costs
> parsing format string and is less efficient than
> seq_put_decimal_ull_width(). Stress reading /proc/interrupts
> indicates ~30% performance improvement with this patch.
>
> Signed-off-by: David Wang <00107082@163.com>
> ---
> arch/sh/kernel/irq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
> index 4e6835de54cf..9022d8af9d68 100644
> --- a/arch/sh/kernel/irq.c
> +++ b/arch/sh/kernel/irq.c
> @@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
> {
> int j;
>
> - seq_printf(p, "%*s: ", prec, "NMI");
> + seq_printf(p, "%*s:", prec, "NMI");
> for_each_online_cpu(j)
> - seq_printf(p, "%10u ", per_cpu(irq_stat.__nmi_count, j));
> + seq_put_decimal_ull_width(p, " ", per_cpu(irq_stat.__nmi_count, j), 10);
> seq_printf(p, " Non-maskable interrupts\n");
>
> seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Thanks,
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-30 8:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-08 16:26 [PATCH 13/13] sh/irq: use seq_put_decimal_ull_width() for decimal values David Wang
2024-11-30 12:41 ` John Paul Adrian Glaubitz
2024-11-30 12:44 ` John Paul Adrian Glaubitz
2024-11-30 13:34 ` David Wang
2024-11-30 13:49 ` [PATCH v2] " David Wang
2025-01-30 8:28 ` John Paul Adrian Glaubitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®