Re: [PATCH 5/8] locking, mutex: Cancelable MCS lock for adaptivespinning

From: Jason Low
Date: Mon Feb 10 2014 - 16:16:17 EST


On Mon, 2014-02-10 at 20:58 +0100, Peter Zijlstra wrote:
> +void osq_unlock(struct optimistic_spin_queue **lock)
> +{
> + struct optimistic_spin_queue *node = this_cpu_ptr(&osq_node);
> + struct optimistic_spin_queue *next;
> +
> + /*
> + * Fast path for the uncontended case.
> + */
> + if (likely(cmpxchg(lock, node, NULL) == node))
> + return;

Can we can also add the following code here as I'm noticing next != NULL
is the much more likely scenario on my box:

next = xchg(&node->next, NULL);
if (next) {
ACCESS_ONCE(next->locked) = 1;
return;


> + next = osq_wait_next(lock, node, NULL);
> + if (next)
> + ACCESS_ONCE(next->locked) = 1;
> +}

--
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/