Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH v6 0/8] futex: Use runtime constants for futex_hash computation
@ 2026-07-28  5:25 K Prateek Nayak
  2026-07-28  5:25 ` [PATCH v6 1/8] x86/runtime-const: Introduce runtime_const_mask_32() K Prateek Nayak
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: K Prateek Nayak @ 2026-07-28  5:25 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Sebastian Andrzej Siewior, Charlie Jenkins, Borislav Petkov,
	Dave Hansen, x86, Catalin Marinas, Will Deacon, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev
  Cc: Darren Hart, Davidlohr Bueso, André Almeida, linux-arch,
	linux-kernel, linux-s390, linux-riscv, linux-arm-kernel,
	K Prateek Nayak, H. Peter Anvin, Sean Christopherson, Thomas Huth,
	Jisheng Zhang, Ben Dooks, Samuel Holland,
	Radim Krčmář, Guo Ren, Christian Borntraeger,
	Sven Schnelle


tl;dr

This series introduces runtime_const_mask_32() and uses runtime
constants for __ro_after_init data in futex_hash() hot path. More
information can be found on v2 at
https://lore.kernel.org/lkml/20260316052401.18910-1-kprateek.nayak@amd.com/

Notable changes in v5
=====================

Intel test robot flagged a case of compilers re-ordering the
runtime_const usage before their initialization in futex_init() at
https://lore.kernel.org/lkml/202607091538.58e3f39-lkp@intel.com/.
This was fixed by adding a barrier() after the runtime_const_init() bits
in futex_init() to prevent this re-ordering.

Sashiko flagged that __fls(val), when val is 0, can be optimized by the
compiler to consider val as non-zero and silently optimize the
BUG_ON(!val && ...) to only consider the latter bits, skipping the !val
check. Fix this by explicitly checking val before __fls().

Testing
=======

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.

Patches are based on:

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

at commit 8d0b0ef04514 ("Merge branch into tip/master: 'x86/tdx'")
(27-07-2026)

Diffstat from v5 is essentially 5+++++-- with effectively 3 lines of
code change and 2 newlines; Resending for convenience since adding
parital diffs to v5 was getting too finnicky and this is easier for
pickup.

Charlie's optimization for RISC-V bits to patch slli + srli with
andi + nop if mask fits the immediate encoding is left to a later series
once this is merged.
(https://lore.kernel.org/lkml/178366995930.1208691.2993932866462893112.b4-review@b4/)

Few comments from checkpatch.pl have been ignored to adhere to the style
of the particular file. If something needs addressing, please let me
know and I'll address it with a v6.X fixups unless there is a larger
change that will require a re-spin

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 and the lists will be receiving the whole
series (sorry in advance!)
---
changelog v5..v6:

o Added a barrier after runtime_const_init() to prevent compilers from
  re-ordering their access before the initialization in futex_init().
  (Sashiko, Intel test robot)

o Added a zero check before __fls() to prevent smart compiler
  optimizations of a later BUG_ON(). (Sashiko)

o Picked up Peter's S-o-b from his tree.

o Collected tags from Charlie. (Thanks a ton!)

o Rebased on latest tip.

v5: https://lore.kernel.org/lkml/20260630045531.3939-1-kprateek.nayak@amd.com/
---
K Prateek Nayak (5):
  arm64/runtime-const: Use aarch64_insn_patch_text_nosync() for patching
  arm64/runtime-const: Introduce runtime_const_mask_32()
  riscv/runtime-const: Replace open-coded placeholder with RUNTIME_MAGIC
  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 | 63 ++++++++++++++++----
 arch/riscv/include/asm/asm.h           |  1 +
 arch/riscv/include/asm/runtime-const.h | 82 ++++++++++++++++++++------
 arch/s390/include/asm/runtime-const.h  | 22 ++++++-
 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                    | 44 ++++++++------
 8 files changed, 181 insertions(+), 51 deletions(-)


base-commit: 8d0b0ef045143e7ebf2b4c3ad5347bc1e0e45a80
-- 
2.34.1


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

end of thread, other threads:[~2026-07-28  5:42 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28  5:25 [PATCH v6 0/8] futex: Use runtime constants for futex_hash computation K Prateek Nayak
2026-07-28  5:25 ` [PATCH v6 1/8] x86/runtime-const: Introduce runtime_const_mask_32() K Prateek Nayak
2026-07-28  5:37   ` sashiko-bot
2026-07-28  5:25 ` [PATCH v6 2/8] arm64/runtime-const: Use aarch64_insn_patch_text_nosync() for patching K Prateek Nayak
2026-07-28  5:35   ` sashiko-bot
2026-07-28  5:25 ` [PATCH v6 3/8] arm64/runtime-const: Introduce runtime_const_mask_32() K Prateek Nayak
2026-07-28  5:36   ` sashiko-bot
2026-07-28  5:25 ` [PATCH v6 4/8] riscv/runtime-const: Replace open-coded placeholder with RUNTIME_MAGIC K Prateek Nayak
2026-07-28  5:34   ` sashiko-bot
2026-07-28  5:25 ` [PATCH v6 5/8] riscv/runtime-const: Introduce runtime_const_mask_32() K Prateek Nayak
2026-07-28  5:38   ` sashiko-bot
2026-07-28  5:25 ` [PATCH v6 6/8] s390/runtime-const: " K Prateek Nayak
2026-07-28  5:36   ` sashiko-bot
2026-07-28  5:25 ` [PATCH v6 7/8] asm-generic/runtime-const: Add dummy runtime_const_mask_32() K Prateek Nayak
2026-07-28  5:34   ` sashiko-bot
2026-07-28  5:25 ` [PATCH v6 8/8] futex: Use runtime constants for __futex_hash() hot path K Prateek Nayak
2026-07-28  5:42   ` sashiko-bot

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