lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240226020939.45264-4-yaoma@linux.alibaba.com>
Date: Mon, 26 Feb 2024 10:09:38 +0800
From: Bitao Hu <yaoma@...ux.alibaba.com>
To: dianders@...omium.org,
	tglx@...utronix.de,
	liusong@...ux.alibaba.com,
	akpm@...ux-foundation.org,
	pmladek@...e.com,
	kernelfans@...il.com,
	deller@....de,
	npiggin@...il.com,
	tsbogend@...ha.franken.de,
	James.Bottomley@...senPartnership.com,
	jan.kiszka@...mens.com
Cc: linux-kernel@...r.kernel.org,
	linux-mips@...r.kernel.org,
	linux-parisc@...r.kernel.org,
	linuxppc-dev@...ts.ozlabs.org,
	yaoma@...ux.alibaba.com
Subject: [PATCHv10 3/4] genirq: Avoid summation loops for /proc/interrupts

We could use the irq_desc::tot_count member to avoid the summation
loop for interrupts which are not marked as 'PER_CPU' interrupts in
'show_interrupts'. This could reduce the time overhead of reading
/proc/interrupts.

Originally-by: Thomas Gleixner <tglx@...utronix.de>
Signed-off-by: Bitao Hu <yaoma@...ux.alibaba.com>
---
 include/linux/irqdesc.h | 2 ++
 kernel/irq/irqdesc.c    | 2 +-
 kernel/irq/proc.c       | 9 +++++++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index 2912b1998670..1ee96d7232b4 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -121,6 +121,8 @@ static inline void irq_unlock_sparse(void) { }
 extern struct irq_desc irq_desc[NR_IRQS];
 #endif
 
+extern bool irq_is_nmi(struct irq_desc *desc);
+
 static inline unsigned int irq_desc_kstat_cpu(struct irq_desc *desc,
 					      unsigned int cpu)
 {
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 9cd17080b2d8..56a767957a9d 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -955,7 +955,7 @@ unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
 	return desc && desc->kstat_irqs ? per_cpu(desc->kstat_irqs->cnt, cpu) : 0;
 }
 
-static bool irq_is_nmi(struct irq_desc *desc)
+bool irq_is_nmi(struct irq_desc *desc)
 {
 	return desc->istate & IRQS_NMI;
 }
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 6954e0a02047..b3b1b93f0410 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -489,8 +489,13 @@ int show_interrupts(struct seq_file *p, void *v)
 		goto outsparse;
 
 	if (desc->kstat_irqs) {
-		for_each_online_cpu(j)
-			any_count |= data_race(per_cpu(desc->kstat_irqs->cnt, j));
+		if (!irq_settings_is_per_cpu_devid(desc) &&
+		    !irq_settings_is_per_cpu(desc) &&
+		    !irq_is_nmi(desc))
+			any_count = data_race(desc->tot_count);
+		else
+			for_each_online_cpu(j)
+				any_count |= data_race(per_cpu(desc->kstat_irqs->cnt, j));
 	}
 
 	if ((!desc->action || irq_desc_is_chained(desc)) && !any_count)
-- 
2.37.1 (Apple Git-137.1)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