RFR: 8367137: RISC-V: Detect Zicboz block size via hwprobe [v2]
Fei Yang
fyang at openjdk.org
Tue Sep 9 06:59:13 UTC 2025
On Tue, 9 Sep 2025 04:29:41 GMT, Dingli Zhang <dzhang at openjdk.org> wrote:
>> Hi,
>> Can you help to review this patch? Thanks!
>>
>> We can extends RISC-V hwprobe support to include `RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`.
>> The probed value is recorded in VM_Version::zicboz_block_size and then used to set the global CacheLineSize.
>> This ensures correct usage of the Zicboz extension, as block zeroing instructions operate on cache-line granularity.
>>
>> FYI: https://docs.kernel.org/arch/riscv/hwprobe.html
>
> Dingli Zhang has updated the pull request incrementally with one additional commit since the last revision:
>
> fix typo
src/hotspot/cpu/riscv/vm_version_riscv.cpp line 184:
> 182: }
> 183:
> 184: if (UseZicboz) {
I don't think it's safe to turn on `UseBlockZeroing` without knowing the actual cache block size.
So we might want to add check for that here. Maybe change this if condition into something like:
if (UseZicboz && (UseZic64b || zicboz_block_size.enabled())) {
src/hotspot/cpu/riscv/vm_version_riscv.cpp line 187:
> 185: if (zicboz_block_size.enabled()) {
> 186: assert(UseZic64b ? zicboz_block_size.value() == 64 : true, "Zicboz block size should be 64 when UseZic64b is true");
> 187: assert(is_power_of_2(zicboz_block_size.value()), "CacheLineSize must be a power of 2");
Can we merge the two assertions into one? Like:
`assert(UseZic64b ? zicboz_block_size.value() == 64 : is_power_of_2(zicboz_block_size.value()), "Sanity");`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27155#discussion_r2332218887
PR Review Comment: https://git.openjdk.org/jdk/pull/27155#discussion_r2332213815
More information about the hotspot-dev
mailing list