mbox series

[0/6] powerpc/qspinlock: Fix yield latency bug and other

Message ID 20231016124305.139923-1-npiggin@gmail.com (mailing list archive)
Headers show
Series powerpc/qspinlock: Fix yield latency bug and other | expand

Message

Nicholas Piggin Oct. 16, 2023, 12:42 p.m. UTC
This fixes a long-standing latency bug in the powerpc qspinlock
implementation that quite a few people have reported and helped
out with debugging.

The first patch is a minimal fix that avoids the problem. The
other patches are streamlining and improvements after the fix.

Thanks,
Nick

Nicholas Piggin (6):
  powerpc/qspinlock: Fix stale propagated yield_cpu
  powerpc/qspinlock: stop queued waiters trying to set lock sleepy
  powerpc/qspinlock: propagate owner preemptedness rather than CPU
    number
  powerpc/qspinlock: don't propagate the not-sleepy state
  powerpc/qspinlock: Propagate sleepy if previous waiter is preempted
  powerpc/qspinlock: Rename yield_propagate_owner tunable

 arch/powerpc/lib/qspinlock.c | 119 +++++++++++++++--------------------
 1 file changed, 52 insertions(+), 67 deletions(-)

Comments

Shrikanth Hegde Oct. 18, 2023, 7:41 a.m. UTC | #1
On 10/16/23 6:12 PM, Nicholas Piggin wrote:
> This fixes a long-standing latency bug in the powerpc qspinlock
> implementation that quite a few people have reported and helped
> out with debugging.
> 
> The first patch is a minimal fix that avoids the problem. The
> other patches are streamlining and improvements after the fix.
> 

Hi Nick, Thanks for the fix. This issue has been happening in various
scenarios when there was vCPU contention.

Tested this on Power10 Shared processor LPAR(SPLPAR) based on powerVM.
System has two SPLPARs. on LPAR1 trying various scenarios and
LPAR2 is running constant stress-ng threads consuming 100% its CPU.
LPAR1: 96VP, 64EC and LPAR2 is 32VP, 32EC.

lscpu of LPAR1:
Architecture:            ppc64le
  Byte Order:            Little Endian
CPU(s):                  768


  On-line CPU(s) list:   0-767


Model name:              POWER10 (architected), altivec supported
  Model:                 2.0 (pvr 0080 0200)
  Thread(s) per core:    8

Scenarios tried on LPAR1:
1. run ppc64_cpu --smt=1 and ppc64_cpu --smt=8 to switch between SMT=1
   and SMT=8
2. create a cgroup, assign 5% quota to it and run same number of
   stress-ng as number of CPUs within that cgroup.
3. Run a suite of microbenchmarks such as unixbench, schbench, hackbench
   stress-ng with perf enabled.

baseline was tip/master at 84ab57184ff4 (origin/master, origin/HEAD)
Merge branch into tip/master: 'x86/tdx'

Hard lockup was SEEN in each of the above scenario with baseline.
With this patch series applied hard lockup was NOT SEEN in each of
the above scenario.

So,
Tested-by: Shrikanth Hegde <sshegde@linux.vnet.ibm.com>

> Thanks,
> Nick
> 
> Nicholas Piggin (6):
>   powerpc/qspinlock: Fix stale propagated yield_cpu
>   powerpc/qspinlock: stop queued waiters trying to set lock sleepy
>   powerpc/qspinlock: propagate owner preemptedness rather than CPU
>     number
>   powerpc/qspinlock: don't propagate the not-sleepy state
>   powerpc/qspinlock: Propagate sleepy if previous waiter is preempted
>   powerpc/qspinlock: Rename yield_propagate_owner tunable
> 
>  arch/powerpc/lib/qspinlock.c | 119 +++++++++++++++--------------------
>  1 file changed, 52 insertions(+), 67 deletions(-)
>
Nysal Jan K.A. Oct. 20, 2023, 10:04 a.m. UTC | #2
On Mon, Oct 16, 2023 at 10:42:59PM +1000, Nicholas Piggin wrote:
> This fixes a long-standing latency bug in the powerpc qspinlock
> implementation that quite a few people have reported and helped
> out with debugging.
> 
> The first patch is a minimal fix that avoids the problem. The
> other patches are streamlining and improvements after the fix.
> 
> Thanks,
> Nick
> 
> Nicholas Piggin (6):
>   powerpc/qspinlock: Fix stale propagated yield_cpu
>   powerpc/qspinlock: stop queued waiters trying to set lock sleepy
>   powerpc/qspinlock: propagate owner preemptedness rather than CPU
>     number
>   powerpc/qspinlock: don't propagate the not-sleepy state
>   powerpc/qspinlock: Propagate sleepy if previous waiter is preempted
>   powerpc/qspinlock: Rename yield_propagate_owner tunable
> 
>  arch/powerpc/lib/qspinlock.c | 119 +++++++++++++++--------------------
>  1 file changed, 52 insertions(+), 67 deletions(-)
> 
> -- 
> 2.42.0
> 
Just a minor comment regarding patch 2.

For the series:

Reviewed-by: Nysal Jan K.A <nysal@linux.ibm.com>
Michael Ellerman Oct. 20, 2023, 12:01 p.m. UTC | #3
On Mon, 16 Oct 2023 22:42:59 +1000, Nicholas Piggin wrote:
> This fixes a long-standing latency bug in the powerpc qspinlock
> implementation that quite a few people have reported and helped
> out with debugging.
> 
> The first patch is a minimal fix that avoids the problem. The
> other patches are streamlining and improvements after the fix.
> 
> [...]

Patch 1 applied to powerpc/fixes.

[1/6] powerpc/qspinlock: Fix stale propagated yield_cpu
      https://git.kernel.org/powerpc/c/f9bc9bbe8afdf83412728f0b464979a72a3b9ec2

cheers
Michael Ellerman Oct. 27, 2023, 9:59 a.m. UTC | #4
On Mon, 16 Oct 2023 22:42:59 +1000, Nicholas Piggin wrote:
> This fixes a long-standing latency bug in the powerpc qspinlock
> implementation that quite a few people have reported and helped
> out with debugging.
> 
> The first patch is a minimal fix that avoids the problem. The
> other patches are streamlining and improvements after the fix.
> 
> [...]

Applied to powerpc/next.

[2/6] powerpc/qspinlock: stop queued waiters trying to set lock sleepy
      https://git.kernel.org/powerpc/c/f6568647382c667912245c8d07aa26c9c6d4d0c8
[3/6] powerpc/qspinlock: propagate owner preemptedness rather than CPU number
      https://git.kernel.org/powerpc/c/fd8fae50c9c6117c4e05954deab2cc515508666b
[4/6] powerpc/qspinlock: don't propagate the not-sleepy state
      https://git.kernel.org/powerpc/c/fcf77d44274b96a55cc74043561a4b3151b9ad24
[5/6] powerpc/qspinlock: Propagate sleepy if previous waiter is preempted
      https://git.kernel.org/powerpc/c/1e6d5f725738fff83e1c3cbdb8547142eb8820c2
[6/6] powerpc/qspinlock: Rename yield_propagate_owner tunable
      https://git.kernel.org/powerpc/c/b629b541702b082d161c307c9d7d9867911fc933

cheers