Re: [PATCH][2.5][13/14] smp_call_function_on_cpu - UML

Zwane Mwaikambo (zwane@holomorphy.com)
Fri, 14 Feb 2003 08:09:33 -0500 (EST)


One liner to fix num_cpus == 0 on SMP kernel w/ UP box

Index: linux-2.5.60/arch/um/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.60/arch/um/kernel/smp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.c
--- linux-2.5.60/arch/um/kernel/smp.c 10 Feb 2003 22:15:17 -0000 1.1.1.1
+++ linux-2.5.60/arch/um/kernel/smp.c 14 Feb 2003 12:59:41 -0000
@@ -255,15 +255,19 @@
atomic_inc(&scf_finished);
}

-int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic,
- int wait)
+int smp_call_function_on_cpu(void (*_func)(void *info), void *_info, int wait,
+ unsigned long mask)
{
- int cpus = num_online_cpus() - 1;
- int i;
+ int i, cpu, num_cpus;

- if (!cpus)
+ cpu = get_cpu();
+ mask &= ~(1UL << cpu);
+ num_cpus = hweight32(mask);
+ if (num_cpus == 0) {
+ put_cpu_no_resched();
return 0;
-
+ }
+
spin_lock_bh(&call_lock);
atomic_set(&scf_started, 0);
atomic_set(&scf_finished, 0);
@@ -271,19 +275,24 @@
info = _info;

for (i=0;i<NR_CPUS;i++)
- if((i != current->thread_info->cpu) &&
- test_bit(i, &cpu_online_map))
+ if (cpu_online(i) && ((1UL << i) & mask))
write(cpu_data[i].ipi_pipe[1], "C", 1);

- while (atomic_read(&scf_started) != cpus)
+ while (atomic_read(&scf_started) != num_cpus)
barrier();

if (wait)
- while (atomic_read(&scf_finished) != cpus)
+ while (atomic_read(&scf_finished) != num_cpus)
barrier();

spin_unlock_bh(&call_lock);
+ put_cpu_no_resched();
return 0;
+}
+
+int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic, int wait)
+{
+ return smp_call_function_on_cpu(_func, _info, wait, cpu_online_map);
}

#endif
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/