Re: [PATCH v3 2/7] locking/pvqspinlock: Add pending bit support

From: Waiman Long
Date: Wed Jul 29 2015 - 16:50:29 EST


On 07/27/2015 03:39 PM, Davidlohr Bueso wrote:
On Mon, 2015-07-27 at 13:30 -0400, Waiman Long wrote:
The pending bit acts as a 1-slot waiting queue. So if the vCPU needs to
fall back to regular queuing, it needs to clear the bit.
Right, that's what I thought. So you would also need to call
clear_pending() as soon as the trylock/pending loop hits zero. Or am I
missing something?

/*
* trylock || pending
*/
for (;;) {
...
if (loop--<= 0) {
clear_pending(lock);
goto queue;
}
}

Also, no need to check for negative loop, zero should be enough to
breakout.

The while loop below can potentially make the loop variable become negative:


/*
* wait for in-progress pending->locked hand-overs
*/
if (val == _Q_PENDING_VAL) {
while (((val = atomic_read(&lock->val)) == _Q_PENDING_VAL) &&
loop--)
cpu_relax();
}

Cheers,
Longman
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/