On Thu, 2014-08-14 at 13:17 -0400, Waiman Long wrote:Let's consider the following scenario:
As mentioned, this causes all sorts of hung tasks when the another task
I still think it is better to do that after spin_lock_mutex().
enters the slowpath when locking. There's a big fat comment above.
InWhy is it racy? Atomically setting the lock to -1 given that the lock
addition, the atomic_set() is racy. It is better to something like
was stolen should be safe. The alternative we discussed with Jason was
to set the counter to -1 in the spinning path. But given that we need to
serialize the counter check with the list_empty() check that would
require the wait_lock. This is very messy and unnecessarily complicates
things.
if (atomic_cmpxchg(&lock->count, 0, -1)<= 0)Not really because some archs leave the lock at 1 after the unlock
return;
fastpath.