linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Luigi Rizzo <lrizzo@google.com>, Marc Zyngier <maz@kernel.org>,
	Luigi Rizzo <rizzo.unipi@gmail.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sean Christopherson <seanjc@google.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH-v3 3/3] genirq: Configurable default mode for GSIM
Date: Thu, 18 Dec 2025 22:56:51 +0100	[thread overview]
Message-ID: <87pl8bbgik.ffs@tglx> (raw)
In-Reply-To: <20251217112128.1401896-4-lrizzo@google.com>

On Wed, Dec 17 2025 at 11:21, Luigi Rizzo wrote:
> GSIM (Global Software Interrupt Moderation) can be enabled only after the
> interrupt is created by writing to /proc/irq/NN/soft_moderation. This is
> impractical when devices that are dynamically created or reconfigured.
>
> Add a module parameter irq_moderation.enable_list to specify whether
> moderation should be enabled at interrupt creation time. This is done
> with a comma-separated list of patterns (enable_list) matched against
> interrupt or handler names when the interrupt is created.
>
> This allows very flexible control without having to modify every single
> driver. As an example, one can limit to specific drivers by specifying
> the handler functions (using parentheses) as below
>
>      irq_moderation.enable_list="nvme_irq(),vfio_msihandler()"
>
> ora apply it to certain interrupt names
>
>      irq_moderation.enable_list="eth*,vfio*"

TBH, that's an admittely creative but horrible hack.

That's what uevents are for. Something like the below provides the
information you need to keep track of interrupt requests:

KERNEL[57.529152] change   /kernel/irq/256 (irq)

With that it is very practical to do all this magic in user space, no?

Thanks,

        tglx
---
 kernel/irq/internals.h |    6 ++++++
 kernel/irq/irqdesc.c   |   25 ++++++++++++++++++++-----
 kernel/irq/manage.c    |    1 +
 3 files changed, 27 insertions(+), 5 deletions(-)

--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -521,3 +521,9 @@ static inline void irq_debugfs_copy_devn
 {
 }
 #endif /* CONFIG_GENERIC_IRQ_DEBUGFS */
+
+#if defined(CONFIG_SPARSE_IRQ) && defined(CONFIG_SYSFS)
+void irqdesc_action_uevent(struct irq_desc *desc);
+#else
+static inline void irqdesc_action_uevent(struct irq_desc *desc) { }
+#endif
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -241,7 +241,7 @@ static int init_desc(struct irq_desc *de
 static void irq_kobj_release(struct kobject *kobj);
 
 #ifdef CONFIG_SYSFS
-static struct kobject *irq_kobj_base;
+static struct kset *irq_kobj_base;
 
 #define IRQ_ATTR_RO(_name) \
 static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
@@ -363,10 +363,12 @@ static void irq_sysfs_add(int irq, struc
 		 * crucial and failures in the late irq_sysfs_init()
 		 * cannot be rolled back.
 		 */
-		if (kobject_add(&desc->kobj, irq_kobj_base, "%d", irq))
+		if (kobject_add(&desc->kobj, &irq_kobj_base->kobj, "%d", irq)) {
 			pr_warn("Failed to add kobject for irq %d\n", irq);
-		else
+		} else {
 			desc->istate |= IRQS_SYSFS;
+			desc->kobj.kset = irq_kobj_base;
+		}
 	}
 }
 
@@ -382,6 +384,16 @@ static void irq_sysfs_del(struct irq_des
 		kobject_del(&desc->kobj);
 }
 
+void irqdesc_action_uevent(struct irq_desc *desc)
+{
+	if (!(desc->istate & IRQS_SYSFS))
+		return;
+
+	guard(mutex)(&sparse_irq_lock);
+	if (irq_kobj_base)
+		kobject_uevent(&desc->kobj, KOBJ_CHANGE);
+}
+
 static int __init irq_sysfs_init(void)
 {
 	struct irq_desc *desc;
@@ -389,13 +401,16 @@ static int __init irq_sysfs_init(void)
 
 	/* Prevent concurrent irq alloc/free */
 	guard(mutex)(&sparse_irq_lock);
-	irq_kobj_base = kobject_create_and_add("irq", kernel_kobj);
+	irq_kobj_base = kset_create_and_add("irq", NULL, kernel_kobj);
 	if (!irq_kobj_base)
 		return -ENOMEM;
 
 	/* Add the already allocated interrupts */
-	for_each_irq_desc(irq, desc)
+	for_each_irq_desc(irq, desc) {
 		irq_sysfs_add(irq, desc);
+		if (data_race(desc->action))
+			kobject_uevent(&desc->kobj, KOBJ_CHANGE);
+	}
 	return 0;
 }
 postcore_initcall(irq_sysfs_init);
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1762,6 +1762,7 @@ static int
 	register_irq_proc(irq, desc);
 	new->dir = NULL;
 	register_handler_proc(irq, new);
+	irqdesc_action_uevent(desc);
 	return 0;
 
 mismatch:

      reply	other threads:[~2025-12-18 21:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 11:21 [PATCH-v3 0/3] Global Software Interrupt Moderation (GSIM) Luigi Rizzo
2025-12-17 11:21 ` [PATCH-v3 1/3] genirq: Fixed " Luigi Rizzo
2025-12-17 19:17   ` Randy Dunlap
2025-12-18 15:37   ` Thomas Gleixner
2025-12-21 11:21   ` kernel test robot
2025-12-17 11:21 ` [PATCH-v3 2/3] genirq: Adaptive " Luigi Rizzo
2025-12-17 19:18   ` Randy Dunlap
2025-12-18 16:00   ` Thomas Gleixner
2025-12-21  9:46   ` kernel test robot
2025-12-17 11:21 ` [PATCH-v3 3/3] genirq: Configurable default mode for GSIM Luigi Rizzo
2025-12-18 21:56   ` Thomas Gleixner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pl8bbgik.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrizzo@google.com \
    --cc=maz@kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rizzo.unipi@gmail.com \
    --cc=seanjc@google.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).