From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Chris Mason <clm@meta.com>,
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: Fri, 27 Jun 2025 14:24:34 +0200 [thread overview]
Message-ID: <20250627122434.LtaTjk_B@linutronix.de> (raw)
In-Reply-To: <20250626143638.GM1613200@noisy.programming.kicks-ass.net>
On 2025-06-26 16:36:38 [+0200], Peter Zijlstra wrote:
> > I guess that is why you said earlier with to use srcu. For
> > things like "hackbench -T" you end up creating a new hash on every
> > thread creation which is not applied because RCU takes a while.
> > This could be optimized later by checking if the hash in futex_phash_new
> > matches the requested size.
>
> So the main benefit of using SRCU (I have half a patch and a head-ache
> to show for it) is that you don't need the per-mm-per-cpu memory
> storage. The down-side is that you share the 'refcount' between all mm's
> so it gets to be even slower.
I see. So it is not just s/rcu/srcu/ for the hopefully quicker grace
period since it does not affect whole system. It a different algorithm.
> The 'problem' is that reasoning about stuff comes even harder. But the
> main idea is to replace mm->futex_phash with a 'tombstone' value to
> force __futex_hash() into taking the slow-path and hitting
> mm->futex_hash_lock.
>
> Then you do call_srcu() to wait one SRCU period, this has everybody
> stalled, and guarantees the fph you had is now unused so we can rehash.
> Then replace the tombstone with the new hash and start over.
>
> It's just that stuff like futex_hash_get() gets somewhat tricky, you
> have to ensure the SRCU periods overlap.
>
> Anyway, that approach should be feasible as well, just not sure of the
> trade-offs.
The current looks reasonable enough and it survived yesterday's testing.
> > Why preempt_disable()? Is it just an optimized version of
> > rcu_read_lock()? I don't understand why. You don't even go for
> > __this_cpu_inc() so I a bit puzzled.
>
> The code morphed a lot over the two days it took to write this. But
> yeah, preempt or rcu doesn't really matter here.
>
> I didn't yet think about __this_cpu, its not really relevant on x86. If
> you want to make that relaxation you have to consider IRQ and SoftIRQ
> handling though. Given we have this_cpu_inc() in the RCU callback, which
> is ran from SoftIRQ context, this might not be safe.
Nah, I am all for a simple cguard(rcu) here.
Sebastian
next prev parent reply other threads:[~2025-06-27 12:24 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
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 [this message]
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=20250627122434.LtaTjk_B@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=clm@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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®