RFR: 8367137: RISC-V: Detect Zicboz block size via hwprobe [v5]

Fei Yang fyang at openjdk.org
Thu Sep 11 00:35:15 UTC 2025


On Thu, 11 Sep 2025 00:11:34 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:
> 
>   Refine comments and formatting

src/hotspot/cpu/riscv/vm_version_riscv.cpp line 190:

> 188:     }
> 189:     if (FLAG_IS_DEFAULT(BlockZeroingLowLimit)) {
> 190:       FLAG_SET_DEFAULT(BlockZeroingLowLimit, 2 * zicboz_block_size.value());

Seems to me some extra change is needed at the use of `zero_dcache_blocks` in file stubGenerator_riscv.cpp:

diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
index 7db426327ee..9ab16dea39b 100644
--- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
+++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
@@ -683,10 +683,11 @@ class StubGenerator: public StubCodeGenerator {
     address start = __ pc();

     if (UseBlockZeroing) {
-      // Ensure count >= 2*CacheLineSize so that it still deserves a cbo.zero
-      // after alignment.
+      int zicboz_blk_size = VM_Version::zicboz_block_size.value();
+      // Ensure count >= 2 * zicboz_block_size so that it still deserves
+      // a cbo.zero after alignment.
       Label small;
-      int low_limit = MAX2(2 * CacheLineSize, BlockZeroingLowLimit) / wordSize;
+      int low_limit = MAX2(2 * zicboz_blk_size, BlockZeroingLowLimit) / wordSize;
       __ mv(tmp1, low_limit);
       __ blt(cnt, tmp1, small);
       __ zero_dcache_blocks(base, cnt, tmp1, tmp2);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27155#discussion_r2338227450


More information about the hotspot-dev mailing list