<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/arch, branch contended-release-qspinlock</title>
<subtitle>Linux kernel source tree.</subtitle>
<id>https://git.ilvokhin.com/linux.git/atom/arch?h=contended-release-qspinlock</id>
<link rel='self' href='https://git.ilvokhin.com/linux.git/atom/arch?h=contended-release-qspinlock'/>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/'/>
<updated>2026-07-29T13:07:29Z</updated>
<entry>
<title>x86/paravirt: Trace contended_release on unlock</title>
<updated>2026-07-29T13:07:29Z</updated>
<author>
<name>Dmitry Ilvokhin</name>
<email>d@ilvokhin.com</email>
</author>
<published>2026-07-27T16:47:45Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=b65e9e77eb73462a2c122c8d53bad1e2d55f8122'/>
<id>urn:sha1:b65e9e77eb73462a2c122c8d53bad1e2d55f8122</id>
<content type='text'>
On PARAVIRT_SPINLOCKS=y kernels queued_spin_unlock() is dispatched
through a static_call(), and those kernels are quite common. Gating
contended_release behind a static branch there would leave a NOP on the
unlock path even while the tracepoint is disabled. Since the
static_call() is already present, swap its target to a traced unlock
while the tracepoint is enabled instead. When it is disabled the target
is the plain unlock (an inline store on native), so the unlock path is
unchanged and the tracepoint is truly zero-cost.

Implement the arch_contended_release_trace_reg() and
arch_contended_release_trace_unreg() hooks to update the
queued_spin_unlock static_call() on the tracepoint's enable and disable
transitions. Provide two traced variants,
native_queued_spin_unlock_traced() and pv_queued_spin_unlock_traced(),
so each tail-calls its own base unlock directly rather than recursing
through the now-traced static_call().

Teach pv_is_native_spin_unlock() that the traced native variant still
counts as native.

Only PARAVIRT_SPINLOCKS=y is affected. PARAVIRT_SPINLOCKS=n keeps the
generic static-branch path.

Signed-off-by: Dmitry Ilvokhin &lt;d@ilvokhin.com&gt;
</content>
</entry>
<entry>
<title>locking: Factor out queued_spin_release()</title>
<updated>2026-07-29T13:07:28Z</updated>
<author>
<name>Dmitry Ilvokhin</name>
<email>d@ilvokhin.com</email>
</author>
<published>2026-03-25T16:39:23Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=733cc31a061f6fe233108e14712e11a882ca56a9'/>
<id>urn:sha1:733cc31a061f6fe233108e14712e11a882ca56a9</id>
<content type='text'>
The contended_release tracepoint needs to hook queued_spin_unlock(), but
architectures with a custom unlock define queued_spin_unlock() directly,
leaving no single generic place to add the tracing.

Introduce queued_spin_release() as the arch-overridable release
primitive and make queued_spin_unlock() a generic wrapper around it.
An architecture that only customizes the release can then override
queued_spin_release() and inherit the generic wrapper.

Rename the MIPS override to queued_spin_release() accordingly. x86
paravirt overrides queued_spin_unlock() directly and is left unchanged.

No functional change intended.

Signed-off-by: Dmitry Ilvokhin &lt;d@ilvokhin.com&gt;
</content>
</entry>
<entry>
<title>x86/paravirt: Use static_call() for the paravirt spinlock ops</title>
<updated>2026-07-29T13:07:28Z</updated>
<author>
<name>Dmitry Ilvokhin</name>
<email>d@ilvokhin.com</email>
</author>
<published>2026-06-29T16:46:05Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=58216639dac7beb666a1727a943810742a0bbe9a'/>
<id>urn:sha1:58216639dac7beb666a1727a943810742a0bbe9a</id>
<content type='text'>
From: Peter Zijlstra &lt;peterz@infradead.org&gt;

queued_spin_lock_slowpath() and queued_spin_unlock() are dispatched
through pv_ops_lock via the paravirt-ops ALTERNATIVE machinery, which
picks the target (native inline store / hypervisor call) once at boot
and cannot change at runtime.

Convert both to static_call(). The site becomes a direct call patched in
place (one byte smaller), and on native the unlock still collapses to
the inline "movb $0, (%rdi)" store, so the fast path is unchanged.

