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

Steven Rostedt
2010-01-07T17:00:12Z

On Thu, 2010-01-07 at 08:49 -0800, Paul E. McKenney wrote:

> > If the task->rq changes, or the task->rq->curr changes, and makes the
> > condition fail (or even pass), the events that cause those changes are
> > probably good enough than needing to call smp_mb();
>
> This narrows the fatal window, but does not eliminate it. :-(
>
> The CPU doing the sys_membarrier() might see an old value of ->curr,
> and the other CPU might see an old value of whatever pointer we are
> trying to recycle. This combination is fatal.

But for curr to change, the rq spin lock must have been held. Which
implies smp_wb(). I would think that if you do a smp_rb() wouldn't that
guarantee that you see the new value of curr?

-- Steve