Re: [PATCH v8 17/19] locking/rwsem: Merge owner into count on x86-64
From: Peter Zijlstra
Date: Tue Jun 04 2019 - 05:49:43 EST
On Mon, May 20, 2019 at 04:59:16PM -0400, Waiman Long wrote:
> With separate count and owner, there are timing windows where the two
> values are inconsistent. That can cause problem when trying to figure
> out the exact state of the rwsem. For instance, a RT task will stop
> optimistic spinning if the lock is acquired by a writer but the owner
> field isn't set yet. That can be solved by combining the count and
> owner together in a single atomic value.
I just realized we can use cmpxchg_double() here (where available of
course).