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]
Date: Mon, 13 May 2024 20:05:48 +0800
From: Adrian Huang <adrianhuang0701@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org,
	Jiwei Sun <sunjw10@...ovo.com>,
	Adrian Huang <ahuang12@...ovo.com>
Subject: [PATCH 2/2] genirq/proc: Refine percpu kstat_irqs access logic

From: Adrian Huang <ahuang12@...ovo.com>

There is no need to accumulate all CPUs' kstat_irqs to determine whether
the corresponding irq should be printed. Instead, stop the iteration
once one of kstat_irqs is nonzero.

In addition, no need to check if kstat_irqs address is available
for each iteration when printing each CPU irq statistic.

Tested-by: Jiwei Sun <sunjw10@...ovo.com>
Signed-off-by: Adrian Huang <ahuang12@...ovo.com>
---
 kernel/irq/proc.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 623b8136e9af..bfa341fac687 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -461,7 +461,7 @@ int show_interrupts(struct seq_file *p, void *v)
 {
 	static int prec;
 
-	unsigned long flags, any_count = 0;
+	unsigned long flags, print_irq = 1;
 	int i = *(loff_t *) v, j;
 	struct irqaction *action;
 	struct irq_desc *desc;
@@ -488,18 +488,28 @@ int show_interrupts(struct seq_file *p, void *v)
 	if (!desc || irq_settings_is_hidden(desc))
 		goto outsparse;
 
-	if (desc->kstat_irqs) {
-		for_each_online_cpu(j)
-			any_count |= data_race(*per_cpu_ptr(desc->kstat_irqs, j));
+	if ((!desc->action || irq_desc_is_chained(desc)) && desc->kstat_irqs) {
+		print_irq = 0;
+		for_each_online_cpu(j) {
+			if (data_race(*per_cpu_ptr(desc->kstat_irqs, j))) {
+				print_irq = 1;
+				break;
+			}
+		}
 	}
 
-	if ((!desc->action || irq_desc_is_chained(desc)) && !any_count)
+	if (!print_irq)
 		goto outsparse;
 
 	seq_printf(p, "%*d: ", prec, i);
-	for_each_online_cpu(j)
-		seq_printf(p, "%10u ", desc->kstat_irqs ?
-					*per_cpu_ptr(desc->kstat_irqs, j) : 0);
+
+	if (desc->kstat_irqs) {
+		for_each_online_cpu(j)
+			seq_printf(p, "%10u ", *per_cpu_ptr(desc->kstat_irqs, j));
+	} else {
+		for_each_online_cpu(j)
+			seq_printf(p, "%10u ", 0);
+	}
 
 	raw_spin_lock_irqsave(&desc->lock, flags);
 	if (desc->irq_data.chip) {
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