Re: [PATCH 04/10] locking: export osq_lock()/osq_unlock()
From: Peter Zijlstra
Date: Fri May 18 2018 - 06:44:54 EST
On Fri, May 18, 2018 at 07:32:05AM -0400, Kent Overstreet wrote:
> It does strike me that the whole optimistic spin algorithm
> (mutex_optimistic_spin() and rwsem_optimistic_spin()) are ripe for factoring
> out. They've been growing more optimizations I see, and the optimizations mostly
> aren't specific to either locks.
There's a few unfortunate differences between the two; but yes it would
be good if we could reduce some of the duplication found there.
One of the distinct differences is that mutex (now) has the lock state
and owner in a single atomic word, while rwsem still tracks the owner in
a separate word and thus needs to account for 'inconsistent' owner
state.
And then there's warts such as ww_mutex and rwsem_owner_is_reader and
similar.