Re: [PATCH] locking/mutex: Set and clear owner using WRITE_ONCE()

From: Davidlohr Bueso
Date: Thu May 19 2016 - 21:19:38 EST


On Thu, 19 May 2016, Jason Low wrote:

The mutex owner can get read and written to without the wait_lock.
Use WRITE_ONCE when setting and clearing the owner field in order
to avoid optimizations such as store tearing. This avoids
situations where the owner field gets written to with multiple
stores and another thread could concurrently read and use a
partially written owner value.

Right, I also ran into this with rtmutexes when avoiding the schedule()
and the spin on owner thingie.

Signed-off-by: Jason Low <jason.low2@xxxxxxx>

Acked-by: Davidlohr Bueso <dave@xxxxxxxxxxxx>