Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8311696 | 17.0.9 | Fei Yang | P4 | Resolved | Fixed | b01 |
For RISCV, we use membars when accessing volatile _thread_state through Atomic::load_acquire in JavaThread::thread_state.
Accordingly, we should use Atomic::release_store to access volatile _thread_state in JavaThread::set_thread_state for this architecture.
This is correct for our JDK 11 version: both functions are guarded by a single-line macro check for architecures [1].
The code is refactored in JDK mainline: each function has their own macro check for architectures.
But looks like we only kept the macro check for RISCV64 in JavaThread::thread_state when porting from JDK 11.
The same check is missing for JavaThread::set_thread_state. We should add it back.
Simple fix:
diff --git a/src/hotspot/share/runtime/thread.inline.hpp b/src/hotspot/share/runtime/thread.inline.hpp
index 92dfdfa3dbe..ee7d48b8660 100644
--- a/src/hotspot/share/runtime/thread.inline.hpp
+++ b/src/hotspot/share/runtime/thread.inline.hpp
@@ -162,7 +162,7 @@ inline JavaThreadState JavaThread::thread_state() const {
inline void JavaThread::set_thread_state(JavaThreadState s) {
assert(current_or_null() == NULL || current_or_null() == this,
"state change should only be called by the current thread");
-#if defined(PPC64) || defined (AARCH64)
+#if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
// Use membars when accessing volatile _thread_state. See
// Threads::create_vm() for size checks.
Atomic::release_store((volatile jint*)&_thread_state, (jint)s);
[1] https://gitee.com/openeuler/bishengjdk-11/blob/risc-v/src/hotspot/share/runtime/thread.inline.hpp#L123
Accordingly, we should use Atomic::release_store to access volatile _thread_state in JavaThread::set_thread_state for this architecture.
This is correct for our JDK 11 version: both functions are guarded by a single-line macro check for architecures [1].
The code is refactored in JDK mainline: each function has their own macro check for architectures.
But looks like we only kept the macro check for RISCV64 in JavaThread::thread_state when porting from JDK 11.
The same check is missing for JavaThread::set_thread_state. We should add it back.
Simple fix:
diff --git a/src/hotspot/share/runtime/thread.inline.hpp b/src/hotspot/share/runtime/thread.inline.hpp
index 92dfdfa3dbe..ee7d48b8660 100644
--- a/src/hotspot/share/runtime/thread.inline.hpp
+++ b/src/hotspot/share/runtime/thread.inline.hpp
@@ -162,7 +162,7 @@ inline JavaThreadState JavaThread::thread_state() const {
inline void JavaThread::set_thread_state(JavaThreadState s) {
assert(current_or_null() == NULL || current_or_null() == this,
"state change should only be called by the current thread");
-#if defined(PPC64) || defined (AARCH64)
+#if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
// Use membars when accessing volatile _thread_state. See
// Threads::create_vm() for size checks.
Atomic::release_store((volatile jint*)&_thread_state, (jint)s);
[1] https://gitee.com/openeuler/bishengjdk-11/blob/risc-v/src/hotspot/share/runtime/thread.inline.hpp#L123
- backported by
-
JDK-8311696 riscv: should call Atomic::release_store in JavaThread::set_thread_state
- Resolved
- relates to
-
JDK-8276799 Implementation of JEP 422: Linux/RISC-V Port
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/966fc82d
-
Commit openjdk/jdk/e5e1aab4
-
Review openjdk/jdk17u-dev/1427
-
Review openjdk/jdk/8055
(1 links to)