RFR: 8278241: Implement JVM SpinPause on linux-aarch64 [v4]

Andrew Haley aph at openjdk.java.net
Tue Dec 14 15:05:09 UTC 2021


On Tue, 14 Dec 2021 13:20:47 GMT, Evgeny Astigeevich <duke at openjdk.java.net> wrote:

>> This JVM SpinPause uses a spin wait stub. The stub is generated based on the `SpinWait` description which is defined with `OnSpinWaitInst`/`OnSpinWaitInstCount` options.  The `SpinWait` provides the description of the instruction and the instruction count.
>> 
>> The `SpinWait` description is also used for the `_onSpinWait()` intrinsic. We don't have use cases when we need different implementations for the `_onSpinWait()` intrinsic and JVM SpinPause.
>> 
>> Testing results for fastdebug and release builds:
>> - `gtest`: Passed
>> - `tier1`...`tier4`: Passed
>> - `hotspot/jtreg/runtime/Thread/TestSpinPause.java`: Passed
>> 
>> JVM SpinPause is used for the synchronised statements and can benchmarked with `org.openjdk.bench.vm.lang.LockUnlock.testContendedLock`.
>> 
>> Benchmarking results (number of samples per an experiment: 150) for Graviton2 (Neoverse N1), 1 ISB instruction:
>> 
>> 
>> 
>> +-----------+-------------------+------------+-----------+-----------+----------+---------+
>> | CPU cores | Contended threads | Base ns/op |   Error   |    New    |  Error   |  Diff   |
>> +-----------+-------------------+------------+-----------+-----------+----------+---------+
>> |         8 |                64 |  10007.213 | ±910.911  |  8527.346 | ±377.242 | -14.79% |
>> |        16 |                64 |  10274.935 | ±880.568  |  8310.433 | ±326.845 | -19.12% |
>> |        32 |                64 |  12231.947 | ±1525.364 |  9205.941 | ±394.409 | -24.74% |
>> |        64 |                64 |    9929.49 | ±586.074  | 10488.695 | ±570.458 | 5.63%   |
>> |        64 |                32 |   5605.119 | ±629.340  |  5023.882 | ±230.639 | -10.37% |
>> |        64 |                16 |   2817.346 | ±263.696  |  2367.528 | ±94.158  | -15.97% |
>> |        64 |                 2 |    870.389 | ±530.579  |   464.395 | ±126.260 | -46.65% |
>> +-----------+-------------------+------------+-----------+-----------+----------+---------+
>
> Evgeny Astigeevich has updated the pull request incrementally with one additional commit since the last revision:
> 
>   RET only StubRoutines::aarch64::spin_wait() for SpinWait::NONE

Two more changes. The first makes the code simpler, and the second makes it less fragile.


diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
index a8b2820bb62..e946f3be970 100644
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
@@ -6403,9 +6403,7 @@ class StubGenerator: public StubCodeGenerator {
     StubCodeMark mark(this, "StubRoutines", "spin_wait");
     address start = __ pc();
 
-    if (VM_Version::spin_wait_desc().inst() != SpinWait::NONE) {
-      __ spin_wait();
-    }
+    __ spin_wait();
     __ ret(lr);
 
     return start;
diff --git a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp
index bb1a3325cea..f7c27ea7380 100644
--- a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp
@@ -57,7 +57,10 @@ address StubRoutines::aarch64::_string_indexof_linear_uu = NULL;
 address StubRoutines::aarch64::_string_indexof_linear_ul = NULL;
 address StubRoutines::aarch64::_large_byte_array_inflate = NULL;
 address StubRoutines::aarch64::_method_entry_barrier = NULL;
-address StubRoutines::aarch64::_spin_wait = NULL;
+
+static void spin_wait_nop() { }
+address StubRoutines::aarch64::_spin_wait = CAST_FROM_FN_PTR(address, spin_wait_nop);
+
 bool StubRoutines::aarch64::_completed = false;
 
 /**

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

PR: https://git.openjdk.java.net/jdk/pull/6803


More information about the hotspot-dev mailing list