Unlike the ALTERNATIVE mechanism, a static_call() target can also be
updated at runtime via static_call_update(). This is a prerequisite for
the contended_release tracepoint, which has to swap in a traced unlock
while the system is running.

Drop the now-unused
pv_ops_lock.{queued_spin_lock_slowpath,queued_spin_unlock} members and
the X86_FEATURE_PVUNLOCK feature bit. KVM, Xen and Hyper-V install their
backends with static_call_update(), and pv_is_native_spin_unlock() reads
the current target with static_call_query(). The native unlock is
emitted inline at the call site from __static_call_transform(),
mirroring the existing __static_call_return0 and __WARN_trap special
cases.

[ ilvokhin: fix PARAVIRT_SPINLOCKS=n build; teach
  __static_call_validate() about the inline unlock insn; make the
  slowpath site module-safe: static_call_mod() +
  EXPORT_STATIC_CALL_TRAMP(); pass @lock to the callee-save unlock,
  fixing a boot hang under CALL_DEPTH_TRACKING. Boot tested native + KVM
  PV guest. ]

Link: https://lore.kernel.org/all/20260603120811.GW3493090@noisy.programming.kicks-ass.net/
Co-developed-by: Dmitry Ilvokhin &lt;d@ilvokhin.com&gt;
Signed-off-by: Dmitry Ilvokhin &lt;d@ilvokhin.com&gt;
</content>
</entry>
<entry>
<title>s390/runtime-const: Introduce runtime_const_mask_32()</title>
<updated>2026-07-29T11:17:52Z</updated>
<author>
<name>K Prateek Nayak</name>
<email>kprateek.nayak@amd.com</email>
</author>
<published>2026-07-28T05:25:38Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=cf0de88094a7b4df18008b6efb1290f4efed731f'/>
<id>urn:sha1:cf0de88094a7b4df18008b6efb1290f4efed731f</id>
<content type='text'>
Futex hash computation requires a mask operation with read-only after
init data that will be converted to a runtime constant in the subsequent
commit.

Introduce runtime_const_mask_32 to further optimize the mask operation
in the futex hash computation hot path.

GCC generates a:

  nilf %r1,&lt;imm32&gt;

to tackle arbitrary 32-bit masks and the same is implemented here.
Immediate patching pattern for __runtime_fixup_mask() has been adopted
from __runtime_fixup_ptr().

Signed-off-by: K Prateek Nayak &lt;kprateek.nayak@amd.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Acked-by: Heiko Carstens &lt;hca@linux.ibm.com&gt;
Link: https://patch.msgid.link/20260728052540.4728-7-kprateek.nayak@amd.com
</content>
</entry>
<entry>
<title>riscv/runtime-const: Introduce runtime_const_mask_32()</title>
<updated>2026-07-29T11:17:45Z</updated>
<author>
<name>K Prateek Nayak</name>
<email>kprateek.nayak@amd.com</email>
</author>
<published>2026-07-28T05:25:37Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=e412c77541c7926ff61baec712616837a2c6887f'/>
<id>urn:sha1:e412c77541c7926ff61baec712616837a2c6887f</id>
<content type='text'>
Futex hash computation requires a mask operation with read-only after
init data that will be converted to a runtime constant in the subsequent
commit.

Introduce runtime_const_mask_32 to further optimize the mask operation
in the futex hash computation hot path. Since all the current use-cases
are of the form GENMASK(n, 0), with n &gt; 0, following sequence:

  srli a0, a1, imm
  slli a0, a0, imm

is used for RISC-V where imm = (31 - width) to improve instruction
density and performance.

"The RISC-V Instruction Set Manual, Volume I - Unprivileged
Architecture" [1] Sec. 2.4.1 "Integer Register-Immediate Instructions"
notes the immediate shift for SRLI and SLLI are 5 bits wide starting at
bit #10. __runtime_fixup_shift() is reused to patch the immediate shifts
for the two instructions.

If a future use case arises that needs to tackle arbitrary mask,
consider using:

  lui   a0, 0x12346       # upper; +0x800 then &gt;&gt;12 for correct rounding
  addi  a0, a0, 0x678     # lower 12 bits

