RFR: 8366441: AArch64: Support WFET in OnSpinWait [v2]

Andrew Haley aph at openjdk.org
Fri Feb 6 10:40:48 UTC 2026


On Thu, 18 Dec 2025 16:31:04 GMT, Ruben <duke at openjdk.org> wrote:

>> Implement OnSpinWait based on WFET - wait for event with timeout:
>>  - introduce OnSpinWaitDelay - the OnSpinWait time in nanoseconds;
>>  - the OnSpinWaitInstCount is expected to be 1 when WFET is used;
>>  - the waiting loop is followed by SB - to ensure following instructions aren't speculated until wait is finished;
>>  - the timer register is read via the self-synchronized view CNTVCTSS_EL0 to prevent the read being hoisted out of the loop.
>> 
>> The WFET and CNTVCTSS_EL0 read are added to aarch64-asmtest.py as hex values - using the instruction mnemonics would require support of -march=armv9-2.a, and consequently, the binutils 2.36+.
>
> Ruben has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix bsd_aarch64 build

src/hotspot/cpu/aarch64/globals_aarch64.hpp line 118:

> 116:           range(-1, 4096)                                               \
> 117:   product(ccstr, OnSpinWaitInst, "yield", DIAGNOSTIC,                   \
> 118:           "The instruction to use to implement "                        \

Suggestion:

          "The instruction to use for "                        \

src/hotspot/cpu/aarch64/globals_aarch64.hpp line 125:

> 123:           "The number of OnSpinWaitInst instructions to generate."      \
> 124:           "It cannot be used with OnSpinWaitInst=none."                 \
> 125:           "For OnSpinWaitInst=wfet it is required to be 1.")            \

Suggestion:

          "For OnSpinWaitInst=wfet it must be 1.")            \

Required by whom?

src/hotspot/cpu/aarch64/spin_wait_aarch64.hpp line 57:

> 55:   int delay() const {
> 56:     assert(_inst == WFET, "Specifying the delay value is only supported for WFET");
> 57:     assert(_delay > 0, "The delay value should be positive");

Suggestion:

    assert(_delay > 0, "The delay value must be positive");

There is no alternative.

src/hotspot/cpu/aarch64/vm_version_aarch64.cpp line 65:

> 63:   if (spin_wait.inst() == SpinWait::WFET) {
> 64:     if (!VM_Version::supports_wfxt()) {
> 65:       vm_exit_during_initialization("OnSpinWaitInst is WFET but current CPU does not support WFET instruction");

Suggestion:

      vm_exit_during_initialization("OnSpinWaitInst is WFET but the CPU does not support the WFET instruction");

Several times.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27030#discussion_r2773442922
PR Review Comment: https://git.openjdk.org/jdk/pull/27030#discussion_r2773439209
PR Review Comment: https://git.openjdk.org/jdk/pull/27030#discussion_r2773450315
PR Review Comment: https://git.openjdk.org/jdk/pull/27030#discussion_r2773453723


More information about the hotspot-dev mailing list