From: Thomas Gleixner <tglx@kernel.org>
To: Dmitry Ilvokhin <d@ilvokhin.com>
Cc: Usama Arif <usama.arif@linux.dev>,
peterz@infradead.org, andrealmeid@igalia.com, dave@stgolabs.net,
dvhart@infradead.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, mingo@redhat.com,
shuah@kernel.org, shakeel.butt@linux.dev, hannes@cmpxchg.org,
riel@surriel.com, kernel-team@meta.com
Subject: Re: [PATCH] futex: Avoid hash-bucket locking for mismatched waits
Date: Fri, 21 Aug 2026 15:18:22 +0200 [thread overview]
Message-ID: <878q5zipcx.ffs@fw13> (raw)
In-Reply-To: <aocn4kp5F_2Y2e5O@shell.ilvokhin.com>
On Thu, Aug 20 2026 at 16:14, Dmitry Ilvokhin wrote:
> On Fri, Aug 14, 2026 at 06:02:45PM +0200, Thomas Gleixner wrote:
> I've built a benchmark to simulate this behaviour on the smaller scale
> and run it with two threads and `nproc` threads to simulate low and high
> contention cases. The benchmark is a bit on a extreme side, but I think
> it approximates the real world case quite well.
>
> The numbers below are averaged across 10 runs.
>
> SKYLAKE (2 NUMA NODES, 80 CPUS, Intel(R) Xeon(R) Gold 6138 CPU)
>
> Threads Baseline (ops/sec) Patched 95% CI Diff
> -----------------------------------------------------------------------
> 2 5,917,777 6,441,061 [ -1.98%, +19.67%] +8.84%
> 80 122,926 77,801 [-41.17%, -32.25%] -36.71%
>
>
> BERGAMO (1 NUMA NODE, 176 CPUS, AMD EPYC 9D64)
>
> Threads Baseline (ops/sec) Patched 95% CI Diff
> -----------------------------------------------------------------------
> 2 14,952,962 14,482,494 [ -4.62%, -1.68%] -3.15%
> 176 161,294 127,563 [-21.72%, -20.11%] -20.91%
>
>
> Skylake two thread case seems in line with ~5% improvement you measured,
> but numbers are quite noisy. Other runs do not look encouraging.
>
> It looks like early bail out amplifies contention problem even more.
> Instead of letting thread spin on the hb->lock, early check returns just
> for userspace to retry again moment later. Ideally, it would be better
> to park spinning thread as fast as possible and with early bail out we
> do opposite of that.
Changing the timing even slightly either in user space or in kernel
space results in different outcomes depending on the micro architecture,
NUMA, contention scenario ...
While it is benefical for some scenarios to avoid the wait/wake, for
others especially those with high concurrency in trying to acquire the
futex the cache line bouncing just gets worse.
And yes, you are right that with your benchmark the early bail amplifies
exactly that problem. The hash bucket lock contention eases the cache
line contention for the price of wasting CPU cycles in the kernel.
There is no magic cure for this with the current implementations and I
doubt that any benchmark will give a satisfying answer which is
generally useful accross a wider range of application scenarios.
This needs quite some thought and investigations to get right.
Thanks,
tglx
next prev parent reply other threads:[~2026-08-21 13:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 19:26 Usama Arif
2026-08-04 17:07 ` Dmitry Ilvokhin
2026-08-05 13:28 ` Usama Arif
2026-08-07 15:42 ` Thomas Gleixner
2026-08-10 12:17 ` Usama Arif
2026-08-14 16:01 ` Thomas Gleixner
2026-08-14 16:02 ` Thomas Gleixner
2026-08-20 15:19 ` Usama Arif
2026-08-20 16:23 ` Thomas Gleixner
2026-08-20 18:05 ` Usama Arif
2026-08-20 16:14 ` Dmitry Ilvokhin
2026-08-21 13:18 ` Thomas Gleixner [this message]
2026-08-08 9:19 ` Thomas Gleixner
2026-08-10 12:35 ` Usama Arif
2026-08-14 15:55 ` Thomas Gleixner
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=878q5zipcx.ffs@fw13 \
--to=tglx@kernel.org \
--cc=andrealmeid@igalia.com \
--cc=d@ilvokhin.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=shakeel.butt@linux.dev \
--cc=shuah@kernel.org \
--cc=usama.arif@linux.dev \
/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®