Re: [patch 2/3] scheduler: add full memory barriers upon taskswitch at runqueue lock/unlock
From: Steven Rostedt
Date: Mon Feb 01 2010 - 18:09:51 EST
On Mon, 2010-02-01 at 17:39 -0500, Steven Rostedt wrote:
>
> CPU 0 CPU 1
> ----------- -----------
> < same thread >
> clear_bit(mm_cpumask)
>
> sys_membarrier();
> <miss sending CPU 1 mb()>
> return back to user-space
>
> modify data
>
> < CPU 0 data is read > <<- corruption
>
> schedule()
>
>
> (posted in a previous email)
>
> sys_membarrier(void) {
>
> again:
> tmp_mask = mm_cpumask(current->mm);
> smp_mb();
> rcu_read_lock(); /* ensures validity of cpu_curr(cpu) tasks */
> for_each_cpu(cpu, tmp_mask) {
> spin_lock_irq(&cpu_rq(cpu)->lock);
> ret = current->mm == cpu_curr(cpu)->mm;
> spin_unlock_irq(&cpu_rq(cpu)->lock);
> if (ret)
> smp_call_function_single(cpu, membarrier_ipi, NULL, 1);
> }
> rcu_read_unlock();
> smp_mb();
> if (tmp_mask != mm_cpumask(current->mm)) {
> /* do check for signals here */
> goto again;
> }
Doh, this misses the above case if a mb() is not before the caller.
Nevermind, it looks like the only other case is to iterate over all
CPUs.
-- Steve
--
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/