From: Jamie Lokier <jamie@shareable.org>
To: "Hu, Boris" <boris.hu@intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Split futex global spinlock futex_lock
Date: Wed, 10 Sep 2003 12:07:44 +0100 [thread overview]
Message-ID: <20030910110744.GD21313@mail.jlokier.co.uk> (raw)
In-Reply-To: <37FBBA5F3A361C41AB7CE44558C3448E01C0B69E@pdsmsx403.ccr.corp.intel.com>
Hu, Boris wrote:
> Split futex global spinlock futex_lock into hash bucket spinlocks.
> +/*
> + * Split the global futex_lock into every hash list lock.
> + */
> +struct futex_hash_bucket {
> + struct list_head chain;
> + spinlock_t lock;
> +};
Put "lock" first: it is always the first field accessed. That will
save a few clock cycles on some systems.
I was going to suggest something about cache alignment, but of course
that doesn't make sense. If the structure is made any larger,
it might as well contain more hash buckets.
Thinking a little deeper, it occurs to me that for scalable SMP
performance, you want:
(1 << FUTEX_HASHBITS) > some factor * SMP_CACHE_BYTES * NR_CPUS / sizeof (bucket)
To put it into perspective, consider a hypothetical 16-way P4.
SMP_CACHE_BYTES is 128 on a P4. That's 24 cache lines in the whole hash table.
If there are only a few futexes in the table at any time, the dominant
time for each operation is going to be the spinlock and associated
cache line transfers, not traversing a bucket's list.
So that hypothetical box would have an effective hash table of only 24 buckets.
What I'm saying is:
If you're able to benchmark changes to the code on a big box,
and you want to tune it's performance, try changing
FUTEX_HASHBITS. Also try adding a dummy word into
futex_hash_bucket, and use __cache_aligned_in_smp on the array so that
no buckets straddle two cache lines.
Thought for the day...
-- Jamie
next prev parent reply other threads:[~2003-09-10 11:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-10 5:23 Hu, Boris
2003-09-10 6:47 ` William Lee Irwin III
2003-09-10 7:36 ` Ulrich Drepper
2003-09-10 9:36 ` Ulrich Drepper
2003-09-10 10:23 ` Jamie Lokier
2003-09-10 11:07 ` Jamie Lokier [this message]
2003-09-11 7:02 Hu, Boris
2003-09-15 15:07 ` Rusty Russell
2003-09-16 4:48 ` Ulrich Drepper
2003-09-16 11:11 ` Jamie Lokier
2003-09-16 11:04 ` Jamie Lokier
2003-09-17 1:55 ` Rusty Russell
2003-09-16 7:31 Hu, Boris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030910110744.GD21313@mail.jlokier.co.uk \
--to=jamie@shareable.org \
--cc=boris.hu@intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®