RFR: 8352673: RISC-V: Vector can't be turned on with -XX:+UseRVV
Dingli Zhang
dzhang at openjdk.org
Mon Mar 24 14:00:34 UTC 2025
On Mon, 24 Mar 2025 09:11:48 GMT, Robbin Ehn <rehn 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:0x00007fff7fe670...
>
> 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.
Hi @robehn
Thank you for your response! I have updated the code.
When the kernel version is greater than 6.6, the test results are the same as [here](https://github.com/openjdk/jdk/pull/24182#issue-2942299437).
However, when the kernel version is less than 6.6, the test results are as follows:
$ uname -a
Linux ubuntu 5.19.0-1012-generic #13~22.04.1-Ubuntu SMP Thu Jan 12 15:34:31 UTC 2023 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
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGILL (0x4) at pc=0x00007fff8dea1d50, pid=5090, tid=5091
#
# JRE version: (25.0) (build )
# Java VM: OpenJDK 64-Bit Server VM (25-internal-adhoc.zhangdingli.jdk, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# V [libjvm.so+0xca1d50] VM_Version::cpu_vector_length()+0x6
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/ubuntu/jdk-enable-rvv/bin/core.5090)
#
# An error report file with more information is saved as:
# /home/ubuntu/jdk-enable-rvv/bin/hs_err_pid5090.log
#
#
Aborted (core dumped)
$ ./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)
If more extensive changes and a better approach are needed, I'll be happy to close this PR.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24182#issuecomment-2748219275
More information about the hotspot-runtime-dev
mailing list