On Tue, Jan 22, 2013 at 03:13:30PM -0800, Michel Lespinasse wrote:Oh yea, its been quite awhile.Introduce queue spinlocks, to be used in situations where it is desiredIt is possible to keep the normal API for MCS locks by having the lock
to have good throughput even under the occasional high-contention situation.
This initial implementation is based on the classic MCS spinlock,
because I think this represents the nicest API we can hope for in a
fast queue spinlock algorithm. The MCS spinlock has known limitations
in that it performs very well under high contention, but is not as
good as the ticket spinlock under low contention. I will address these
limitations in a later patch, which will propose an alternative,
higher performance implementation using (mostly) the same API.
Sample use case acquiring mystruct->lock:
struct q_spinlock_node node;
q_spin_lock(&mystruct->lock, &node);
...
q_spin_unlock(&mystruct->lock, &node);
holder remember the parameter in the lock word itself. While spinning,
the node is on the stack, is not needed once the lock is acquired.
The pointer to the next node in the queue -is- needed, but this can be
stored in the lock word.
I believe that John Stultz worked on something like this some years back,
so added him to CC.