Skip to content

Improve /proc/interrupts further

Thomas Gleixner lkml 6 versions – Applied

Status from this message: The following commit has been merged into the irq/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest16 patches 14 repliesApplied
  2. v515 patches 8 repliesSuperseded
  3. v415 patches 7 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v314 patches4 repliesSuperseded
v214 patches31 repliesSuperseded
v114 patches9 repliesSuperseded

Changes in v6 from the cover letter

- Rebased against v7.1-rc2

- Addressed some formatting/alignment details - Radu, Michael

- Fixed some 0-day fallout vs. various Kconfig combinations

- Picked up tags where appropriate

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/16x86/irq: Optimize interrupts decimals printingarch/x86/kernel/irq.c+59 -530 replies
2/16genirq/proc: Avoid formatting zero counts in /proc/interruptsinclude/linux/interrupt.h kernel/irq/proc.c+39 -51 reply
3/16genirq/proc: Utilize irq_desc::tot_count to avoid evaluationinclude/linux/irqdesc.h kernel/irq/proc.c+13 -40 replies
4/16x86/irq: Make irqstats array basedarch/x86/events/amd/core.c arch/x86/events/amd/ibs.c arch/x86/events/core.c +24 more+174 -2331 reply
5/16x86/irq: Suppress unlikely interrupt stats by defaultarch/x86/include/asm/hardirq.h arch/x86/kernel/apic/apic.c arch/x86/kernel/apic/ipi.c +1 more+31 -124 replies
6/16x86/irq: Move IOAPIC misrouted and PIC/APIC error counts into irq_statsarch/x86/include/asm/hardirq.h arch/x86/include/asm/hw_irq.h arch/x86/kernel/apic/apic.c +4 more+11 -280 replies
7/16scripts/gdb: Update x86 interrupts to the array based storagescripts/gdb/linux/interrupts.py+18 -530 replies
8/16genirq: Expose nr_irqs in core codekernel/irq/internals.h kernel/irq/irqdesc.c kernel/irq/proc.c +1 more+18 -171 reply
9/16genirq/manage: Make NMI cleanup RT safekernel/irq/manage.c+21 -160 replies
10/16genirq: Cache the condition for /proc/interrupts exposureinclude/linux/irq.h kernel/irq/chip.c kernel/irq/internals.h +3 more+36 -50 replies
11/16genirq: Calculate precision only when requiredkernel/irq/internals.h kernel/irq/irqdesc.c kernel/irq/proc.c+35 -140 replies
12/16genirq/proc: Increase default interrupt number precision to fourarch/alpha/kernel/irq.c arch/arm/kernel/smp.c arch/arm64/kernel/smp.c +9 more+29 -360 replies
13/16genirq: Add rcuref count to struct irq_descinclude/linux/irqdesc.h kernel/irq/internals.h kernel/irq/irqdesc.c+31 -90 replies
14/16genirq: Expose irq_find_desc_at_or_after() in core codekernel/irq/internals.h kernel/irq/irqdesc.c+10 -70 replies
15/16genirq/proc: Runtime size the chip namekernel/irq/chip.c kernel/irq/debugfs.h kernel/irq/internals.h +4 more+111 -610 replies
16/16genirq/proc: Speed up /proc/interrupts iterationfs/proc/Makefile kernel/irq/proc.c+95 -270 replies

Reviews trailers per patch

14 of 16 patches have a Reviewed-by or Acked-by.

PatchMichael KelleyThomas GleixnerRadu RendecDmitry IlvokhinFlorian FainelliShrikanth Hegde
SeriesT-b T-b
1/16T-b R-b R-b
2/16T-b R-b R-b R-b
3/16T-b R-b R-b
4/16T-b R-b
5/16T-b R-b
6/16T-b R-b
7/16T-b R-b
8/16T-b R-b R-b R-b
9/16T-b
10/16T-b R-b R-b
11/16T-b R-b R-b
12/16
13/16T-b R-b
14/16T-b R-b
15/16T-b R-b
16/16T-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v6 thread

Cover letter [patch V6 00/16] Improve /proc/interrupts further

This is a follow up to v5 which can be found here:

https://lore.kernel.org/[email protected]

The v1 cover letter contains a full analysis, explanation and numbers:

https://lore.kernel.org/[email protected]

TLDR:

- The performance of reading of /proc/interrupts has been improved piecewise over the years, but most of the low hanging fruit has been left on the table.

Changes vs. V5:

- Rebased against v7.1-rc2

- Addressed some formatting/alignment details - Radu, Michael

- Fixed some 0-day fallout vs. various Kconfig combinations

- Picked up tags where appropriate

Delta patch against v5 is below.

