Re: sem_lock() vs qspinlocks

From: Davidlohr Bueso
Date: Fri May 20 2016 - 11:01:08 EST


On Fri, 20 May 2016, Peter Zijlstra wrote:

On Thu, May 19, 2016 at 10:39:26PM -0700, Davidlohr Bueso wrote:
In addition, this makes me wonder if queued_spin_is_locked() should then be:

- return atomic_read(&lock->val);
+ return atomic_read(&lock->val) & _Q_LOCKED_MASK;

And avoid considering pending waiters as locked.

Probably

Similarly, and I know you hate it, but afaict, then semantically
queued_spin_is_contended() ought to be:

- return atomic_read(&lock->val) & ~_Q_LOCKED_MASK;
+ return atomic_read(&lock->val);

Thanks,
Davidlohr