Skip to contentSkip to conversation

genirq: Delegate irq affinity setting to the irq thread

tip:irq/urgent tip-bot for Thomas Gleixner 1 participant 1 message Jul 21, 2009 IRQ

lore
Share & tools
lore
#0 lore raw
Commit-ID:  591d2fb02ea80472d846c0b8507007806bdd69cc
Gitweb:     http://git.kernel.org/tip/591d2fb02ea80472d846c0b8507007806bdd69cc
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Tue, 21 Jul 2009 11:09:39 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 21 Jul 2009 14:35:07 +0200

genirq: Delegate irq affinity setting to the irq thread

irq_set_thread_affinity() calls set_cpus_allowed_ptr() which might sleep, but irq_set_thread_affinity() is called with desc->lock held and can be called from hard interrupt context as well. The code has another bug as it does not hold a ref on the task struct as required by set_cpus_allowed_ptr().

Just set the IRQTF_AFFINITY bit in action->thread_flags. The next time the thread runs it migrates itself. Solves all of the above problems nicely.

Add kerneldoc to irq_set_thread_affinity() while at it.

LKML-Reference: <new-submission>

---
 include/linux/interrupt.h |    2 +
 kernel/irq/internals.h    |    3 +-
 kernel/irq/manage.c       |   50 +++++++++++++++++++++++++++++++++++++++-----
 kernel/irq/migration.c    |    2 +-
 4 files changed, 48 insertions(+), 9 deletions(-)
include/linux/interrupt.h +2 -0
index 2721f07..88b056a 100644
@@ -64,11 +64,13 @@
  * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run
  * IRQTF_DIED      - handler thread died
  * IRQTF_WARNED    - warning "IRQ_WAKE_THREAD w/o thread_fn" has been printed
+ * IRQTF_AFFINITY  - irq thread is requested to adjust affinity
  */
 enum {
 	IRQTF_RUNTHREAD,
 	IRQTF_DIED,
 	IRQTF_WARNED,
+	IRQTF_AFFINITY,
 };
 
 typedef irqreturn_t (*irq_handler_t)(int, void *);
kernel/irq/internals.h +1 -2
index 7346825..e70ed55 100644
@@ -42,8 +42,7 @@ static inline void unregister_handler_proc(unsigned int irq,
 
 extern int irq_select_affinity_usr(unsigned int irq);
 
-extern void
-irq_set_thread_affinity(struct irq_desc *desc, const struct cpumask *cpumask);
+extern void irq_set_thread_affinity(struct irq_desc *desc);
 
 /*
  * Debugging printout:
kernel/irq/manage.c +44 -6

91 lines not on this page · raw message

kernel/irq/migration.c +1 -1
index cfe767c..fcb6c96 100644
@@ -45,7 +45,7 @@ void move_masked_irq(int irq)
 		   < nr_cpu_ids))
 		if (!desc->chip->set_affinity(irq, desc->pending_mask)) {
 			cpumask_copy(desc->affinity, desc->pending_mask);
-			irq_set_thread_affinity(desc, desc->pending_mask);
+			irq_set_thread_affinity(desc);
 		}
 
 	cpumask_clear(desc->pending_mask);