Skip to content
Commit 42e48084 authored by Guo Ren's avatar Guo Ren
Browse files

riscv: Add queued_spinlock support

The requirements of qspinlock have been documented by commit:
a8ad07e5 ("asm-generic: qspinlock: Indicate the use of mixed-size
atomics").

Although RISC-V ISA gives out a weaker forward guarantee LR/SC, which
doesn't satisfy the requirements of qspinlock above, it won't prevent
some riscv vendors from implementing a strong fwd guarantee LR/SC in
microarchitecture to match xchg_tail requirement. T-HEAD C9xx processor
is the one.

We've tested the patch on SOPHGO SG2042 [1] and passed the stress test
(Fedora/Ubuntu/OpenEuler ...). Here is the performance comparison
between qspinlock and ticket_lock:

sysbench test=threads threads=32 yields=100 lock=8 (+13.7%):
  queued_spinlock 0.5109/0.00
  ticket_spinlock 0.5814/0.00

perf futex/hash (+6.7%):
  queued_spinlock 14443937 operations/sec (+- 0.09%)
  ticket_spinlock 1353215 operations/sec (+- 0.15%)

perf futex/wake-parallel (+8.6%):
  queued_spinlock (waking 1/64 threads) in 0.0253 ms (+-2.90%)
  ticket_spinlock (waking 1/64 threads) in 0.0275 ms (+-3.12%)

perf futex/requeue (4.2%):
  queued_spinlock Requeued 64 of 64 threads in 0.0785 ms (+-0.55%)
  ticket_spinlock Requeued 64 of 64 threads in 0.0818 ms (+-4.12%)

The qspinlock has a significant improvement on SOPHGO SG2042 than the
ticket_lock.

[1] https://en.sophgo.com/product/introduce/sg2042.html



Signed-off-by: default avatarGuo Ren <guoren@kernel.org>
Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
parent 8a507976
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment