Skip to contentSkip to conversation

Add SA_PERCPU_IRQ flag support

PATCH In review Dimitri Sivanich 4 participants 7 messages Mar 17, 2006 – Mar 20, 2006 IRQ

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add SA_PERCPU_IRQ flag support

The generic request_irq/setup_irq code should support the SA_PERCPU_IRQ flag.

Not sure why it was left out, but this patch adds that support.

Index: linux/kernel/irq/manage.c
=================================--- linux.orig/kernel/irq/manage.c 2006-03-16 14:05:27.957927445 -0600
+++ linux/kernel/irq/manage.c 2006-03-16 14:06:02.283661867 -0600
@@ -201,6 +201,9 @@ int setup_irq(unsigned int irq, struct i
* The following block of code has to be executed atomically */
spin_lock_irqsave(&desc->lock,flags);
+ if (new->flags & SA_PERCPU_IRQ) {
+ desc->status |= IRQ_PER_CPU;
+ }
p = &desc->action;
if ((old = *p) != NULL) {
/* Can't share interrupts unless both agree to */

#1 lore raw
Quoted 10 lines · Dimitri Sivanich

The generic request_irq/setup_irq code should support the SA_PERCPU_IRQ flag.

Not sure why it was left out, but this patch adds that support.

Index: linux/kernel/irq/manage.c
=================================> --- linux.orig/kernel/irq/manage.c 2006-03-16 14:05:27.957927445 -0600
+++ linux/kernel/irq/manage.c 2006-03-16 14:06:02.283661867 -0600

Review int setup_irq(unsigned int irq, struct i · line 206

Quoted 6 lines
(quoted diff) +3 -0
@@ -201,6 +201,9 @@ int setup_irq(unsigned int irq, struct i
 	 * The following block of code has to be executed atomically
 	 */
 	spin_lock_irqsave(&desc->lock,flags);
+	if (new->flags & SA_PERCPU_IRQ) {
+		desc->status |= IRQ_PER_CPU;
+	}

looks good, although the braces aren't really needed for single-line conditionals.

#2 lore raw
In reply to Dimitri Sivanich
Quoted 12 lines · Dimitri Sivanich

he generic request_irq/setup_irq code should support the SA_PERCPU_IRQ flag.

Not sure why it was left out, but this patch adds that support.

Index: linux/kernel/irq/manage.c
===================================================================

kernel/irq/manage.c int setup_irq(unsigned int irq, struct i · line 209

Quoted 9 lines
kernel/irq/manage.c +3 -0
@@ -201,6 +201,9 @@ int setup_irq(unsigned int irq, struct i
 	 * The following block of code has to be executed atomically
 	 */
 	spin_lock_irqsave(&desc->lock,flags);
+	if (new->flags & SA_PERCPU_IRQ) {
+		desc->status |= IRQ_PER_CPU;
+	}
 	p = &desc->action;
 	if ((old = *p) != NULL) {
 		/* Can't share interrupts unless both agree to */

Yes, we're presently going in and needlessly taking desc->lock on every cpu-local interrupt. However it only appears to affect mmtimer.c at present.

Shouldn't we also have a check in there, to make sure that all the other handlers off this IRQ agree about the per-cpuness of this interrupt?

Your patch broke the x86 build, btw..

From: Dimitri Sivanich <[email protected]>

The generic request_irq/setup_irq code should support the SA_PERCPU_IRQ flag.

Also, check that all handlers agree to do per-cpu IRQs.

---

 kernel/irq/manage.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
kernel/irq/manage.c renamed from kernel/irq/manage.c~generic-irq-add-sa_percpu_irq-flag-support +19 -4
diff -puN kernel/irq/manage.c~generic-irq-add-sa_percpu_irq-flag-support kernel/irq/manage.c
@@ -204,10 +204,14 @@ int setup_irq(unsigned int irq, struct i
 	p = &desc->action;
 	if ((old = *p) != NULL) {
 		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
-			spin_unlock_irqrestore(&desc->lock,flags);
-			return -EBUSY;
-		}
+		if (!(old->flags & new->flags & SA_SHIRQ))
+			goto mismatch;
+
+#ifdef ARCH_HAS_IRQ_PER_CPU
+		/* All handlers must agree on per-cpuness */
+		if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU))
+			goto mismatch;
+#endif
 
 		/* add new interrupt at end of irq queue */
 		do {
@@ -219,6 +223,11 @@ int setup_irq(unsigned int irq, struct i
 
 	*p = new;
 
+#ifdef ARCH_HAS_IRQ_PER_CPU
+	if (new->flags & SA_PERCPU_IRQ)
+		desc->status |= IRQ_PER_CPU;
+#endif
+
 	if (!shared) {
 		desc->depth = 0;
 		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
@@ -236,6 +245,12 @@ int setup_irq(unsigned int irq, struct i
 	register_handler_proc(irq, new);
 
 	return 0;
+
+mismatch:
+	spin_unlock_irqrestore(&desc->lock, flags);
+	printk(KERN_ERR "%s: irq handler mismatch\n", __FUNCTION__);
+	dump_stack();
+	return -EBUSY;
 }
 
 #ifdef CONFIG_DEBUG_SHIRQ

_

#3 lore raw
Quoted 5 lines · Andrew Morton

+#ifdef ARCH_HAS_IRQ_PER_CPU
+ if (new->flags & SA_PERCPU_IRQ)
+ desc->status |= IRQ_PER_CPU;
+#endif

OK, five architectures define ARCH_HAS_IRQ_PER_CPU but only one of them
defines SA_PERCPU_IRQ. Giving up.

#4 lore raw
Quoted 9 lines · Andrew Morton
Quoted 5 lines · Andrew Morton

+#ifdef ARCH_HAS_IRQ_PER_CPU
+ if (new->flags & SA_PERCPU_IRQ)
+ desc->status |= IRQ_PER_CPU;
+#endif

OK, five architectures define ARCH_HAS_IRQ_PER_CPU but only one of them
defines SA_PERCPU_IRQ. Giving up.

Could we do the following (at least for now)?:

+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+ if (new->flags & SA_PERCPU_IRQ)
+ desc->status |= IRQ_PER_CPU;
+#endif

#5 lore raw
Quoted 13 lines · Dimitri Sivanich
Quoted 9 lines · Andrew Morton
Quoted 5 lines · Andrew Morton

+#ifdef ARCH_HAS_IRQ_PER_CPU
+ if (new->flags & SA_PERCPU_IRQ)
+ desc->status |= IRQ_PER_CPU;
+#endif

OK, five architectures define ARCH_HAS_IRQ_PER_CPU but only one of them
defines SA_PERCPU_IRQ. Giving up.

Could we do the following (at least for now)?:

kernel/irq/manage.c int setup_irq(unsigned int irq, struct i · line 229

Quoted 4 lines
kernel/irq/manage.c renamed from kernel/irq/manage.c~generic-irq-add-sa_percpu_irq-flag-support +4 -0
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+	if (new->flags & SA_PERCPU_IRQ)
+		desc->status |= IRQ_PER_CPU;
+#endif

Why not just

#ifdef SA_PERCPU_IRQ
	if (new->flags & SA_PERCPU_IRQ)
		desc->status |= IRQ_PER_CPU;

#endif

#6 lore raw
Quoted 21 lines · Matthew Wilcox
Quoted 13 lines · Dimitri Sivanich
Quoted 9 lines · Andrew Morton
Quoted 5 lines · Andrew Morton

+#ifdef ARCH_HAS_IRQ_PER_CPU
+ if (new->flags & SA_PERCPU_IRQ)
+ desc->status |= IRQ_PER_CPU;
+#endif

OK, five architectures define ARCH_HAS_IRQ_PER_CPU but only one of them
defines SA_PERCPU_IRQ. Giving up.

Could we do the following (at least for now)?:

kernel/irq/manage.c int setup_irq(unsigned int irq, struct i · line 229

Quoted 4 lines
kernel/irq/manage.c renamed from kernel/irq/manage.c~generic-irq-add-sa_percpu_irq-flag-support +4 -0
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+	if (new->flags & SA_PERCPU_IRQ)
+		desc->status |= IRQ_PER_CPU;
+#endif

Why not just

Quoted 4 lines
#ifdef SA_PERCPU_IRQ
	if (new->flags & SA_PERCPU_IRQ)
		desc->status |= IRQ_PER_CPU;

#endif

Fine with me. I was simply maintaining the ARCH_HAS_IRQ_PER_CPU convention.