The series applies on top of v7.1-rc2 and is also available via git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git irq-proc-v6

Thanks,

tglx
---

arch/alpha/kernel/irq.c +4 -4
index c67047c5d830..4a6a8b1d5a8b 100644
@@ -72,16 +72,16 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	int j;
 
 #ifdef CONFIG_SMP
-	seq_puts(p, "IPI: ");
+	seq_puts(p, " IPI: ");
 	for_each_online_cpu(j)
 		seq_printf(p, "%10lu ", cpu_data[j].ipi_count);
 	seq_putc(p, '\n');
 #endif
-	seq_puts(p, "PMI: ");
+	seq_puts(p, " PMI: ");
 	for_each_online_cpu(j)
 		seq_printf(p, "%10lu ", per_cpu(irq_pmi_count, j));
-	seq_puts(p, "          Performance Monitoring\n");
-	seq_printf(p, "ERR: %10lu\n", irq_err_count);
+	seq_puts(p, " Performance Monitoring\n");
+	seq_printf(p, " ERR: %10lu\n", irq_err_count);
 	return 0;
 }
 
arch/arm/kernel/smp.c +1 -2
index 4e8e89a26ca3..b5fb4697bc3f 100644
@@ -551,8 +551,7 @@ void show_ipi_list(struct seq_file *p, int prec)
 		if (!ipi_desc[i])
 			continue;
 
-		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
-			   prec >= 4 ? " " : "");
+		seq_printf(p, "%*s%u:", prec - 1, "IPI", i);
 
 		for_each_online_cpu(cpu)
 			seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i], cpu));
arch/arm64/kernel/smp.c +2 -3
index 1aa324104afb..1d0e0e6a5b92 100644
@@ -833,11 +833,10 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	unsigned int cpu, i;
 
 	for (i = 0; i < MAX_IPI; i++) {
-		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
-			   prec >= 4 ? " " : "");
+		seq_printf(p, "%*s%u: ", prec - 1, "IPI", i);
 		for_each_online_cpu(cpu)
 			seq_printf(p, "%10u ", irq_desc_kstat_cpu(get_ipi_desc(cpu, i), cpu));
-		seq_printf(p, "      %s\n", ipi_types[i]);
+		seq_printf(p, " %s\n", ipi_types[i]);
 	}
 
 	seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count);
arch/loongarch/kernel/smp.c +1 -1
index 64a048f1b880..50922610758b 100644
@@ -88,7 +88,7 @@ void show_ipi_list(struct seq_file *p, int prec)
 	unsigned int cpu, i;
 
 	for (i = 0; i < NR_IPI; i++) {
-		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, prec >= 4 ? " " : "");
+		seq_printf(p, "%*s%u:", prec - 1, "IPI", i);
 		for_each_online_cpu(cpu)
 			seq_put_decimal_ull_width(p, " ", per_cpu(irq_stat, cpu).ipi_irqs[i], 10);
 		seq_printf(p, " LoongArch  %d  %s\n", i + 1, ipi_types[i]);
arch/riscv/kernel/smp.c +1 -2
index 5ed5095320e6..fa66f9c97d74 100644
@@ -226,8 +226,7 @@ void show_ipi_stats(struct seq_file *p, int prec)
 	unsigned int cpu, i;
 
 	for (i = 0; i < IPI_MAX; i++) {
-		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
-			   prec >= 4 ? " " : "");
+		seq_printf(p, "%*s%u:", prec - 1, "IPI", i);
 		for_each_online_cpu(cpu)
 			seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i], cpu));
 		seq_printf(p, " %s\n", ipi_names[i]);
arch/sh/kernel/irq.c +1 -1
index 9022d8af9d68..03c39b5da50f 100644
@@ -46,7 +46,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	seq_printf(p, "%*s:", prec, "NMI");
 	for_each_online_cpu(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, " Non-maskable interrupts\n");
 
 	seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
 
arch/sparc/kernel/irq_32.c +6 -6
index 5210991429d5..22db727652ba 100644
@@ -199,19 +199,19 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	int j;
 
 #ifdef CONFIG_SMP
-	seq_printf(p, "RES:");
+	seq_printf(p, "%*s:", prec, "RES");
 	for_each_online_cpu(j)
 		seq_put_decimal_ull_width(p, " ", cpu_data(j).irq_resched_count, 10);
-	seq_printf(p, "     IPI rescheduling interrupts\n");
-	seq_printf(p, "CAL:");
+	seq_printf(p, " IPI rescheduling interrupts\n");
+	seq_printf(p, "%*s:", prec, "CAL");
 	for_each_online_cpu(j)
 		seq_put_decimal_ull_width(p, " ", cpu_data(j).irq_call_count, 10);
