AArch64: Implementing spin pauses with ISB

Andrew Haley aph-open at littlepinkcloud.com
Sat Sep 4 10:30:36 UTC 2021


On 9/4/21 6:37 AM, Peter Kessler (Open Source) wrote:

> Why this is not also an issue for C code?  Shouldn't SpinPause()
> call a function from the C library, possibly a (GCC) built-in
> function implemented with a choice of NOP, YIELD, ISB, or whatever
> as appropriate on the architecture?

Ouch. I can't think of any good reason why it should, and we'd have to
dump many registers of state to call it. Let C provide its builtins,
and we'll provide ours.

> The original post referred to improvements in MySQL and MongoDB,
> neither of which is written in the Java programming language.  The
> Java platform intrinsic would need to pick an implementation, if
> calling the C library function was too time-consuming, or not
> time-consuming enough.

Yep. Right now ISB looks like a decent-enough choice.

> In addition to making the choice of implementation switchable, it
> would be good to get the default setting of that switch from
> vm_version_aarch64.cpp so vendors could set it appropriately for
> their implementations.

I'm assuming that is what will happen. However, I'm still intrigued by
the possibility that the best solution is actually implementation
as much as hardware dependent, particularly with many threads and high
contention. And what we really need may be randomized exponential
backoff, which is adaptive rather than fixed.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the hotspot-dev mailing list