RFR: 8352673: RISC-V: Vector can't be turned on with -XX:+UseRVV
Robbin Ehn
rehn at openjdk.org
Mon Mar 24 09:16:06 UTC 2025
On Mon, 24 Mar 2025 07:37:06 GMT, Dingli Zhang <dzhang at openjdk.org> wrote:
> Hi all,
> After [JDK-8348384](https://bugs.openjdk.org/browse/JDK-8348384), Vector can't be turned on with -XX:+UseRVV when Linux kernels before 6.8.5, which does not match the printed log:
>
> log.info("Linux kernels before 6.8.5 (current %ld.%ld.%ld) have a known bug when using Vector and signals.", major, minor, patch);
> log.info("Vector not enabled automatically via hwprobe, but can be turned on with -XX:+UseRVV.");
>
>
> Testing on QEMU before this PR:
>
> $ uname -a
> Linux ubuntu 6.8.0-52-generic #53.1-Ubuntu SMP PREEMPT_DYNAMIC Sun Jan 26 04:38:25 UTC 2025 riscv64 riscv64 riscv64 GNU/Linux
>
> $ ./java -XX:+PrintFlagsFinal -XX:+UnlockDiagnosticVMOptions -version | grep UseRVV
> bool UseRVV = false {ARCH diagnostic} {default}
> openjdk version "25-internal" 2025-09-16
> OpenJDK Runtime Environment (build 25-internal-adhoc.zhangdingli.jdk)
> OpenJDK 64-Bit Server VM (build 25-internal-adhoc.zhangdingli.jdk, mixed mode)
>
> $ ./java -XX:+PrintFlagsFinal -XX:+UnlockDiagnosticVMOptions -XX:+UseRVV -version | grep UseRVV
> OpenJDK 64-Bit Server VM warning: RVV is not supported on this CPU
> bool UseRVV = false {ARCH diagnostic} {command line}
> openjdk version "25-internal" 2025-09-16
> OpenJDK Runtime Environment (build 25-internal-adhoc.zhangdingli.jdk)
> OpenJDK 64-Bit Server VM (build 25-internal-adhoc.zhangdingli.jdk, mixed mode)
>
> $ ./java -XX:+PrintFlagsFinal -XX:+UnlockDiagnosticVMOptions -XX:-UseRVV -version | grep UseRVV
> bool UseRVV = false {ARCH diagnostic} {command line}
> openjdk version "25-internal" 2025-09-16
> OpenJDK Runtime Environment (build 25-internal-adhoc.zhangdingli.jdk)
> OpenJDK 64-Bit Server VM (build 25-internal-adhoc.zhangdingli.jdk, mixed mode)
>
> $ ./java -XX:+UnlockDiagnosticVMOptions -XX:+UseRVV -Xlog:os=info -version
> [0.021s][info][os] Use of CLOCK_MONOTONIC is supported
> [0.022s][info][os] Use of pthread_condattr_setclock is supported
> [0.022s][info][os] Relative timed-wait using pthread_cond_timedwait is associated with CLOCK_MONOTONIC
> [0.022s][info][os] HotSpot is running with glibc 2.39, NPTL 2.39
> [0.022s][info][os] Glibc stack size guard page adjustment is not needed
> [0.024s][info][os] SafePoint Polling address, bad (protected) page:0x00007fff7fe66000, good (unprotected) page:0x00007fff7fe67000
> [0.040s][info][os] attempting shared library load of /home/ubuntu/jdk-rvv...
Thanks for finding!
The code your patching is only suppose not to enable it via hwprobe, which it do.
If you want to allow RVV even do the kernel do not support I think it's better to change this code:
if (UseRVV) {
if (!ext_V.enabled()) {
warning("RVV is not supported on this CPU");
FLAG_SET_DEFAULT(UseRVV, false);
Which is the actual code that turns off RVV.
E.g. there is no issue turning on -XX:+UseZbb even of ext_Zbb is false.
Maybe the Linux version check is placed wrong, and should not be in hwprobe?
Note: I also think you need a FLAG_IS_DEFAULT, as we only want to turn it on if it is set by user.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24182#issuecomment-2747394215
More information about the hotspot-runtime-dev
mailing list