-	seq_printf(p, "     IPI function call interrupts\n");
+	seq_printf(p, " IPI function call interrupts\n");
 #endif
-	seq_printf(p, "NMI:");
+	seq_printf(p, "%*s:", prec, "NMI");
 	for_each_online_cpu(j)
 		seq_put_decimal_ull_width(p, " ", cpu_data(j).counter, 10);
-	seq_printf(p, "     Non-maskable interrupts\n");
+	seq_printf(p, " Non-maskable interrupts\n");
 	return 0;
 }
 
arch/sparc/kernel/irq_64.c +2 -2
index c5466a9fd560..3f55c69d5f3b 100644
@@ -303,10 +303,10 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 {
 	int j;
 
-	seq_printf(p, "NMI:");
+	seq_printf(p, "%*s:", prec, "NMI");
 	for_each_online_cpu(j)
 		seq_put_decimal_ull_width(p, " ", cpu_data(j).__nmi_count, 10);
-	seq_printf(p, "     Non-maskable interrupts\n");
+	seq_printf(p, " Non-maskable interrupts\n");
 	return 0;
 }
 
arch/um/kernel/irq.c +2 -2
index 5929d498b65f..ddfd6e9bd8c7 100644
@@ -716,12 +716,12 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	seq_printf(p, "%*s: ", prec, "RES");
 	for_each_online_cpu(cpu)
 		seq_printf(p, "%10u ", irq_stats(cpu)->irq_resched_count);
-	seq_puts(p, "  Rescheduling interrupts\n");
+	seq_puts(p, " Rescheduling interrupts\n");
 
 	seq_printf(p, "%*s: ", prec, "CAL");
 	for_each_online_cpu(cpu)
 		seq_printf(p, "%10u ", irq_stats(cpu)->irq_call_count);
-	seq_puts(p, "  Function call interrupts\n");
+	seq_puts(p, " Function call interrupts\n");
 #endif
 
 	return 0;
arch/x86/kernel/irq.c +25 -25

79 lines not on this page · raw message

arch/xtensa/kernel/irq.c +1 -1
index b1e410f6b5ab..6f01f530868b 100644
@@ -59,7 +59,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	seq_printf(p, "%*s:", prec, "NMI");
 	for_each_online_cpu(cpu)
 		seq_printf(p, " %10lu", per_cpu(nmi_count, cpu));
-	seq_puts(p, "   Non-maskable interrupts\n");
+	seq_puts(p, " Non-maskable interrupts\n");
 #endif
 	return 0;
 }
kernel/irq/debugfs.h new file +44 -0

44 lines not on this page · raw message

kernel/irq/internals.h +1 -39
index 7fbf003c6e93..f9c099d45a64 100644
@@ -12,6 +12,7 @@
 #include <linux/rcuref.h>
 #include <linux/sched/clock.h>
 
+#include "debugfs.h"
 #include "proc.h"
 
 #ifdef CONFIG_SPARSE_IRQ
@@ -394,42 +395,3 @@ static inline struct irq_data *irqd_get_parent_data(struct irq_data *irqd)
 	return NULL;
 #endif
 }
-
-#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
-#include <linux/debugfs.h>
-
-struct irq_bit_descr {
-	unsigned int	mask;
-	char		*name;
-};
-
-#define BIT_MASK_DESCR(m)	{ .mask = m, .name = #m }
-
-void irq_debug_show_bits(struct seq_file *m, int ind, unsigned int state,
-			 const struct irq_bit_descr *sd, int size);
-
-void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc);
-static inline void irq_remove_debugfs_entry(struct irq_desc *desc)
-{
-	debugfs_remove(desc->debugfs_file);
-	kfree(desc->dev_name);
-}
-void irq_debugfs_copy_devname(int irq, struct device *dev);
-# ifdef CONFIG_IRQ_DOMAIN
-void irq_domain_debugfs_init(struct dentry *root);
-# else
-static inline void irq_domain_debugfs_init(struct dentry *root)
-{
-}
-# endif
-#else /* CONFIG_GENERIC_IRQ_DEBUGFS */
-static inline void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *d)
-{
-}
-static inline void irq_remove_debugfs_entry(struct irq_desc *d)
-{
-}
-static inline void irq_debugfs_copy_devname(int irq, struct device *dev)
-{
-}
-#endif /* CONFIG_GENERIC_IRQ_DEBUGFS */
kernel/irq/irqdomain.c +1 -1
index 9f524ed709b8..f15c9f1223bb 100644
@@ -2084,7 +2084,7 @@ static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq
 #endif	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
 
 #ifdef CONFIG_GENERIC_IRQ_DEBUGFS
-#include "internals.h"
+#include "debugfs.h"
 
 static struct dentry *domain_dir;
 
