Re: [PATCH] rbtree: use READ_ONCE in RB_EMPTY_ROOT

From: Peter Zijlstra
Date: Tue Jan 12 2016 - 10:59:43 EST

On Tue, Jan 12, 2016 at 07:09:46AM -0800, Davidlohr Bueso wrote:
> On Tue, 12 Jan 2016, Peter Zijlstra wrote:
> >On Mon, Jan 11, 2016 at 10:22:43AM -0800, Davidlohr Bueso wrote:
> >>With d72da4a4d97 (rbtree: Make lockless searches non-fatal) our rbtrees
> >>provide weak guarantees that allows us to do lockless (and very speculative)
> >>reads of the tree. Such readers cannot see partial stores on nodes, ie
> >>left/right as well as root. As such, similar to the WRITE_ONCE semantics when
> >>doing rotations, use READ_ONCE when checking the root node in RB_EMPTY_ROOT.
> >
> >No objection, but is this actually used anywhere?
> I found this because I wanted to use the waiter check in rtmutexes in a lockless
> fashion (ie rt_mutex_has_waiters).

OK, fair enough.

Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>