Re: [RFC PATCH 1/6] kernel: implement queue spinlock API

From: Paul E. McKenney
Date: Thu Feb 07 2013 - 19:40:49 EST


On Thu, Feb 07, 2013 at 04:03:54PM -0800, Eric Dumazet wrote:
> On Thu, 2013-02-07 at 15:58 -0800, Michel Lespinasse wrote:
>
> > No, I think that's doable. The trick would be that once a thread
> > acquires the lock, the only remaining use of the node is to receive
> > the 'next' pointer if/when another thread starts contending for the
> > lock. So if the lock state would need to distinguish between a lock
> > that is currently locked but not contended (the next value would then
> > be NULL), and a lock that is currently locked and contended (the
> > lock->next value is the node that goes after the current lock owner)
> >
>
> It adds yet another memory write to store the node pointer in the
> lock...
>
> I suspect it's going to increase false sharing.

On the other hand, compared to straight MCS, it reduces the need to
pass the node address around. Furthermore, the node pointer is likely
to be in the same cache line as the lock word itself, and finally
some architectures can do a double-pointer store.

Of course, it might well be slower, but it seems like it is worth
giving it a try.

Thanx, Paul

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