[lkml]   [2010]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC PATCH] introduce sys_membarrier(): process-wide memory barrier
On Thu, Jan 07, 2010 at 10:50:26AM +0100, Andi Kleen wrote:
> Mathieu Desnoyers <> writes:
> > Both the signal-based and the sys_membarrier userspace RCU schemes
> > permit us to remove the memory barrier from the userspace RCU
> > rcu_read_lock() and rcu_read_unlock() primitives, thus significantly
> > accelerating them. These memory barriers are replaced by compiler
> > barriers on the read-side, and all matching memory barriers on the
> > write-side are turned into an invokation of a memory barrier on all
> > active threads in the process. By letting the kernel perform this
> > synchronization rather than dumbly sending a signal to every process
> > threads (as we currently do), we diminish the number of unnecessary wake
> > ups and only issue the memory barriers on active threads. Non-running
> > threads do not need to execute such barrier anyway, because these are
> > implied by the scheduler context switches.
> I'm not sure all this effort is really needed on architectures
> with strong memory ordering.

Even CPUs with strong memory ordering allow later reads to complete
prior to earlier writes, which is enough to cause problems.

That said, some of the lighter-weight schemes sampling ->mm might be
safe on TSO machines.

> > + * The current implementation simply executes a memory barrier in an IPI handler
> > + * on each active cpu. Going through the hassle of taking run queue locks and
> > + * checking if the thread running on each online CPU belongs to the current
> > + * thread seems more heavyweight than the cost of the IPI itself.
> > + */
> > +SYSCALL_DEFINE0(membarrier)
> > +{
> > + on_each_cpu(membarrier_ipi, NULL, 1);
> Can't you use mm->cpu_vm_mask?

Hmmm... Acquiring the corresponding lock would certainly make this
safe. Not sure about lock-less access to it, though.

Thanx, Paul

 \ /
  Last update: 2010-01-07 17:59    [W:0.192 / U:3.864 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site