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: <tip-c2da3f1b711173b72378258496b49f74db7479de@git.kernel.org>
Date:   Sun, 10 Feb 2019 12:55:41 -0800
From:   tip-bot for Thomas Gleixner <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     keescook@...omium.org, adobriyan@...il.com,
        linux-kernel@...r.kernel.org, dave@...olabs.net,
        marc.zyngier@....com, rdunlap@...radead.org, dbueso@...e.de,
        hpa@...or.com, david@...morbit.com, willy@...radead.org,
        mingo@...nel.org, miklos@...redi.hu, tglx@...utronix.de,
        dancol@...gle.com, akpm@...ux-foundation.org, longman@...hat.com
Subject: [tip:irq/core] proc/stat: Make the interrupt statistics more
 efficient

Commit-ID:  c2da3f1b711173b72378258496b49f74db7479de
Gitweb:     https://git.kernel.org/tip/c2da3f1b711173b72378258496b49f74db7479de
Author:     Thomas Gleixner <tglx@...utronix.de>
AuthorDate: Fri, 8 Feb 2019 14:48:04 +0100
Committer:  Thomas Gleixner <tglx@...utronix.de>
CommitDate: Sun, 10 Feb 2019 21:34:46 +0100

proc/stat: Make the interrupt statistics more efficient

Waiman reported that on large systems with a large amount of interrupts the
readout of /proc/stat takes a long time to sum up the interrupt
statistics. In principle this is not a problem. but for unknown reasons
some enterprise quality software reads /proc/stat with a high frequency.

The reason for this is that interrupt statistics are accounted per cpu. So
the /proc/stat logic has to sum up the interrupt stats for each interrupt.

The interrupt core provides now a per interrupt summary counter which can
be used to avoid the summation loops completely except for interrupts
marked PER_CPU which are only a small fraction of the interrupt space if at
all.

Another simplification is to iterate only over the active interrupts and
skip the potentially large gaps in the interrupt number space and just
print zeros for the gaps without going into the interrupt core in the first
place.

Waiman provided test results from a 4-socket IvyBridge-EX system (60-core
120-thread, 3016 irqs) excuting a test program which reads /proc/stat
50,000 times:

   Before: 18.436s (sys 18.380s)
   After:   3.769s (sys  3.742s)

Reported-by: Waiman Long <longman@...hat.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Reviewed-by: Alexey Dobriyan <adobriyan@...il.com>
Reviewed-by: Waiman Long <longman@...hat.com>
Reviewed-by: Marc Zyngier <marc.zyngier@....com>
Reviewed-by: Davidlohr Bueso <dbueso@...e.de>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Kees Cook <keescook@...omium.org>
Cc: linux-fsdevel@...r.kernel.org
Cc: Davidlohr Bueso <dave@...olabs.net>
Cc: Miklos Szeredi <miklos@...redi.hu>
Cc: Daniel Colascione <dancol@...gle.com>
Cc: Dave Chinner <david@...morbit.com>
Cc: Randy Dunlap <rdunlap@...radead.org>
Link: https://lkml.kernel.org/r/20190208135021.013828701@linutronix.de

---
 fs/proc/stat.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index 535eda7857cf..76175211b304 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -79,6 +79,31 @@ static u64 get_iowait_time(int cpu)
 
 #endif
 
+static void show_irq_gap(struct seq_file *p, unsigned int gap)
+{
+	static const char zeros[] = " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
+
+	while (gap > 0) {
+		unsigned int inc;
+
+		inc = min_t(unsigned int, gap, ARRAY_SIZE(zeros) / 2);
+		seq_write(p, zeros, 2 * inc);
+		gap -= inc;
+	}
+}
+
+static void show_all_irqs(struct seq_file *p)
+{
+	unsigned int i, next = 0;
+
+	for_each_active_irq(i) {
+		show_irq_gap(p, i - next);
+		seq_put_decimal_ull(p, " ", kstat_irqs_usr(i));
+		next = i + 1;
+	}
+	show_irq_gap(p, nr_irqs - next);
+}
+
 static int show_stat(struct seq_file *p, void *v)
 {
 	int i, j;
@@ -156,9 +181,7 @@ static int show_stat(struct seq_file *p, void *v)
 	}
 	seq_put_decimal_ull(p, "intr ", (unsigned long long)sum);
 
-	/* sum again ? it could be updated? */
-	for_each_irq_nr(j)
-		seq_put_decimal_ull(p, " ", kstat_irqs_usr(j));
+	show_all_irqs(p);
 
 	seq_printf(p,
 		"\nctxt %llu\n"

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