RFR: 8295282: Use Zicboz/cbo.zero to zero-out memory on RISC-V [v11]

Ludovic Henry luhenry at openjdk.org
Mon Oct 24 09:04:24 UTC 2022


On Mon, 24 Oct 2022 08:58:01 GMT, Fei Yang <fyang at openjdk.org> wrote:

>> Another solution is to do something similar to AArch64 and have vendor-specific setup in `src/hotspot/cpu/riscv/vm_version_riscv.cpp`. See https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp#L132-L222 for example. `CacheLineSize` can then be then be a global variable defined in `src/hotspot/cpu/riscv/globalDefinitions_riscv.hpp` which is set based on the vendor and a default value.
>
>> Is there is no guarantee that a platform will provide both `Zicboz` _and_ `Zic64b` even if the cache lines are 64 bytes? As in, the cache lines are 64 bytes, but the CPU doesn't notify the kernel that it supports `Zic64b`?
>> 
>> In that case, we won't use `Zicboz` which can be significantly faster than other approaches to zero out memory (the CPU is free not to fetch a cache line before storing it, since the whole cache line is zeroed out). Given the overall cost of zeroing out memory in Java, it's necessary to ensure it's as fast as possible.
>> 
>> I overall agree with the 64 bytes is an industry standard. What I want to ensure is that we can eagerly enable `UseBlockZeroing` whenever we can.
> 
> AFAIK, it's still not clear how those extensions like Zva, Zvb, Zicboz, etc, should be auto-detected at runtime for now. 
> I see this is still under discussion on LKML not long ago. So for now we depend on users to specify corresponding JVM options explicitly on the command line when the extensions are available. So for your concern here, I would expect the user to specify both Zicboz and Zic64b explictly for performance. We will revisit the auto-detection part once the correct way is settled down.

We can already do auto-detection via `/proc/cpuinfo`. I agree it's not the best way nor the most stable way, and I can only assume there will be a better way, but there is already a way.

I'll remove this `CacheLineSize` flag for now and we'll revisit later.

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

PR: https://git.openjdk.org/jdk/pull/10718


More information about the hotspot-dev mailing list