public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/7] futex: Use runtime constants for futex_hash computation
@ 2026-03-16  5:23 K Prateek Nayak
  2026-03-16  5:23 ` [RFC PATCH v2 1/7] x86/runtime-const: Introduce runtime_const_mask_32() K Prateek Nayak
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: K Prateek Nayak @ 2026-03-16  5:23 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Sebastian Andrzej Siewior, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, Borislav Petkov, Dave Hansen, x86, Catalin Marinas,
	Will Deacon, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Arnd Bergmann
  Cc: Darren Hart, Davidlohr Bueso, André Almeida, linux-arch,
	linux-kernel, linux-arm-kernel, linux-riscv, linux-s390,
	K Prateek Nayak, Alexandre Ghiti, H. Peter Anvin, Kiryl Shutsemau,
	Sean Christopherson, Charlie Jenkins, Charles Mirabile,
	Christian Borntraeger, Sven Schnelle, Thomas Huth, Jisheng Zhang

Use runtime consts for futex_mask, futex_queues, and futex_shift, all of
which is used in the __futex_hash() hot path. With runtime-const, the
futex_queues can be allocated dynamically to only nr_node_ids slots
which saves a bit of space and was the main motivation for v1.

To support the mask operation, runtime_const_mask_32() has been added
and implemented for all the architectures supporting runtime const. x86
implementation was provided by Peter in [1] and rest is me looking at
gcc disassembly with a helping hand from Claude to plumb the rest -
these are likely the bits that needs more review.

Apart from x86, which was build and boot tested on baremetal, all the
other architectures have been build and boot tested with cross-compile +
QEMU with some light sanity testing on each.

Reviews and feedback are much appreciated.

Patches are based on:

  git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master

at commit 1def441ca008 ("Merge branch into tip/master: 'x86/tdx'") dated
15-03-2026.

Everyone has been Cc'd on the cover-letter and the futex bits for the
context. Respective arch maintainers, reviewers, and whoever got lucky
with get_maintainer.pl have been Cc'd on their respective arch specific
changes. Futex maintainers, reviewers, and the lists will be receiving
the whole series.

References:

[1] https://lore.kernel.org/all/20260227161841.GH606826@noisy.programming.kicks-ass.net/

---
changelog rfc v1..rfc v2:

o Use runtime constants to avoid the dereference overheads for
  dynamically allocated futex_queues.

o arch/ side plumbings for runtime_const_mask_32()

rfc v1: https://lore.kernel.org/all/20260128101358.20954-1-kprateek.nayak@amd.com/
---
K Prateek Nayak (4):
  arm64/runtime-const: Introduce runtime_const_mask_32()
  arm64/runtime-const: Use aarch64_insn_patch_text_nosync() for patching
  riscv/runtime-const: Introduce runtime_const_mask_32()
  s390/runtime-const: Introduce runtime_const_mask_32()

Peter Zijlstra (3):
  x86/runtime-const: Introduce runtime_const_mask_32()
  asm-generic/runtime-const: Add dummy runtime_const_mask_32()
  futex: Use runtime constants for __futex_hash() hot path

 arch/arm64/include/asm/runtime-const.h | 34 +++++++++++++++------
 arch/riscv/include/asm/runtime-const.h | 24 +++++++++++++++
 arch/s390/include/asm/runtime-const.h  | 19 ++++++++++++
 arch/x86/include/asm/runtime-const.h   | 14 +++++++++
 include/asm-generic/runtime-const.h    |  1 +
 include/asm-generic/vmlinux.lds.h      |  5 ++-
 kernel/futex/core.c                    | 42 ++++++++++++++------------
 7 files changed, 109 insertions(+), 30 deletions(-)


base-commit: 1def441ca0085042d41aa8614bee7269bd7e18ff
-- 
2.43.0



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-03-17  5:11 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16  5:23 [RFC PATCH v2 0/7] futex: Use runtime constants for futex_hash computation K Prateek Nayak
2026-03-16  5:23 ` [RFC PATCH v2 1/7] x86/runtime-const: Introduce runtime_const_mask_32() K Prateek Nayak
2026-03-16  5:23 ` [RFC PATCH v2 2/7] arm64/runtime-const: " K Prateek Nayak
2026-03-16 11:50   ` David Laight
2026-03-16 17:09     ` K Prateek Nayak
2026-03-16  5:23 ` [RFC PATCH v2 3/7] arm64/runtime-const: Use aarch64_insn_patch_text_nosync() for patching K Prateek Nayak
2026-03-16 11:52   ` David Laight
2026-03-16 17:13     ` K Prateek Nayak
2026-03-16  5:23 ` [RFC PATCH v2 4/7] riscv/runtime-const: Introduce runtime_const_mask_32() K Prateek Nayak
2026-03-16  5:23 ` [RFC PATCH v2 5/7] s390/runtime-const: " K Prateek Nayak
2026-03-16 19:19   ` Heiko Carstens
2026-03-17  1:55     ` K Prateek Nayak
2026-03-16  5:24 ` [RFC PATCH v2 6/7] asm-generic/runtime-const: Add dummy runtime_const_mask_32() K Prateek Nayak
2026-03-16  5:24 ` [RFC PATCH v2 7/7] futex: Use runtime constants for __futex_hash() hot path K Prateek Nayak
2026-03-16  8:14   ` Sebastian Andrzej Siewior
2026-03-16 17:15     ` K Prateek Nayak
2026-03-17  3:06   ` Samuel Holland
2026-03-17  5:11     ` K Prateek Nayak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox