[PATCH v6 8/8] futex: Use runtime constants for __futex_hash() hot path

Peter Zijlstra peterz at infradead.org
Tue Jul 28 04:08:06 PDT 2026


On Tue, Jul 28, 2026 at 12:46:53PM +0200, Peter Zijlstra wrote:
> On Tue, Jul 28, 2026 at 05:25:40AM +0000, K Prateek Nayak wrote:
> > From: Peter Zijlstra <peterz at infradead.org>
> > 
> > Runtime constify the read-only after init data  __futex_shift(shift_32),
> > __futex_mask(mask_32), and __futex_queues(ptr) used in __futex_hash()
> > hot path to avoid referencing global variable.
> > 
> > This also allows __futex_queues to be allocated dynamically to
> > "nr_node_ids" slots instead of reserving config dependent MAX_NUMNODES
> > (1 << CONFIG_NODES_SHIFT) worth of slots upfront.
> > 
> > Runtime constants are initialized before their first access and
> > runtime_const_init() provides necessary barrier to ensure subsequent
> > accesses are not reordered against their initialization.
> > 
> > No functional changes intended.
> > 
> >   [ prateek: Dynamically allocate __futex_queues, mark the global data
> >     __ro_after_init since they are constified after futex_init(). ]
> > 
> > Link: https://patch.msgid.link/20260227161841.GH606826@noisy.programming.kicks-ass.net
> > Reported-by: Sebastian Andrzej Siewior <bigeasy at linutronix.de> # MAX_NUMNODES bloat
> > Signed-off-by: Peter Zijlstra <peterz at infradead.org>
> > Reviewed-by: Charlie Jenkins <thecharlesjenkins at gmail.com>
> > Tested-by: Charlie Jenkins <thecharlesjenkins at gmail.com>
> > Signed-off-by: K Prateek Nayak <kprateek.nayak at amd.com>
> > ---
> > changelog v5..v6:
> > 
> > o Picked up tags from Charlie. (Thanks a ton!)
> > 
> > o Picked up Peter's S-o-b from his tree.
> 
> Right, so I also munged the Changelog in my tree to include those
> benchmark results. I failed to actually push out those patches before
> disappearing on holidays, but I recon I should refresh them patches and
> re-munge the changelog?

With a bit of luck I didn't wreck things and this new version should now
be available in queue/locking/core.



More information about the linux-riscv mailing list