RFR: 8370947: Mitigate Neoverse-N1 erratum 1542419 negative impact on GenZGC performance [v6]
Axel Boldt-Christmas
aboldtch at openjdk.org
Wed Nov 26 09:06:59 UTC 2025
On Tue, 25 Nov 2025 17:37:38 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:
>> Arm Neoverse N1 erratum 1542419: "The core might fetch a stale instruction from memory which violates the ordering of instruction fetches". It is fixed in Neoverse N1 r4p1.
>>
>> Neoverse-N1 implementations mitigate erratum 1542419 with a workaround:
>> - Disable coherent icache.
>> - Trap IC IVAU instructions.
>> - Execute:
>> - `tlbi vae3is, xzr`
>> - `dsb sy`
>>
>> `tlbi vae3is, xzr` invalidates translations for all address spaces (global for address). It waits for all memory accesses using in-scope old translation information to complete before it is considered complete.
>>
>> As this workaround has significant overhead, Arm Neoverse N1 (MP050) Software Developer Errata Notice version 29.0 suggests:
>>
>> "Since one TLB inner-shareable invalidation is enough to avoid this erratum, the number of injected TLB invalidations should be minimized in the trap handler to mitigate the performance impact due to this workaround."
>>
>> This PR introduces a mechanism to defer instruction cache (ICache) invalidation for AArch64 to address the Arm Neoverse N1 erratum 1542419, which causes significant performance overhead if ICache invalidation is performed too frequently. The implementation includes detection of affected Neoverse N1 CPUs and automatic enabling of the workaround for relevant Neoverse N1 revisions.
>>
>> Changes include:
>>
>> * Added a new diagnostic JVM flag `NeoverseN1Errata1542419` to enable or disable the workaround for the erratum. The flag is automatically enabled for Neoverse N1 CPUs prior to r4p1, as detected during VM initialization.
>> * Introduced the `ICacheInvalidationContext` class to manage deferred ICache invalidation, with platform-specific logic for AArch64. This context is used to batch ICache invalidations, reducing performance impact. As the address for icache invalidation is not relevant, we use the nmethod's code start address.
>> * Provided a default (no-op) implementation for `ICacheInvalidationContext` on platforms where the workaround is not needed, ensuring portability and minimal impact on other architectures.
>> * Modified barrier patching and relocation logic (`ZBarrierSetAssembler`, `ZNMethod`, `RelocIterator`, and related code) to accept a `defer_icache_invalidation` parameter, allowing ICache invalidation to be deferred and later performed in bulk.
>>
>> Benchmarking results: Neoverse-N1 r3p1 (Graviton 2)
>>
>> - Baseline
>>
>> $ taskset -c 0-3 java -Xbootclasspath/a:./wb.jar -XX:+UnlockDiagnosticVMOptions -XX:-NeoverseN1...
>
> Evgeny Astigeevich has updated the pull request incrementally with two additional commits since the last revision:
>
> - Remove redundant include
> - Move ICacheInvalidationContext::pd_ to icache_linux_aarch64
Some style comments.
src/hotspot/os_cpu/linux_aarch64/icache_linux_aarch64.hpp line 77:
> 75: assert(((cache_info >> CTR_IDC_SHIFT) & 0x1) != 0x0, "Expect CTR_EL0.IDC to be enabled");
> 76: assert(((cache_info >> CTR_DIC_SHIFT) & 0x1) == 0x0, "Expect CTR_EL0.DIC to be disabled");
> 77: #endif
Not sure if this should be `#ifndef PRODUCT` or `#ifdef ASSERT`.
But regardless, `#ifndef PRODUCT` should be paired with `guarantees` and `#ifdef ASSERT` should be paired with `asserts`.
src/hotspot/share/gc/z/zGeneration.cpp line 1439:
> 1437: if (_bs_nm->is_armed(nm)) {
> 1438: {
> 1439: ICacheInvalidationContext icic;
Style.
Suggestion:
ICacheInvalidationContext icic;
src/hotspot/share/gc/z/zMark.cpp line 723:
> 721: if (_bs_nm->is_armed(nm)) {
> 722: {
> 723: ICacheInvalidationContext icic;
Style.
Suggestion:
ICacheInvalidationContext icic;
src/hotspot/share/gc/z/zNMethod.cpp line 375:
> 373:
> 374: {
> 375: ICacheInvalidationContext icic;
Style.
Suggestion:
ICacheInvalidationContext icic;
src/hotspot/share/gc/z/zUnload.cpp line 85:
> 83: }
> 84: ZIsUnloadingOopClosure cl(nm);
> 85: ICacheInvalidationContext icic;
Sytle.
Could you reorder this two lines too.
```c++
ICacheInvalidationContext icic;
ZIsUnloadingOopClosure cl(nm);
src/hotspot/share/runtime/icache.hpp line 77:
> 75: NONCOPYABLE(ICacheInvalidationContext);
> 76:
> 77: private:
Style.
Suggestion:
private:
NONCOPYABLE(ICacheInvalidationContext);
-------------
PR Review: https://git.openjdk.org/jdk/pull/28328#pullrequestreview-3509739850
PR Review Comment: https://git.openjdk.org/jdk/pull/28328#discussion_r2564006359
PR Review Comment: https://git.openjdk.org/jdk/pull/28328#discussion_r2564012438
PR Review Comment: https://git.openjdk.org/jdk/pull/28328#discussion_r2564014015
PR Review Comment: https://git.openjdk.org/jdk/pull/28328#discussion_r2564015380
PR Review Comment: https://git.openjdk.org/jdk/pull/28328#discussion_r2564028679
PR Review Comment: https://git.openjdk.org/jdk/pull/28328#discussion_r2564038347
More information about the hotspot-dev
mailing list