mbox series

[RFC,v2,0/6] RISC-V: Add dynamic TSO support

Message ID 20240209064050.2746540-1-christoph.muellner@vrull.eu (mailing list archive)
Headers show
Series RISC-V: Add dynamic TSO support | expand

Message

Christoph Müllner Feb. 9, 2024, 6:40 a.m. UTC
The upcoming RISC-V Ssdtso specification introduces a bit in the senvcfg
CSR to switch the memory consistency model of user mode at run-time from
RVWMO to TSO. The active consistency model can therefore be switched on a
per-hart base and managed by the kernel on a per-process base.

This patchset implements basic Ssdtso support and adds a prctl API on top
so that user-space processes can switch to a stronger memory consistency
model (than the kernel was written for) at run-time.
The patchset also comes with a short documentation of the prctl API.

This series is based on the third draft of the Ssdtso specification
which can be found here:
  https://github.com/riscv/riscv-ssdtso/releases/tag/v1.0-draft3
Note, that the Ssdtso specification is in development state
(i.e., not frozen or even ratified) which is also the reason
why this series is marked as RFC.

This series saw the following changes since v1:
* Reordered/restructured patches
* Fixed build issues
* Addressed typos
* Removed ability to switch TSO->WMO
* Moved the state from per-thread to per-process
* Reschedule all CPUs after switching
* Some cleanups in the documentation
* Adding compatibility with Ztso (spec change in draft 3)

This patchset can also be found in this GitHub branch:
  https://github.com/cmuellner/linux/tree/ssdtso-v2

A QEMU implementation of DTSO can be found in this GitHub branch:
  https://github.com/cmuellner/qemu/tree/ssdtso-v2

Christoph Müllner (6):
  mm: Add dynamic memory consistency model switching
  uapi: prctl: Add new prctl call to set/get the memory consistency
    model
  RISC-V: Enable dynamic memory consistency model support with Ssdtso
  RISC-V: Implement prctl call to set/get the memory consistency model
  RISC-V: Expose Ssdtso via hwprobe API
  RISC-V: selftests: Add DTSO tests

 Documentation/arch/riscv/hwprobe.rst          |  3 +
 .../mm/dynamic-memory-consistency-model.rst   | 86 ++++++++++++++++
 Documentation/mm/index.rst                    |  1 +
 arch/Kconfig                                  | 14 +++
 arch/riscv/Kconfig                            | 11 +++
 arch/riscv/include/asm/csr.h                  |  1 +
 arch/riscv/include/asm/dtso.h                 | 97 +++++++++++++++++++
 arch/riscv/include/asm/hwcap.h                |  1 +
 arch/riscv/include/asm/processor.h            |  7 ++
 arch/riscv/include/asm/switch_to.h            |  3 +
 arch/riscv/include/uapi/asm/hwprobe.h         |  1 +
 arch/riscv/kernel/Makefile                    |  1 +
 arch/riscv/kernel/asm-offsets.c               |  3 +
 arch/riscv/kernel/cpufeature.c                |  1 +
 arch/riscv/kernel/dtso.c                      | 67 +++++++++++++
 arch/riscv/kernel/sys_hwprobe.c               |  2 +
 include/linux/sched.h                         |  5 +
 include/uapi/linux/prctl.h                    |  5 +
 kernel/sys.c                                  | 12 +++
 tools/testing/selftests/riscv/Makefile        |  2 +-
 tools/testing/selftests/riscv/dtso/.gitignore |  1 +
 tools/testing/selftests/riscv/dtso/Makefile   | 11 +++
 tools/testing/selftests/riscv/dtso/dtso.c     | 82 ++++++++++++++++
 23 files changed, 416 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/mm/dynamic-memory-consistency-model.rst
 create mode 100644 arch/riscv/include/asm/dtso.h
 create mode 100644 arch/riscv/kernel/dtso.c
 create mode 100644 tools/testing/selftests/riscv/dtso/.gitignore
 create mode 100644 tools/testing/selftests/riscv/dtso/Makefile
 create mode 100644 tools/testing/selftests/riscv/dtso/dtso.c