Re: [PATCH] Futexes IV (Fast Lightweight Userspace Semaphores)

From: Linus Torvalds (torvalds@transmeta.com)
Date: Fri Mar 08 2002 - 15:57:33 EST


On Fri, 8 Mar 2002, Alan Cox wrote:
>
> Can we go to cache line alignment - for an array of locks thats clearly
> advantageous

I disagree about the "clearly". Firstly, the cacheline alignment is CPU
dependent, so on some CPU's it's 32 bytes (or even 16), on others it is
128 bytes.

Secondly, a lot of locking is actually done inside a single thread, and
false sharing doesn't happen much - so keeping the locks dense can be
quite advantageous.

The cases where false sharing _does_ happen and are a problem should be
for the application writer to worry about, not for the kernel to force.

So I think 8 bytes is plenty fine enough - with 16 bytes a remote
possibility (I don't think it is needed, but it gives you som epadding for
future expansion). And people who have arrays and find false sharing to be
a problem can fix it themselves.

I personally don't find arrays of locks very common. It's much more common
to have arrays of data structures that _contain_ locks (eg things like
having hash tables etc with a per-hashchain lock) and then those container
structures may want to be cacheline aligned, but the locks themselves
should not need to be.

                Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 15 2002 - 22:00:10 EST