include/linux/irqdesc.h | 6 +++--- kernel/irq/proc.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-)
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 0179464391af9a01b911f441d2dda42ea253dfbd
Gitweb: https://git.kernel.org/tip/0179464391af9a01b911f441d2dda42ea253dfbd
Author: Thomas Gleixner <tglx@kernel.org>
AuthorDate: Sun, 17 May 2026 22:01:43 +02:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 26 May 2026 16:21:11 +02:00
genirq/proc: Utilize irq_desc::tot_count to avoid evaluation
Interrupts which are not marked per CPU increment not only the per CPU
statistics, but also the accumulation counter irq_desc::tot_count.
Change the counter to type unsigned long so it does not produce sporadic
zeros due to wrap arounds on 64-bit machines and do a quick check for non
per CPU interrupts. If the counter is zero, then simply emit a full set of
zero strings. That spares the evaluation of the per CPU counters completely
for interrupts with zero events.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Reviewed-by: Dmitry Ilvokhin <d@ilvokhin.com>
Reviewed-by: Radu Rendec <radu@rendec.net>
Link: https://patch.msgid.link/20260517194931.115522199@kernel.org
---
include/linux/irqdesc.h | 6 +++---
kernel/irq/proc.c | 11 ++++++++++-
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index dae9a9b..1058786 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -52,8 +52,8 @@ struct irq_redirect {
* @depth: disable-depth, for nested irq_disable() calls
* @wake_depth: enable depth, for multiple irq_set_irq_wake() callers
* @tot_count: stats field for non-percpu irqs
- * @irq_count: stats field to detect stalled irqs
* @last_unhandled: aging timer for unhandled count
+ * @irq_count: stats field to detect stalled irqs
* @irqs_unhandled: stats field for spurious unhandled interrupts
* @threads_handled: stats field for deferred spurious detection of threaded handlers
* @threads_handled_last: comparator field for deferred spurious detection of threaded handlers
@@ -87,9 +87,9 @@ struct irq_desc {
unsigned int core_internal_state__do_not_mess_with_it;
unsigned int depth; /* nested irq disables */
unsigned int wake_depth; /* nested wake enables */
- unsigned int tot_count;
- unsigned int irq_count; /* For detecting broken IRQs */
+ unsigned long tot_count;
unsigned long last_unhandled; /* Aging timer for unhandled count */
+ unsigned int irq_count; /* For detecting broken IRQs */
unsigned int irqs_unhandled;
atomic_t threads_handled;
int threads_handled_last;
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 378b523..5a1805b 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -523,7 +523,16 @@ int show_interrupts(struct seq_file *p, void *v)
return 0;
seq_printf(p, "%*d:", prec, i);
- irq_proc_emit_counts(p, &desc->kstat_irqs->cnt);
+
+ /*
+ * Always output per CPU interrupts. Output device interrupts only when
+ * desc::tot_count is not zero.
+ */
+ if (irq_settings_is_per_cpu(desc) || irq_settings_is_per_cpu_devid(desc) ||
+ data_race(desc->tot_count))
+ irq_proc_emit_counts(p, &desc->kstat_irqs->cnt);
+ else
+ irq_proc_emit_zero_counts(p, num_online_cpus());
seq_putc(p, ' ');
guard(raw_spinlock_irq)(&desc->lock);
© 2016 - 2026 Red Hat, Inc.