lkml.org 
[lkml]   [2003]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Split futex global spinlock futex_lock
I don't agree with this change,

Rusty Russell wrote:
> This doesn't do what you expect, unfortunately. You need:
>
> struct futex_hash_bucket {
> spinlock_t lock;
> struct list_head chain;
> } ____cacheline_aligned_in_smp;
>
> static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS]
> __cacheline_aligned_in_smp;

> Also, Jamie was hinting at a sectored approach: optimal memory
> footprint/speed balance might be one lock in one cache-line-worth of
> list_head.

That was before I thought a bit more :)

If you're increasing the size of futex_hash_bucket, you can put
multiple lists in each one (as you observed). That reduces the
average list length, making hash operations faster when the table is
quite full.

There isn't any speed penalty for having a lock per list_head when you
do that, because the cache line has to bounce anyway for the
list_head, and locks are small. (On HT, where cache lines are shared
between sibling CPUs, a lock per list is a slight improvement).

Therefore, if cache line transfer between CPUs is a bottleneck, it
makes more sense to increase FUTEX_HASHBITS than to increase the
alignment of each bucket.

Increasing the alignment from 12 bytes to 16 bytes, to prevent buckets
straddling 2 cache lines, makes sense though. (Alternatively using a
single-linked list would do the trick, and be kinder on UP).

> Uli, can we ask you for benchmarks with this change, too?

Theoretically, I'd expect slightly better performance from increasing
FUTEX_HASHBITS than from this change, if there is any improvement at all.

Note that we're still bouncing mmap_sem on every futex operation, so
if the 6% improvement from splitting locks is anything to go by,
splitting mmap_sem should make a further measureable improvement,
although it might slow down the rest of the kernel.

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

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.070 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site