to patch the 32-bit mask in the asm block and return "__ret &amp; (val)"
from runtime_const_mask_32() which allows compiler to further optimize
the logical and operation. __runtime_fixup_ptr() already patches a
lui + addi sequence which can be reused when the need arises.

A possible implementation for this alternate scheme can be found at [2].

Suggested-by: Samuel Holland &lt;samuel.holland@sifive.com&gt;
Suggested-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Assisted-by: Claude:claude-sonnet-4-5
Signed-off-by: K Prateek Nayak &lt;kprateek.nayak@amd.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Tested-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Link: https://docs.riscv.org/reference/isa/_attachments/riscv-unprivileged.pdf [1]
Link: https://lore.kernel.org/lkml/20260430094730.31624-6-kprateek.nayak@amd.com/ [2]
Link: https://patch.msgid.link/20260728052540.4728-6-kprateek.nayak@amd.com
</content>
</entry>
<entry>
<title>riscv/runtime-const: Replace open-coded placeholder with RUNTIME_MAGIC</title>
<updated>2026-07-28T11:07:15Z</updated>
<author>
<name>K Prateek Nayak</name>
<email>kprateek.nayak@amd.com</email>
</author>
<published>2026-07-28T05:25:36Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=ee10b1028129a73857593801614d5bf75a15b9c7'/>
<id>urn:sha1:ee10b1028129a73857593801614d5bf75a15b9c7</id>
<content type='text'>
Define the placeholder used for lui + addi[w] patching sequence as
RUNTIME_MAGIC and use that instead of open coding the constants in the
inline assembly.

No functional changes intended.

Suggested-by: Guo Ren &lt;guoren@kernel.org&gt;
Signed-off-by: K Prateek Nayak &lt;kprateek.nayak@amd.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Reviewed-by: Guo Ren &lt;guoren@kernel.org&gt;
Tested-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Link: https://patch.msgid.link/20260728052540.4728-5-kprateek.nayak@amd.com
</content>
</entry>
<entry>
<title>arm64/runtime-const: Introduce runtime_const_mask_32()</title>
<updated>2026-07-28T11:07:14Z</updated>
<author>
<name>K Prateek Nayak</name>
<email>kprateek.nayak@amd.com</email>
</author>
<published>2026-07-28T05:25:35Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=7eccf137dc044c802f11d3d60bc7fc29066fdf92'/>
<id>urn:sha1:7eccf137dc044c802f11d3d60bc7fc29066fdf92</id>
<content type='text'>
Futex hash computation requires a mask operation with read-only after
init data that will be converted to a runtime constant in the subsequent
commit.

Introduce runtime_const_mask_32 to further optimize the mask operation
in the futex hash computation hot path. Since all the current use-cases
are of the form GENMASK(n, 0), with n &gt; 0, a single:

  ubfx  w0, w0, #0, #widthm1     // w0 = w0 [widthm1:0]

instruction is used for amd64 to improve instruction dinsity and
performance.

"Arm A-profile A64 Instruction Set Architecture" manual, Sec.
"A64 -- Base Instructions" [1] for UBFX instruction highlights the
immediate "width" is encoded as width minus 1 in imms (Bits [15:10])
which is patched by __runtime_fixup_mask() once the mask is known.

If a future use case arises that needs to tackle arbitrary mask,
consider using:

  movz  w1, #lo16, lsl #0
  movk  w1, #hi16, lsl #16

to patch the 32-bit mask in the asm block and return "__ret &amp; (val)"
from runtime_const_mask_32() which allows compiler to further optimize
the logical and operation. __runtime_fixup_ptr() already patches a
"movz, + movk lsl #16" sequence which can be reused when the need
arises.

A possible implementation for this alternate scheme can be found at [2].

