unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Christoph Müllner" <christoph.muellner@vrull.eu>
To: libc-alpha@sourceware.org,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Darius Rad <darius@bluespec.com>,
	Andrew Waterman <andrew@sifive.com>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Evan Green <evan@rivosinc.com>,
	Kito Cheng <kito.cheng@sifive.com>,
	Jeff Law <jeffreyalaw@gmail.com>,
	Vineet Gupta <vineetg@rivosinc.com>
Cc: "Christoph Müllner" <christoph.muellner@vrull.eu>
Subject: [RFC PATCH 0/3] RISC-V: Use WRS.STO for atomic_spin_nop
Date: Thu, 18 Apr 2024 11:46:32 +0200	[thread overview]
Message-ID: <20240418094635.3502009-1-christoph.muellner@vrull.eu> (raw)

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


             reply	other threads:[~2024-04-18  9:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18  9:46 Christoph Müllner [this message]
2024-04-18  9:46 ` [RFC PATCH 1/3] RISC-V: Sync hwprobe: Sync extension bits with Linux 6.8 Christoph Müllner
2024-04-18  9:46 ` [RFC PATCH 2/3] RISC-V: hwprobe: Add Zawrs test bit Christoph Müllner
2024-04-18  9:46 ` [RFC PATCH 3/3] RISC-V: Implement CPU yielding for busy loops with Zihintpause/Zawrs Christoph Müllner
2024-04-18 17:17   ` Palmer Dabbelt
2024-04-18 20:03     ` Vineet Gupta
2024-04-18 20:25       ` Christoph Müllner
2024-04-18 20:19     ` Christoph Müllner
2024-04-18 20:36       ` Vineet Gupta
2024-04-18 21:10         ` Palmer Dabbelt
2024-04-19 14:09           ` Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240418094635.3502009-1-christoph.muellner@vrull.eu \
    --to=christoph.muellner@vrull.eu \
    --cc=adhemerval.zanella@linaro.org \
    --cc=andrew@sifive.com \
    --cc=darius@bluespec.com \
    --cc=evan@rivosinc.com \
    --cc=jeffreyalaw@gmail.com \
    --cc=kito.cheng@sifive.com \
    --cc=libc-alpha@sourceware.org \
    --cc=palmer@dabbelt.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=vineetg@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).