linux-stable/arch/powerpc/lib
Nicholas Piggin f9bc9bbe8a powerpc/qspinlock: Fix stale propagated yield_cpu
yield_cpu is a sample of a preempted lock holder that gets propagated
back through the queue. Queued waiters use this to yield to the
preempted lock holder without continually sampling the lock word (which
would defeat the purpose of MCS queueing by bouncing the cache line).

The problem is that yield_cpu can become stale. It can take some time to
be passed down the chain, and if any queued waiter gets preempted then
it will cease to propagate the yield_cpu to later waiters.

This can result in yielding to a CPU that no longer holds the lock,
which is bad, but particularly if it is currently in H_CEDE (idle),
then it appears to be preempted and some hypervisors (PowerVM) can
cause very long H_CONFER latencies waiting for H_CEDE wakeup. This
results in latency spikes and hard lockups on oversubscribed
partitions with lock contention.

This is a minimal fix. Before yielding to yield_cpu, sample the lock
word to confirm yield_cpu is still the owner, and bail out of it is not.

Thanks to a bunch of people who reported this and tracked down the
exact problem using tracepoints and dispatch trace logs.

Fixes: 28db61e207 ("powerpc/qspinlock: allow propagation of yield CPU down the queue")
Cc: stable@vger.kernel.org # v6.2+
Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Reported-by: Laurent Dufour <ldufour@linux.ibm.com>
Reported-by: Shrikanth Hegde <sshegde@linux.vnet.ibm.com>
Debugged-by: "Nysal Jan K.A" <nysal@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Shrikanth Hegde <sshegde@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231016124305.139923-2-npiggin@gmail.com
2023-10-18 21:07:21 +11:00
..
checksum_32.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
checksum_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
checksum_wrappers.c net: unexport csum_and_copy_{from,to}_user 2022-04-29 14:37:59 -07:00
code-patching.c powerpc/code-patching: Fix oops with DEBUG_VM enabled 2022-12-16 23:59:43 +11:00
copy_32.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
copy_mc_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
copypage_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
copypage_power7.S powerpc: add CFUNC assembly label annotation 2023-04-20 12:54:24 +10:00
copyuser_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
copyuser_power7.S powerpc: add CFUNC assembly label annotation 2023-04-20 12:54:24 +10:00
crtsavres.S
div64.S
error-inject.c powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
feature-fixups-test.S powerpc: Test prefixed instructions in feature fixups 2020-05-19 00:11:02 +10:00
feature-fixups.c powerpc/features: Add capability to update mmu features later 2023-08-02 22:22:17 +10:00
hweight_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
ldstfp.S
locks.c powerpc/pseries: Move some PAPR paravirt functions to their own file 2020-07-26 23:34:26 +10:00
Makefile powerpc: Drop zalloc_maybe_bootmem() 2023-08-24 22:33:16 +10:00
mem_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
memcmp_32.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
memcmp_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
memcpy_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
memcpy_power7.S powerpc: add CFUNC assembly label annotation 2023-04-20 12:54:24 +10:00
pmem.c powerpc: Remove memcpy_page_flushcache() 2023-03-29 23:53:02 +11:00
qspinlock.c powerpc/qspinlock: Fix stale propagated yield_cpu 2023-10-18 21:07:21 +11:00
quad.S
restart_table.c powerpc/64s: add a table of implicit soft-masked addresses 2021-06-30 22:21:20 +10:00
rheap.c
sstep.c powerpc/step: Mark __copy_mem_out() and __emulate_dcbz() __always_inline 2023-08-16 23:54:48 +10:00
string.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
string_32.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
string_64.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
strlen_32.S powerpc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-16 23:54:48 +10:00
test-code-patching.c powerpc/code-patching: Replace patch_instruction() by ppc_inst_write() in selftests 2021-12-23 22:36:58 +11:00
test_emulate_step.c powerpc/ppc-opcode: Define and use PPC_RAW_SETB() 2022-07-27 21:36:05 +10:00
test_emulate_step_exec_instr.S powerpc: add definition for pt_regs offset within an interrupt frame 2022-12-02 17:54:08 +11:00
vmx-helper.c powerpc: Fix reschedule bug in KUAP-unlocked user copy 2022-10-18 22:46:19 +11:00
xor_vmx.c lib/xor: make xor prototypes more friendly to compiler vectorization 2022-02-11 20:39:39 +11:00
xor_vmx.h lib/xor: make xor prototypes more friendly to compiler vectorization 2022-02-11 20:39:39 +11:00
xor_vmx_glue.c lib/xor: make xor prototypes more friendly to compiler vectorization 2022-02-11 20:39:39 +11:00