[RFC PATCH] MIPS/octeon: select online CPU for irq

From: Hillf Danton
Date: Sat Jul 30 2011 - 23:11:30 EST


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@xxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/