Skip to content

Commit e8a7035

Browse files
committed
genirq/cpuhotplug: Reorder check logic
Move the checks for a valid irq chip and the irq_set_affinity() callback right in front of the whole migration logic. No point in doing a gazillion of other things when the interrupt cannot be migrated at all. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Jens Axboe <axboe@kernel.dk> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Keith Busch <keith.busch@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Christoph Hellwig <hch@lst.de> Link: http://lkml.kernel.org/r/20170619235445.354181630@linutronix.de
1 parent 735c095 commit e8a7035

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

kernel/irq/cpuhotplug.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,20 @@
1717
static bool migrate_one_irq(struct irq_desc *desc)
1818
{
1919
struct irq_data *d = irq_desc_get_irq_data(desc);
20+
struct irq_chip *chip = irq_data_get_irq_chip(d);
2021
const struct cpumask *affinity = d->common->affinity;
21-
struct irq_chip *c;
22-
bool ret = false;
22+
bool brokeaff = false;
23+
int err;
24+
25+
/*
26+
* IRQ chip might be already torn down, but the irq descriptor is
27+
* still in the radix tree. Also if the chip has no affinity setter,
28+
* nothing can be done here.
29+
*/
30+
if (!chip || !chip->irq_set_affinity) {
31+
pr_debug("IRQ %u: Unable to migrate away\n", d->irq);
32+
return false;
33+
}
2334

2435
/*
2536
* If this is a per-CPU interrupt, or the affinity does not
@@ -31,23 +42,16 @@ static bool migrate_one_irq(struct irq_desc *desc)
3142

3243
if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
3344
affinity = cpu_online_mask;
34-
ret = true;
45+
brokeaff = true;
3546
}
3647

37-
c = irq_data_get_irq_chip(d);
38-
if (!c->irq_set_affinity) {
39-
pr_debug("IRQ%u: unable to set affinity\n", d->irq);
40-
ret = false;
41-
} else {
42-
int r = irq_do_set_affinity(d, affinity, false);
43-
if (r) {
44-
pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n",
45-
d->irq, r);
46-
ret = false;
47-
}
48+
err = irq_do_set_affinity(d, affinity, false);
49+
if (err) {
50+
pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n",
51+
d->irq, err);
52+
return false;
4853
}
49-
50-
return ret;
54+
return brokeaff;
5155
}
5256

5357
/**

0 commit comments

Comments
 (0)