On Thu, 27 Jun 2013, Waiman Long wrote:On 06/26/2013 09:37 PM, Andi Kleen wrote:Please no timeout heuristics. They are bound to be wrong.Calling spin_unlock_wait() doesn't put the caller into a queue. It just waitIt will be hard to know what changes will be needed without knowingTotally independent of elision.
the exact semantics of the spinlock functions with lock elision. Can
you explain a little more what bizarre semantics you are referring
to?
For example, what semantics does spin_unlock_wait() have with a ticket
lock. Where in the queue does it wait?
It doesn't really make sense with a ticket lock.
What semantics would lockdep put on it?
-Andi
until the lock is no longer held by any thread. Yes, there is a possibility
that the lock can be so busy that it may be hold by various threads
continuously for a long time making it hard for those who wait to proceed.
Perhaps, I should change the code to abandon the use of spin_unlock_wait().
Instead, I can make it wait for the lock to be free with some kind of timeout
to make sure that it won't wait too long.
If the lock is held by some other cpu, then waiting for it with
unlock_wait() or a magic timeout is probably equally expensive as just
going into the slow path right away.