Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8311711 | 17.0.9 | Fei Yang | P4 | Resolved | Fixed | b01 |
The usage of fence.i is in-efficient or redundant in the current implementation of riscv port now. The riscv port has already followed the [RISC-V platform specification](https://github.com/riscv/riscv-platform-specs/blob/main/riscv-platform-spec.adoc): the write hart use the __builtin__clear_cache or the syscall riscv_flush_icache directly after modifying code in riscv port, to execute fence.i on local hart and other harts by IPI. That's because fence.i only synchronizes the local hart, and the OS can reschedule the user hart to a different physical hart after the fence.i.
"To order older stores before younger instruction fetches, user-level programs must use system supplied
library calls (e.g. GNU libc's __riscv_flush_icache, which invokes the Linux kernel's
corresponding vDSO routine), rather than executing the fence.i instruction directly."
What now seems unnecessary is that we also put fence.i in front of code that will be modifed concurrently, just like Aarch64 port. Because the icache flush syscall already provides the explicit icache synchronization between all harts, so that we can remove fence.i used in the read hart.
Details of the discussion can be found in https://mail.openjdk.org/pipermail/riscv-port-dev/2022-July/000571.html.
In contrast, the isb in aarch64 is not broadcast by the writing PE, so any other PE must perform its own isb synchronization after it knows that the instruction update is visible.
"To order older stores before younger instruction fetches, user-level programs must use system supplied
library calls (e.g. GNU libc's __riscv_flush_icache, which invokes the Linux kernel's
corresponding vDSO routine), rather than executing the fence.i instruction directly."
What now seems unnecessary is that we also put fence.i in front of code that will be modifed concurrently, just like Aarch64 port. Because the icache flush syscall already provides the explicit icache synchronization between all harts, so that we can remove fence.i used in the read hart.
Details of the discussion can be found in https://mail.openjdk.org/pipermail/riscv-port-dev/2022-July/000571.html.
In contrast, the isb in aarch64 is not broadcast by the writing PE, so any other PE must perform its own isb synchronization after it knows that the instruction update is visible.
- backported by
-
JDK-8311711 riscv: remove fence.i used in user space
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/966fc82d
-
Commit openjdk/jdk/5a539e8d
-
Commit openjdk/riscv-port-jdk11u/d4b0021a
-
Review openjdk/jdk17u-dev/1427
-
Review openjdk/jdk/9770
-
Review openjdk/riscv-port-jdk11u/16
-
Review openjdk/riscv-port-jdk17u/13
(3 links to)