RFR: 8315856: RISC-V: Use Zacas extension for cmpxchg

Robbin Ehn rehn at openjdk.org
Mon Dec 4 07:24:39 UTC 2023


On Mon, 4 Dec 2023 06:32:59 GMT, Fei Yang <fyang at openjdk.org> wrote:

>> 8315856: RISC-V: Use Zacas extension for cmpxchg
>
> src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 2630:
> 
>> 2628:     mv(tmp, oldv);
>> 2629:     atomic_cas(tmp, newv, addr, Assembler::int64, Assembler::aq, Assembler::rl);
>> 2630:     beq(tmp, oldv, succeed);
> 
> The Zacas spec says: `The memory operation performed by an AMOCAS.W/D/Q, when not successful, has acquire semantics if aq bit is 1 but does not have release semantics, regardless of rl.`
> 
> So when the CAS fails, I think we are lacking the needed semantics which is enforced at L2645 for the else block. Seems that we should place a `membar(AnyAny);` after the `beq` instruction when  like our aarch64 counterpart [1].
> 
> [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L2758

Good! Yea, we discussed that internally and I thought we fixed that, those changes seems to have been lost, thanks!

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16910#discussion_r1413457961


More information about the hotspot-dev mailing list