From: Peter Zijlstra <peterz@infradead.org>
To: Chris Mason <clm@meta.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: futex performance regression from "futex: Allow automatic allocation of process wide futex hash"
Date: Thu, 26 Jun 2025 15:17:15 +0200 [thread overview]
Message-ID: <20250626131715.GI1613200@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <71ea52f2-f6bf-4a55-84ba-d1442d13bc82@meta.com>
On Thu, Jun 26, 2025 at 07:01:23AM -0400, Chris Mason wrote:
> On 6/24/25 3:01 PM, Peter Zijlstra wrote:
> > On Fri, Jun 06, 2025 at 09:06:38AM +0200, Sebastian Andrzej Siewior wrote:
> >> On 2025-06-05 20:55:27 [-0400], Chris Mason wrote:
> >>>>> We've got large systems that are basically dedicated to single
> >>>>> workloads, and those will probably miss the larger global hash table,
> >>>>> regressing like schbench did. Then we have large systems spread over
> >>>>> multiple big workloads that will love the private tables.
> >>>>>
> >>>>> In either case, I think growing the hash table as a multiple of thread
> >>>>> count instead of cpu count will probably better reflect the crazy things
> >>>>> multi-threaded applications do? At any rate, I don't think we want
> >>>>> applications to need prctl to get back to the performance they had on
> >>>>> older kernels.
> >>>>
> >>>> This is only an issue if all you CPUs spend their time in the kernel
> >>>> using the hash buckets at the same time.
> >>>> This was the case in every benchmark I've seen so far. Your thing might
> >>>> be closer to an actual workload.
> >>>>
> >>>
> >>> I didn't spend a ton of time looking at the perf profiles of the slower
> >>> kernel, was the bottleneck in the hash chain length or in contention for
> >>> the buckets?
> >>
> >> Every futex operation does a rcuref_get() (which is an atomic inc) on
> >> the private hash. This is before anything else happens. If you have two
> >> threads, on two CPUs, which simultaneously do a futex() operation then
> >> both do this rcuref_get(). That atomic inc ensures that the cacheline
> >> bounces from one CPU to the other. On the exit of the syscall there is a
> >> matching rcuref_put().
> >
> > How about something like this (very lightly tested)...
> >
> > the TL;DR is that it turns all those refcounts into per-cpu ops when
> > there is no hash replacement pending (eg. the normal case), and only
> > folds the lot into an atomic when we really care about it.
> >
> > There's some sharp corners still.. but it boots and survives the
> > (slightly modified) selftest.
>
> I can get some benchmarks going of this, thanks. For 6.16, is the goal
> to put something like this in, or default to the global hash table until
> we've nailed it down?
>
> I'd vote for defaulting to global for one more release.
Probably best to do that; means we don't have to rush crazy code :-)
next prev parent reply other threads:[~2025-06-26 13:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 19:00 Chris Mason
2025-06-04 9:28 ` Sebastian Andrzej Siewior
2025-06-04 15:48 ` Chris Mason
2025-06-04 20:08 ` Sebastian Andrzej Siewior
2025-06-06 0:55 ` Chris Mason
2025-06-06 7:06 ` Sebastian Andrzej Siewior
2025-06-06 21:06 ` Chris Mason
2025-06-06 22:17 ` Chris Mason
2025-06-24 19:01 ` Peter Zijlstra
2025-06-26 11:01 ` Chris Mason
2025-06-26 13:17 ` Peter Zijlstra [this message]
2025-06-26 13:50 ` Sebastian Andrzej Siewior
2025-06-27 11:04 ` Peter Zijlstra
2025-06-27 12:14 ` Sebastian Andrzej Siewior
2025-06-30 14:50 ` [PATCH] futex: Temporary disable FUTEX_PRIVATE_HASH Sebastian Andrzej Siewior
2025-07-01 13:13 ` [tip: locking/urgent] " tip-bot2 for Sebastian Andrzej Siewior
2025-07-16 1:34 ` [PATCH] " kernel test robot
2025-06-26 13:48 ` futex performance regression from "futex: Allow automatic allocation of process wide futex hash" Sebastian Andrzej Siewior
2025-06-26 14:36 ` Peter Zijlstra
2025-06-27 12:24 ` Sebastian Andrzej Siewior
2025-06-27 22:48 ` Tim Chen
2025-06-28 8:23 ` Peter Zijlstra
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=20250626131715.GI1613200@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=clm@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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®