[RFC PATCH 0/3] RISC-V: Use WRS.STO for atomic_spin_nop
Christoph Müllner
christoph.muellner@vrull.eu
Thu Apr 18 09:46:32 GMT 2024
This series utilizes the recently introduced hwprobe() and ifunc support
in RISC-V to implement atomic_spin_nop. The generic code uses the PAUSE
instruction (specified in Zihintpause as HINT instruction).
If hwprobe() report availability of Zawrs, then WRS.STO is used instead.
All specification are ratified. However, The second patch is not ready
to land in glibc yet, because the RISCV_HWPROBE_EXT_ZAWRS macro is not
defined in upstream Linux yet (there is just a patch from Andrew Jones
on LKML). Therefore, this patch is marked as RFC. See also:
https://lore.kernel.org/all/20240315134009.580167-10-ajones@ventanamicro.com/
The first patch of this series imports all HWPROBE macros from Linux 6.8.
As this patch has not further dependencies, it could be merged any time.
This patch was tested with a simple test code that calls
pthread_spin_lock() twice (triggering the spinning).
This program was compiled for rv64gc and executed using QEMU.
A small modification in QEMU was used to report if WRS.STO
was executed (-cpu "rv64,zawrs=false" vs -cpu "rv64,zawrs=true").
Christoph Müllner (3):
RISC-V: Sync hwprobe: Sync extension bits with Linux 6.8
RISC-V: hwprobe: Add Zawrs test bit
RISC-V: Implement CPU yielding for busy loops with Zihintpause/Zawrs
sysdeps/riscv/multiarch/cpu-relax_generic.S | 31 +++++++++++++++
sysdeps/riscv/multiarch/cpu-relax_zawrs.S | 28 +++++++++++++
.../unix/sysv/linux/riscv/atomic-machine.h | 3 ++
.../unix/sysv/linux/riscv/multiarch/Makefile | 8 ++++
.../sysv/linux/riscv/multiarch/cpu-relax.c | 39 +++++++++++++++++++
.../linux/riscv/multiarch/ifunc-impl-list.c | 32 +++++++++++++--
sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h | 30 ++++++++++++++
7 files changed, 167 insertions(+), 4 deletions(-)
create mode 100644 sysdeps/riscv/multiarch/cpu-relax_generic.S
create mode 100644 sysdeps/riscv/multiarch/cpu-relax_zawrs.S
create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/cpu-relax.c
--
2.44.0
More information about the Libc-alpha
mailing list