Re: [PATCH v6 8/8] futex: Use runtime constants for __futex_hash() hot path
Peter Zijlstra <[email protected]> Tue, 28 Jul 2026 12:46:53 +0200
| Newsgroups | org.kernel.vger.linux-arch,org.infradead.lists.linux-arm-kernel,org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel,org.kernel.vger.linux-s390 |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 28, 2026 at 05:25:40AM +0000, K Prateek Nayak wrote: > From: Peter Zijlstra <[email protected]> > > 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/[email protected] > Reported-by: Sebastian Andrzej Siewior <[email protected]> # MAX_NUMNODES bloat > Signed-off-by: Peter Zijlstra <[email protected]> > Reviewed-by: Charlie Jenkins <[email protected]> > Tested-by: Charlie Jenkins <[email protected]> > Signed-off-by: K Prateek Nayak <[email protected]> > --- > 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? > o Added a barrier after runtime_const_init() after to prevent compilers > from re-ordering a later runtime const usage in the init function with > their initialization. (Sashiko; Reported by Intel test robot with a > GCC14 build). > (https://lore.kernel.org/lkml/alNgNvhIkBfkGo1Y@xsang-OptiPlex-9020/)