RFR: 8301852: RISC-V: Optimize class atomic when order is memory_order_relaxed
Dingli Zhang
dzhang at openjdk.org
Mon Feb 6 12:26:36 UTC 2023
This PR will optimize some function in class atomic. We will not need FULL_MEM_BARRIER anymore when order is memory_order_relaxed. This is the first version and maybe we can improve this part with different memory order in the further, just like [JDK-8274615](https://bugs.openjdk.org/browse/JDK-8274615) and [JDK-8261649](https://bugs.openjdk.org/browse/JDK-8261649).
The following call stack uses memory_order_relaxed:
#0 Atomic::PlatformAdd<8ul>::add_and_fetch<unsigned long, unsigned long> (this=0x40038851d0, dest=0x40035b0820 <MallocMemorySummary::_snapshot+576>, add_value=1, order=memory_order_relaxed)
at /home/dingli/jdk/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp:40
#1 0x0000004001d200a2 in Atomic::AddImpl<unsigned long, unsigned long, void>::add_and_fetch (dest=0x40035b0820 <MallocMemorySummary::_snapshot+576>, add_value=1, order=memory_order_relaxed)
at /home/dingli/jdk/src/hotspot/share/runtime/atomic.hpp:681
#2 0x0000004001d1ff9a in Atomic::add<unsigned long, unsigned long> (dest=0x40035b0820 <MallocMemorySummary::_snapshot+576>, add_value=1, order=memory_order_relaxed)
at /home/dingli/jdk/src/hotspot/share/runtime/atomic.hpp:662
#3 0x0000004001d1f55c in MemoryCounter::allocate (this=0x40035b0820 <MallocMemorySummary::_snapshot+576>, sz=96) at /home/dingli/jdk/src/hotspot/share/services/mallocTracker.hpp:63
#4 0x0000004002613608 in MallocMemory::record_malloc (this=0x40035b0820 <MallocMemorySummary::_snapshot+576>, sz=96) at /home/dingli/jdk/src/hotspot/share/services/mallocTracker.hpp:113
#5 0x0000004002613676 in MallocMemorySummary::record_malloc (size=96, flag=MEMFLAGS::mtInternal) at /home/dingli/jdk/src/hotspot/share/services/mallocTracker.hpp:244
By the way, this PR will also polish inline assembly code of PlatformCmpxchg.
## Testing:
- all tier1 on unmatched board without new failures
-------------
Commit messages:
- Optimize class atomic when order is memory_order_relaxed
Changes: https://git.openjdk.org/jdk/pull/12434/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12434&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8301852
Stats: 36 lines in 1 file changed: 18 ins; 1 del; 17 mod
Patch: https://git.openjdk.org/jdk/pull/12434.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12434/head:pull/12434
PR: https://git.openjdk.org/jdk/pull/12434
More information about the hotspot-runtime-dev
mailing list