Re: [PATCH v3 3/4] genirq: Split irq_set_affinity() so it can be called with lock held
From: Thomas Gleixner <hidden>
Date: 2011-03-25 22:32:56
Also in:
lkml
On Fri, 25 Mar 2011, David Daney wrote:
quoted hunk ↗ jump to hunk
The .irq_cpu_online() and .irq_cpu_offline() functions may need to adjust affinity, but they are called with the descriptor lock held. Create __irq_set_affinity_locked() which is called with the lock held. Make irq_set_affinity() just a wrapper that acquires the lock. Signed-off-by: David Daney <redacted> --- include/linux/interrupt.h | 2 ++ kernel/irq/manage.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 59b72ca..815f9fb 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h@@ -229,6 +229,8 @@ static inline int check_wakeup_irqs(void) { return 0; } extern cpumask_var_t irq_default_affinity; extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); +extern int __irq_set_affinity_locked(struct irq_desc *desc, + const struct cpumask *cpumask); extern int irq_can_set_affinity(unsigned int irq); extern int irq_select_affinity(unsigned int irq);diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 0a2aa73..3d3bed1 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c@@ -139,24 +139,12 @@ static inline void irq_get_pending(struct cpumask *mask, struct irq_desc *desc) { } #endif -/** - * irq_set_affinity - Set the irq affinity of a given irq - * @irq: Interrupt to set affinity - * @cpumask: cpumask - * - */ -int irq_set_affinity(unsigned int irq, const struct cpumask *mask) + +int __irq_set_affinity_locked(struct irq_desc *desc, const struct cpumask *mask) { - struct irq_desc *desc = irq_to_desc(irq); struct irq_chip *chip = desc->irq_data.chip; - unsigned long flags; int ret = 0; - if (!chip->irq_set_affinity) - return -EINVAL;
We want to keep that check here. No need to crash with a NULL pointer dereference, when we can deal with it gracefully. Thanks, tglx