[2.5][12/15] smp_call_function/_on_cpu - sparc64

[2.5][12/15] smp_call_function/_on_cpu - sparc64

Post by Zwane Mwaikamb » Mon, 10 Feb 2003 14:40:06



 smp.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 62 insertions(+), 2 deletions(-)

Index: linux-2.5.59-bk/arch/sparc64/kernel/smp.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.59-bk/arch/sparc64/kernel/smp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 smp.c
--- linux-2.5.59-bk/arch/sparc64/kernel/smp.c   9 Feb 2003 09:08:36 -0000       1.1.1.1

  * You must not call this function with disabled interrupts or from a
  * hardware interrupt handler or from a bottom half handler.
  */
-int smp_call_function(void (*func)(void *info), void *info,
-                     int nonatomic, int wait)
+int smp_call_function(void (*func)(void *info), void *info, int wait)
 {
        struct call_data_struct data;

        spin_unlock(&call_lock);
        printk("XCALL: Remote cpus not responding, ncpus=%d finished=%d\n",
               num_online_cpus() - 1, atomic_read(&data.finished));
+       return 0;
+}
+
+/*
+ * smp_call_function_on_cpu - Runs func on all processors in the mask
+ *




+ *
+ * Returns 0 on success, else a negative status code. Does not return until
+ * remote CPUs are nearly ready to execute func or have executed it.
+ *
+ * You must not call this function with disabled interrupts or from a
+ * hardware interrupt handler or from a bottom half handler.
+ */
+
+int smp_call_function_on_cpu(void (*func)(void *info), void *info,
+                               int wait, unsigned long mask)
+{
+       struct call_data_struct data;
+       int num_cpus = hweight32(mask), cpu;
+       long timeout;
+
+       cpu = get_cpu();
+       if (((1UL << cpu) & mask) || num_cpus == 0)
+               goto out;
+
+       data.func = func;
+       data.info = info;
+       atomic_set(&data.finished, 0);
+       data.wait = wait;
+
+       spin_lock(&call_lock);
+
+       call_data = &data;
+
+       smp_cross_call_masked(&xcall_call_function, 0, 0, 0, mask);
+
+       /*
+        * Wait for target cpus to complete function or at
+        * least snap the call data.
+        */
+       timeout = 1000000;
+       while (atomic_read(&data.finished) != num_cpus) {
+               if (--timeout <= 0)
+                       goto out_timeout;
+               barrier();
+               udelay(1);
+       }
+
+       spin_unlock(&call_lock);
+       goto out;
+
+out_timeout:
+       spin_unlock(&call_lock);
+       printk("XCALL: Remote cpus not responding, ncpus=%d finished=%d\n",
+              num_cpus, atomic_read(&data.finished));
+out:
+       put_cpu_no_resched();
        return 0;
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/