Suggested-by: Samuel Holland &lt;samuel.holland@sifive.com&gt;
Suggested-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: K Prateek Nayak &lt;kprateek.nayak@amd.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Tested-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Link: https://developer.arm.com/documentation/ddi0602/2026-03/Base-Instructions/ [1]
Link: https://lore.kernel.org/lkml/20260430094730.31624-4-kprateek.nayak@amd.com/ [2]
Link: https://patch.msgid.link/20260728052540.4728-4-kprateek.nayak@amd.com
</content>
</entry>
<entry>
<title>arm64/runtime-const: Use aarch64_insn_patch_text_nosync() for patching</title>
<updated>2026-07-28T11:07:14Z</updated>
<author>
<name>K Prateek Nayak</name>
<email>kprateek.nayak@amd.com</email>
</author>
<published>2026-07-28T05:25:34Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=a6690350a4ae7558b39d15fcc776c4d1ab5bbf39'/>
<id>urn:sha1:a6690350a4ae7558b39d15fcc776c4d1ab5bbf39</id>
<content type='text'>
The current scheme to directly patch the kernel text for runtime
constants runs into the following issue with futex adapted to using
runtime constants on arm64:

  Unable to handle kernel write to read-only memory at virtual address ...

The pc points to the *p assignment in the following call chain:

  futex_init()
    runtime_const_init(shift, __futex_shift)
      __runtime_fixup_shift()
        *p = cpu_to_le32(insn);

which suggests that core_initcall() is too late to patch the kernel text
directly unlike the "d_hash_shift" which is initialized during
vfs_caches_init_early() before the protections are in place.

Use aarch64_insn_patch_text_nosync() to patch the runtime constants
instead of doing it directly to allow runtime_const_init() slightly
later into the boot.

Since aarch64_insn_patch_text_nosync() calls caches_clean_inval_pou()
internally, __runtime_fixup_caches() ends up being redundant.
runtime_const_init() are rare and the overheads of multiple calls to
caches_clean_inval_pou() instead of batching them together should be
negligible in practice.

The cpu_to_le32() conversion of instruction isn't necessary since it is
handled later in the aarch64_insn_patch_text_nosync() call-chain:

  aarch64_insn_patch_text_nosync(addr, insn)
    aarch64_insn_write(addr, insn)
      __aarch64_insn_write(addr, cpu_to_le32(insn))

Sashiko noted that aarch64_insn_patch_text_nosync() does not expect a
lm_alias() address and Catalin suggested it is safe to drop the
lm_alias() for runtime patching since the kernel text is readable. The
address passed to fixup function is interpreted as a __le32 and
dereferenced as is to read the opcode at the patch site.

No functional changes are intended.

Signed-off-by: K Prateek Nayak &lt;kprateek.nayak@amd.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Reviewed-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Tested-by: Charlie Jenkins &lt;thecharlesjenkins@gmail.com&gt;
Link: https://patch.msgid.link/20260728052540.4728-3-kprateek.nayak@amd.com
</content>
</entry>
<entry>
<title>x86/runtime-const: Introduce runtime_const_mask_32()</title>
<updated>2026-07-28T11:07:14Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2026-07-28T05:25:33Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=775e0f2284554e24855c4372faeb957a5e515337'/>
<id>urn:sha1:775e0f2284554e24855c4372faeb957a5e515337</id>
<content type='text'>
Futex hash computation requires a mask operation with read-only after
init data that will be converted to a runtime constant in the subsequent
commit.

Introduce runtime_const_mask_32 to further optimize the mask operation
in the futex hash computation hot path.

  [ prateek: Broke off the x86 chunk, commit message. ]

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: K Prateek Nayak &lt;kprateek.nayak@amd.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://patch.msgid.link/20260227161841.GH606826@noisy.programming.kicks-ass.net
Link: https://patch.msgid.link/20260728052540.4728-2-kprateek.nayak@amd.com
</content>
</entry>
<entry>
<title>Merge tag 'x86-urgent-2026-07-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip</title>
<updated>2026-07-05T15:37:46Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-07-05T15:37:46Z</published>
<link rel='alternate' type='text/html' href='https://git.ilvokhin.com/linux.git/commit/?id=f105f3631d51e8d7c49bf18ec21b873e4f38e648'/>
<id>urn:sha1:f105f3631d51e8d7c49bf18ec21b873e4f38e648</id>
<content type='text'>
Pull x86 fix from Ingo Molnar:

 - Prevent OOB access in the resctrl code while offlining
   CPUs when Intel SNC (Sub-NUMA Clustering) is enabled
   (Reinette Chatre)

* tag 'x86-urgent-2026-07-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86,fs/resctrl: Prevent out-of-bounds access while offlining CPU when SNC enabled
</content>
</entry>
</feed>
