Messages in this thread | | | Subject | Re: [patch 2/3] scheduler: add full memory barriers upon task switch at runqueue lock/unlock | From | Steven Rostedt <> | Date | Mon, 01 Feb 2010 18:09:43 -0500 |
| |
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
| |