JDK-8321075 : RISC-V: UseSystemMemoryBarrier lacking proper OS support
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 20,21,22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: riscv
  • Submitted: 2023-11-30
  • Updated: 2024-03-11
  • Resolved: 2024-02-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 22 JDK 23
21.0.4Fixed 22.0.2Fixed 23 b11Fixed
Related Reports
Relates :  
Description
Linux risc-v port is lacking correct barriers in the kernel for the membarrier() syscall to actually have the correct semantic in user-space.

https://lore.kernel.org/lkml/041c83e6-1ca5-4953-bcec-03571135165d@efficios.com/

UseSystemMemoryBarrier should not be allowed to turned on when running on Linux/RV.

There is no way telling from the syscall if this is on non-working kernel or a post 6.6 (cross-fingers it get fixed to 6.7) with a working syscall.
The linux membarrier wrapper should probably be informed on the current kernel version to determine if it's usable or not.
Comments
[jdk22u-fix-request] Approval Request from Robbin Ehn JDK 22 is affected by this bug. Applies cleanly locally compiled and tested.
04-03-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk22u/pull/83 Date: 2024-03-04 08:32:20 +0000
04-03-2024

[jdk21u-fix-request] Approval Request from Ludovic Henry Doesn't apply cleanly due to https://github.com/openjdk/jdk/commit/9ded86821b01d6d790850e9b49eedfc597c0c9a2 bue conflict is minimal (int vs long). The change is purely a fix on RISC-V hidden behind a `#if defined(RISCV)` and has been verified to work well on openjdk/jdk on riscv64.
27-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/294 Date: 2024-02-27 09:04:02 +0000
27-02-2024

Sorry I forgot to link the initial feature issue. So this is only in 20+, hence yes to 21.
25-02-2024

Should it be backported to 21, 17 and 11?
24-02-2024

Changeset: 68eb5a1d Author: Robbin Ehn <rehn@openjdk.org> Date: 2024-02-21 08:58:19 +0000 URL: https://git.openjdk.org/jdk/commit/68eb5a1df5afdc011aa467f1c723a8792532dd3f
21-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17889 Date: 2024-02-16 13:01:20 +0000
16-02-2024

As we are not sure of what kernel version it will be fixed in, a very simple fix may be something like: #ifdef RISCV log_info(os)("Linux/RISC-V don't support membarrier()"); return false; #endif LinuxSystemMemoryBarrier::initialize()
30-11-2023