]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - kernel/smp.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux...
[mv-sheeva.git] / kernel / smp.c
index 7c6ded5effd9616dfcbaffcd7a46877712a2900f..7cbd0f293df4484682e18ae637cc5cbcd2ba87ba 100644 (file)
@@ -194,7 +194,7 @@ void generic_smp_call_function_interrupt(void)
         */
        list_for_each_entry_rcu(data, &call_function.queue, csd.list) {
                int refs;
-               void (*func) (void *info);
+               smp_call_func_t func;
 
                /*
                 * Since we walk the list without any locks, we might
@@ -214,17 +214,17 @@ void generic_smp_call_function_interrupt(void)
                if (atomic_read(&data->refs) == 0)
                        continue;
 
-               func = data->csd.func;                  /* for later warn */
-               data->csd.func(data->csd.info);
+               func = data->csd.func;          /* save for later warn */
+               func(data->csd.info);
 
                /*
-                * If the cpu mask is not still set then it enabled interrupts,
-                * we took another smp interrupt, and executed the function
-                * twice on this cpu.  In theory that copy decremented refs.
+                * If the cpu mask is not still set then func enabled
+                * interrupts (BUG), and this cpu took another smp call
+                * function interrupt and executed func(info) twice
+                * on this cpu.  That nested execution decremented refs.
                 */
                if (!cpumask_test_and_clear_cpu(cpu, data->cpumask)) {
-                       WARN(1, "%pS enabled interrupts and double executed\n",
-                            func);
+                       WARN(1, "%pf enabled interrupts and double executed\n", func);
                        continue;
                }
 
@@ -450,7 +450,7 @@ void smp_call_function_many(const struct cpumask *mask,
 {
        struct call_function_data *data;
        unsigned long flags;
-       int cpu, next_cpu, this_cpu = smp_processor_id();
+       int refs, cpu, next_cpu, this_cpu = smp_processor_id();
 
        /*
         * Can deadlock when called with interrupts disabled.
@@ -461,7 +461,7 @@ void smp_call_function_many(const struct cpumask *mask,
        WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
                     && !oops_in_progress && !early_boot_irqs_disabled);
 
-       /* So, what's a CPU they want? Ignoring this one. */
+       /* Try to fastpath.  So, what's a CPU they want? Ignoring this one. */
        cpu = cpumask_first_and(mask, cpu_online_mask);
        if (cpu == this_cpu)
                cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
@@ -519,6 +519,13 @@ void smp_call_function_many(const struct cpumask *mask,
        /* We rely on the "and" being processed before the store */
        cpumask_and(data->cpumask, mask, cpu_online_mask);
        cpumask_clear_cpu(this_cpu, data->cpumask);
+       refs = cpumask_weight(data->cpumask);
+
+       /* Some callers race with other cpus changing the passed mask */
+       if (unlikely(!refs)) {
+               csd_unlock(&data->csd);
+               return;
+       }
 
        raw_spin_lock_irqsave(&call_function.lock, flags);
        /*
@@ -532,7 +539,7 @@ void smp_call_function_many(const struct cpumask *mask,
         * to the cpumask before this write to refs, which indicates
         * data is on the list and is ready to be processed.
         */
-       atomic_set(&data->refs, cpumask_weight(data->cpumask));
+       atomic_set(&data->refs, refs);
        raw_spin_unlock_irqrestore(&call_function.lock, flags);
 
        /*