[PATCH v5 1/7] genirq: Add flags for software interrupt moderation.

From: Luigi Rizzo

Date: Wed Aug 19 2026 - 08:51:35 EST


Add two flags to support software interrupt moderation:

- IRQ_MODERATABLE is an irqdesc flag indicating that an interrupt supports
moderation. This is a capability that can be set for eligible sources.

- IRQD_MODERATED is an internal irqdata flag indicating that the
interrupt is currently being moderated. This is a state flag.

Signed-off-by: Luigi Rizzo <lrizzo@xxxxxxxxxx>
---
include/linux/irq.h | 11 ++++++++++-
kernel/irq/debugfs.c | 3 +++
kernel/irq/settings.h | 17 +++++++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index f485369b1b4f7..232df18af1b66 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -76,6 +76,7 @@ enum irqchip_irq_state;
* IRQ_DISABLE_UNLAZY - Disable lazy irq disable
* IRQ_HIDDEN - Don't show up in /proc/interrupts
* IRQ_NO_DEBUG - Exclude from note_interrupt() debugging
+ * IRQ_MODERATABLE - Can do software interrupt moderation
*/
enum {
IRQ_TYPE_NONE = 0x00000000,
@@ -104,13 +105,14 @@ enum {
IRQ_HIDDEN = (1 << 20),
IRQ_NO_DEBUG = (1 << 21),
IRQ_RESERVED = (1 << 22),
+ IRQ_MODERATABLE = (1 << 23),
};

#define IRQF_MODIFY_MASK \
(IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \
IRQ_NOAUTOEN | IRQ_LEVEL | IRQ_NO_BALANCING | \
IRQ_PER_CPU | IRQ_NESTED_THREAD | IRQ_NOTHREAD | IRQ_PER_CPU_DEVID | \
- IRQ_IS_POLLED | IRQ_DISABLE_UNLAZY | IRQ_HIDDEN)
+ IRQ_IS_POLLED | IRQ_DISABLE_UNLAZY | IRQ_HIDDEN | IRQ_MODERATABLE)

#define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)

@@ -224,6 +226,7 @@ struct irq_data {
* irqchip have flag IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND set.
* IRQD_RESEND_WHEN_IN_PROGRESS - Interrupt may fire when already in progress in which
* case it must be resent at the next available opportunity.
+ * IRQD_MODERATED - Interrupt is currently moderated.
*/
enum {
IRQD_TRIGGER_MASK = 0xf,
@@ -249,6 +252,7 @@ enum {
IRQD_AFFINITY_ON_ACTIVATE = BIT(28),
IRQD_IRQ_ENABLED_ON_SUSPEND = BIT(29),
IRQD_RESEND_WHEN_IN_PROGRESS = BIT(30),
+ IRQD_MODERATED = BIT(31),
};

#define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors)
@@ -438,6 +442,11 @@ static inline bool irqd_needs_resend_when_in_progress(struct irq_data *d)
return __irqd_to_state(d) & IRQD_RESEND_WHEN_IN_PROGRESS;
}

+static inline bool irqd_is_moderated(struct irq_data *d)
+{
+ return __irqd_to_state(d) & IRQD_MODERATED;
+}
+
#undef __irqd_to_state

static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index 5c5ebaee35f2c..634f00c0f0f59 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -128,6 +128,8 @@ static const struct irq_bit_descr irqdata_states[] = {
BIT_MASK_DESCR(IRQD_IRQ_ENABLED_ON_SUSPEND),

BIT_MASK_DESCR(IRQD_RESEND_WHEN_IN_PROGRESS),
+
+ BIT_MASK_DESCR(IRQD_MODERATED),
};

static const struct irq_bit_descr irqdesc_states[] = {
@@ -140,6 +142,7 @@ static const struct irq_bit_descr irqdesc_states[] = {
BIT_MASK_DESCR(_IRQ_IS_POLLED),
BIT_MASK_DESCR(_IRQ_DISABLE_UNLAZY),
BIT_MASK_DESCR(_IRQ_HIDDEN),
+ BIT_MASK_DESCR(_IRQ_MODERATABLE),
};

static const struct irq_bit_descr irqdesc_istates[] = {
diff --git a/kernel/irq/settings.h b/kernel/irq/settings.h
index 0a0c027a5d342..1663bb46d3a99 100644
--- a/kernel/irq/settings.h
+++ b/kernel/irq/settings.h
@@ -19,6 +19,7 @@ enum {
_IRQ_HIDDEN = IRQ_HIDDEN,
_IRQ_NO_DEBUG = IRQ_NO_DEBUG,
_IRQ_PROC_VALID = IRQ_RESERVED,
+ _IRQ_MODERATABLE = IRQ_MODERATABLE,
_IRQF_MODIFY_MASK = IRQF_MODIFY_MASK,
};

@@ -36,6 +37,7 @@ enum {
#define IRQ_HIDDEN GOT_YOU_MORON
#define IRQ_NO_DEBUG GOT_YOU_MORON
#define IRQ_RESERVED GOT_YOU_MORON
+#define IRQ_MODERATABLE GOT_YOU_MORON
#undef IRQF_MODIFY_MASK
#define IRQF_MODIFY_MASK GOT_YOU_MORON

@@ -193,3 +195,18 @@ static inline void irq_settings_update_proc_valid(struct irq_desc *desc, u32 set
desc->status_use_accessors &= ~_IRQ_PROC_VALID;
desc->status_use_accessors |= (set & _IRQ_PROC_VALID);
}
+
+static inline bool irq_settings_moderatable(struct irq_desc *desc)
+{
+ return desc->status_use_accessors & _IRQ_MODERATABLE;
+}
+
+static inline void irq_settings_set_moderatable(struct irq_desc *desc)
+{
+ desc->status_use_accessors |= _IRQ_MODERATABLE;
+}
+
+static inline void irq_settings_clr_moderatable(struct irq_desc *desc)
+{
+ desc->status_use_accessors &= ~_IRQ_MODERATABLE;
+}
--
2.55.0.737.g08866a6d13-goog