Re: [RFC PATCH] introduce sys_membarrier(): process-wide memory barrier

Paul E. McKenney
2010-01-07T17:56:43Z

On Thu, Jan 07, 2010 at 12:44:37PM -0500, Steven Rostedt wrote:
> On Thu, 2010-01-07 at 09:31 -0800, Paul E. McKenney wrote:
>
> > Something like the following for sys_membarrier(), then?
> >
> > smp_mb();
> > for_each_cpu(cpu, current->mm->cpu_vm_mask) {
> > if (cpu_curr(cpu)->mm == current->mm)
> > smp_call_function_single(cpu, func, NULL, 1);
> > }
> >
> > Then the code changing ->mm on the other CPU also needs to have a
> > full smp_mb() somewhere after the change to ->mm, but before starting
> > user-space execution. Which it might well just due to overhead, but
> > we need to make sure that someone doesn't optimize us out of existence.
>
> To change the mm requires things like flushing the TLB. I'd be surprised
> if the change of the mm does not already do a smp_mb() somewhere.

Agreed, but "somewhere" does not fill me with warm fuzzies. ;-)

Thanx, Paul