mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>, Tom Lyon <pugs@cisco.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Jan Kiszka <jan.kiszka@web.de>
Subject: [RFC patch 1/4] genirq: Globally serialize request/free_irq
Date: Wed, 15 Dec 2010 23:12:35 -0000	[thread overview]
Message-ID: <20101215230531.141459653@linutronix.de> (raw)
In-Reply-To: <20101215230352.411894017@linutronix.de>

[-- Attachment #1: genirq-serialize-request-free-irq.patch --]
[-- Type: text/plain, Size: 2441 bytes --]

request/free_irq is not a hotpath, so we can afford to serialize it
with a global lock. That allows us to shorten critical sections as the
action chain of an irq descriptor becomes protected by the global
lock. It's also a prerequisite for further changes which provide
adaptive oneshot functionality for possibly shared interrupts.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Lyon <pugs@cisco.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jan Kiszka <jan.kiszka@web.de>
---
 kernel/irq/manage.c |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Index: linux-2.6-tip/kernel/irq/manage.c
===================================================================
--- linux-2.6-tip.orig/kernel/irq/manage.c
+++ linux-2.6-tip/kernel/irq/manage.c
@@ -14,9 +14,12 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include <linux/mutex.h>
 
 #include "internals.h"
 
+static DEFINE_MUTEX(register_lock);
+
 /**
  *	synchronize_irq - wait for pending IRQ handlers (on other CPUs)
  *	@irq: interrupt number to wait for
@@ -870,8 +873,12 @@ out_thread:
 int setup_irq(unsigned int irq, struct irqaction *act)
 {
 	struct irq_desc *desc = irq_to_desc(irq);
+	int ret;
 
-	return __setup_irq(irq, desc, act);
+	mutex_lock(&register_lock);
+	ret = __setup_irq(irq, desc, act);
+	mutex_unlock(&register_lock);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(setup_irq);
 
@@ -977,7 +984,9 @@ static struct irqaction *__free_irq(unsi
  */
 void remove_irq(unsigned int irq, struct irqaction *act)
 {
+	mutex_lock(&register_lock);
 	__free_irq(irq, act->dev_id);
+	mutex_unlock(&register_lock);
 }
 EXPORT_SYMBOL_GPL(remove_irq);
 
@@ -1002,9 +1011,13 @@ void free_irq(unsigned int irq, void *de
 	if (!desc)
 		return;
 
+	mutex_lock(&register_lock);
+
 	chip_bus_lock(desc);
 	kfree(__free_irq(irq, dev_id));
 	chip_bus_sync_unlock(desc);
+
+	mutex_unlock(&register_lock);
 }
 EXPORT_SYMBOL(free_irq);
 
@@ -1091,10 +1104,14 @@ int request_threaded_irq(unsigned int ir
 	action->name = devname;
 	action->dev_id = dev_id;
 
+	mutex_lock(&register_lock);
+
 	chip_bus_lock(desc);
 	retval = __setup_irq(irq, desc, action);
 	chip_bus_sync_unlock(desc);
 
+	mutex_unlock(&register_lock);
+
 	if (retval)
 		kfree(action);
 



  reply	other threads:[~2010-12-15 23:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-15 23:12 [RFC patch 0/4] genirq: Provide adaptive irq oneshot functionality Thomas Gleixner
2010-12-15 23:12 ` Thomas Gleixner [this message]
2010-12-15 23:12 ` [RFC patch 2/4] genirq: Move action walk outside of desc->lock held region Thomas Gleixner
2010-12-15 23:12 ` [RFC patch 3/4] genirq: Add notification mechanism for adaptive shared irqs Thomas Gleixner
2010-12-15 23:12 ` [RFC patch 4/4] genirq: Add support for IRQF_COND_ONESHOT Thomas Gleixner

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=20101215230531.141459653@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jan.kiszka@web.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pugs@cisco.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

Powered by JetHome