kernel/irq/proc.c +3 -2
index 3bd394aa7617..ca535472e657 100644
@@ -465,7 +465,7 @@ static struct irq_proc_constraints {
 	unsigned int	num_prec;
 	unsigned int	chip_width;
 } irq_proc_constraints __read_mostly = {
-	.num_prec	= 3,
+	.num_prec	= 4,
 	.chip_width	= 8,
 };
 
@@ -477,7 +477,7 @@ void irq_proc_calc_prec(void)
 {
 	unsigned int prec, n;
 
-	for (prec = 3, n = 1000; prec < 10 && n <= total_nr_irqs; ++prec)
+	for (prec = 4, n = 10000; prec < 10 && n <= total_nr_irqs; ++prec)
 		n *= 10;
 
 	guard(raw_spinlock_irqsave)(&irq_proc_constraints_lock);
@@ -498,6 +498,7 @@ void irq_proc_update_chip(const struct irq_chip *chip)
 		WRITE_ONCE(irq_proc_constraints.chip_width, len);
 }
 
+/* Same as seq_put_decimal_ull_width(p, " ", cnt, 10) */
 #define ZSTR1 "          0"
 #define ZSTR1_LEN	(sizeof(ZSTR1) - 1)
 #define ZSTR16		ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 ZSTR1 \
kernel/irq/proc.h +4 -0
index ec9173d573f9..0631d57fbfb7 100644
@@ -1,4 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _KERNEL_IRQ_PROC_H
+#define _KERNEL_IRQ_PROC_H
 
 #if defined(CONFIG_PROC_FS) && defined(CONFIG_GENERIC_IRQ_SHOW)
 void irq_proc_calc_prec(void);
@@ -7,3 +9,5 @@ void irq_proc_update_chip(const struct irq_chip *chip);
 static inline void irq_proc_calc_prec(void) { }
 static inline void irq_proc_update_chip(const struct irq_chip *chip) { }
 #endif
+
+#endif
scripts/gdb/linux/interrupts.py +13 -17
index cf0a02c8124d..a68ae91b4531 100644
@@ -90,6 +90,13 @@ def show_irq_desc(prec, chip_width, irq):
 
     return text
 
+def show_irq_err_count(prec):
+    cnt = utils.gdb_eval_or_none("irq_err_count")
+    text = ""
+    if cnt is not None:
+        text += "%*s: %10u\n" % (prec, "ERR", cnt['counter'])
+    return text
+
 def x86_show_irqstat(prec, pfx, idx, desc):
     irq_stat = gdb.parse_and_eval("&irq_stat.counts[%d]" %idx)
     text = "%*s: " % (prec, pfx)
@@ -124,34 +131,23 @@ def arm_common_show_interrupts(prec):
     if nr_ipi is None or ipi_desc is None or ipi_types is None:
         return text
 
-    if prec >= 4:
-        sep = " "
-    else:
-        sep = ""
-
     for ipi in range(nr_ipi):
-        text += "%*s%u:%s" % (prec - 1, "IPI", ipi, sep)
+        text += "%*s%u: " % (prec - 1, "IPI", ipi)
         desc = ipi_desc[ipi].cast(irq_desc_type.get_type().pointer())
         if desc == 0:
             continue
         for cpu in cpus.each_online_cpu():
-            text += "%10u" % (cpus.per_cpu(desc['kstat_irqs'], cpu)['cnt'])
-        text += "      %s" % (ipi_types[ipi].string())
+            text += "%10u " % (cpus.per_cpu(desc['kstat_irqs'], cpu)['cnt'])
+        text += "%s" % (ipi_types[ipi].string())
         text += "\n"
     return text
 
 def aarch64_show_interrupts(prec):
+    # Does not work for ARM64 as "ipi_desc" is not available there
     text = arm_common_show_interrupts(prec)
     text += "%*s: %10lu\n" % (prec, "ERR", gdb.parse_and_eval("irq_err_count"))
     return text
 
-def show_irq_err_count(prec):
-    cnt = utils.gdb_eval_or_none("irq_err_count")
-    text = ""
-    if cnt is not None:
-        text += "%*s: %10u\n" % (prec, "ERR", cnt['counter'])
-    return text
-
 def arch_show_interrupts(prec):
     text = ""
     if utils.is_target_arch("x86"):
@@ -181,8 +177,8 @@ class LxInterruptList(gdb.Command):
             prec = int(constr['num_prec'])
             chip_width = int(constr['chip_width'])
         else:
-            prec = 3
-            j = 1000
+            prec = 4
+            j = 10000
             while prec < 10 and j <= nr_irqs:
                 prec += 1
                 j *= 10