sh/irq: use seq_put_decimal_ull_width() for decimal values
PATCH 13/13 sh/irq: use seq_put_decimal_ull_width() for decimal values
Performance improvement for reading /proc/interrupts on arch sh
--- arch/sh/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/kernel/irq.c +2 -2
@@ -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));
Signature · 1 line
2.39.2
John Paul Adrian Glaubitz
maintainerHi David,
Quoted 13 lines · David Wang
Performance improvement for reading
/proc/interruptson arch shSigned-off-by David Wang <[email protected]>--- arch/sh/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sh/kernel/irq.c +0
-0@@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec) {
arch/sh/kernel/irq.c int arch_show_interrupts(struct seq_file *p, int prec) · line 51
Quoted 10 lines
arch/sh/kernel/irq.c +2
-2int 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
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
John Paul Adrian Glaubitz
maintainerHi David,
Quoted 23 lines · John Paul Adrian Glaubitz
Quoted 22 lines · David Wang
Performance improvement for reading
/proc/interruptson arch shSigned-off-by David Wang <[email protected]>--- arch/sh/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sh/kernel/irq.c +2
-2@@ -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" );
Quoted 7 lines
arch/sh/kernel/irq.c int arch_show_interrupts(struct seq_file *p, int prec) · line 51
Quoted 1 line
arch/sh/kernel/irq.c +0
-0seq_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 thanseq_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
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Quoted 32 lines · John Paul Adrian Glaubitz
Hi David,
Quoted 29 lines · John Paul Adrian Glaubitz
Quoted 13 lines · David Wang
Performance improvement for reading
/proc/interruptson arch shSigned-off-by David Wang <[email protected]>--- arch/sh/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sh/kernel/irq.c +0
-0@@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec) {arch/sh/kernel/irq.c int arch_show_interrupts(struct seq_file *p, int prec) · line 51
Quoted 10 lines
arch/sh/kernel/irq.c +2
-2int 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 thanseq_printf().
Quoted 13 lines
Quoted 1 line
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
Signature · 4 lines
.''`. 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
PATCH v2 1/1 sh/irq: use seq_put_decimal_ull_width() for decimal values
In reply to John Paul Adrian GlaubitzOn 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.
--- arch/sh/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/kernel/irq.c +2 -2
@@ -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));
Signature · 1 line
2.39.2
Hi David,
Quoted 17 lines · 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 thanseq_put_decimal_ull_width(). Stress reading/proc/interruptsindicates ~30% performance improvement with this patch.Signed-off-by David Wang <[email protected]>--- arch/sh/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sh/kernel/irq.c +0
-0@@ -43,9 +43,9 @@ int arch_show_interrupts(struct seq_file *p, int prec) {
arch/sh/kernel/irq.c int arch_show_interrupts(struct seq_file *p, int prec) · line 51
Quoted 10 lines
arch/sh/kernel/irq.c +2
-2int 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));
Thanks,
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913