Messages in this thread Patch in this message | | | Date | Sun, 31 Jul 2011 11:04:18 +0800 | Subject | [RFC PATCH] MIPS/octeon: select online CPU for irq | From | Hillf Danton <> |
| |
The tiny probability of dead loop is removed if all bound CPUs of given irq go offline, and selected CPU is always checked to be online.
Signed-off-by: Hillf Danton <dhillf@gmail.com> --- arch/mips/cavium-octeon/octeon-irq.c | 32 +++++++++++--------------------- 1 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c index ffd4ae6..7b678e3 100644 --- a/arch/mips/cavium-octeon/octeon-irq.c +++ b/arch/mips/cavium-octeon/octeon-irq.c @@ -198,28 +198,18 @@ static void __init octeon_irq_init_core(void)
static int next_cpu_for_irq(struct irq_data *data) { - #ifdef CONFIG_SMP - int cpu; - int weight = cpumask_weight(data->affinity); - - if (weight > 1) { - cpu = smp_processor_id(); - for (;;) { - cpu = cpumask_next(cpu, data->affinity); - if (cpu >= nr_cpu_ids) { - cpu = -1; - continue; - } else if (cpumask_test_cpu(cpu, cpu_online_mask)) { - break; - } - } - } else if (weight == 1) { - cpu = cpumask_first(data->affinity); - } else { - cpu = smp_processor_id(); - } - return cpu; + int cpu = smp_processor_id(); + + cpu = cpumask_next_and(cpu, data->affinity, cpu_online_mask); + if (cpu < nr_cpu_ids) + return cpu; + + cpu = cpumask_first_and(data->affinity, cpu_online_mask); + if (cpu < nr_cpu_ids) + return cpu; + + return smp_processor_id(); #else return smp_processor_id(); #endif
| |