new file mode 100644
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_GENERIC_IRQ_ERR_H
+#define __ASM_GENERIC_IRQ_ERR_H
+
+extern atomic_t irq_err_counter;
+
+static inline void irq_err_inc(void)
+{
+ atomic_inc(&irq_err_counter);
+}
+
+static inline int irq_err_get(void)
+{
+ return atomic_read(&irq_err_counter);
+}
+
+#endif /* __ASM_GENERIC_IRQ_ERR_H */
@@ -8,6 +8,7 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/export.h>
+#include <asm-generic/irq-err.h>
#include "internals.h"
@@ -20,6 +21,7 @@ static void ack_bad(struct irq_data *data)
struct irq_desc *desc = irq_data_to_desc(data);
print_irq_desc(data->irq, desc);
+ irq_err_inc();
ack_bad_irq(data->irq);
}
@@ -13,11 +13,14 @@
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/kernel_stat.h>
+#include <asm-generic/irq-err.h>
#include <trace/events/irq.h>
#include "internals.h"
+atomic_t irq_err_counter;
+
#ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER
void (*handle_arch_irq)(struct pt_regs *) __ro_after_init;
#endif
@@ -34,6 +37,7 @@ void handle_bad_irq(struct irq_desc *desc)
print_irq_desc(irq, desc);
kstat_incr_irqs_this_cpu(desc);
+ irq_err_inc();
ack_bad_irq(irq);
}
EXPORT_SYMBOL_GPL(handle_bad_irq);
@@ -16,6 +16,7 @@
#include <linux/bitmap.h>
#include <linux/irqdomain.h>
#include <linux/sysfs.h>
+#include <asm-generic/irq-err.h>
#include "internals.h"
@@ -684,6 +685,7 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,
if (printk_ratelimit())
pr_warn("spurious IRQ: irq=%d hwirq=%d nr_irqs=%d\n",
irq, hwirq, nr_irqs);
+ irq_err_inc();
ack_bad_irq(irq);
ret = -EINVAL;
} else {
We currently have counters for spurious interrupt spread over all the individual architectures. Mostly done in the arch's ack_bad_irq(), sometimes also in arch specific drivers. It's time to consolidate this code duplication: * introduce a global counter and inlined accessors * increase the counter in all call sites of ack_bad_irq() * subsequent patches will transform the individual archs one by one Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> --- include/asm-generic/irq-err.h | 17 +++++++++++++++++ kernel/irq/dummychip.c | 2 ++ kernel/irq/handle.c | 4 ++++ kernel/irq/irqdesc.c | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 include/asm-generic/irq-err.h