generic-ipi: fix stack and rcu interaction bug in smp_call_function_mask(), fix
authorNick Piggin <nickpiggin@yahoo.com.au>
Tue, 12 Aug 2008 08:05:13 +0000 (18:05 +1000)
committerIngo Molnar <mingo@elte.hu>
Tue, 12 Aug 2008 09:21:27 +0000 (11:21 +0200)
> > Nick Piggin (1):
> >       generic-ipi: fix stack and rcu interaction bug in
> > smp_call_function_mask()
>
> I'm still not 100% sure that I have this patch right... I might have seen
> a lockup trace implicating the smp call function path... which may have
> been due to some other problem or a different bug in the new call function
> code, but if some more people can take a look at it before merging?

OK indeed it did have a couple of bugs. Firstly, I wasn't freeing the
data properly in the alloc && wait case. Secondly, I wasn't resetting
CSD_FLAG_WAIT in the for each cpu loop (so only the first CPU would
wait).

After those fixes, the patch boots and runs with the kmalloc commented
out (so it always executes the slowpath).

Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/smp.c

index e6084f6efb4d70210889c9dbb3e6a02931acc784..782e2b93e4652214ad5b6f21cd89935178e3b9f9 100644 (file)
@@ -135,7 +135,8 @@ void generic_smp_call_function_interrupt(void)
                         */
                        smp_wmb();
                        data->csd.flags &= ~CSD_FLAG_WAIT;
-               } else
+               }
+               if (data->csd.flags & CSD_FLAG_ALLOC)
                        call_rcu(&data->rcu_head, rcu_free_call_data);
        }
        rcu_read_unlock();
@@ -289,10 +290,11 @@ static void smp_call_function_mask_quiesce_stack(cpumask_t mask)
 
        data.func = quiesce_dummy;
        data.info = NULL;
-       data.flags = CSD_FLAG_WAIT;
 
-       for_each_cpu_mask(cpu, mask)
+       for_each_cpu_mask(cpu, mask) {
+               data.flags = CSD_FLAG_WAIT;
                generic_exec_single(cpu, &data);
+       }
 }
 
 /**
@@ -371,7 +373,7 @@ int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
        if (wait) {
                csd_flag_wait(&data->csd);
                if (unlikely(slowpath))
-                       smp_call_function_mask_quiesce_stack(allbutself);
+                       smp_call_function_mask_quiesce_stack(mask);
        }
 
        return 0;