Skip to content

Conversation

Hamlin-Li
Copy link

@Hamlin-Li Hamlin-Li commented Sep 29, 2025

Hi,
Can you help to review the patch?

This patch cleans up RV_EXT_FEATURE_FLAGS & RV_NON_EXT_FEATURE_FLAGS, as discussed #27152 (comment):

  • reorder flags in alphabetic order for RV_EXT_FEATURE_FLAGS
  • move comments close to feature declaration for RV_EXT_FEATURE_FLAGS & RV_NON_EXT_FEATURE_FLAGS

We also discussed (#27171 (comment)) the assert introduced in #24094, previously we think this will restrict the flags order in RV_EXT_FEATURE_FLAGS, but I found out that this assert (is not necessary, so we should be able to order flags in RV_EXT_FEATURE_FLAGS in any way we'd like to) does not work as expected, will fix this in another pr.

Thanks!


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8368897: RISC-V: Cleanup RV_EXT_FEATURE_FLAGS & RV_NON_EXT_FEATURE_FLAGS (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27562/head:pull/27562
$ git checkout pull/27562

Update a local copy of the PR:
$ git checkout pull/27562
$ git pull https://git.openjdk.org/jdk.git pull/27562/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27562

View PR using the GUI difftool:
$ git pr show -t 27562

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27562.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 29, 2025

👋 Welcome back mli! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 29, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Sep 29, 2025

@Hamlin-Li The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 29, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 29, 2025

Webrevs

Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, You need merge and rebase :-) But the order of the detection of these extesions (the order in RiscvHwprobe::add_features_from_query_result()) still matters, right? Say we must detect ext_v before ext_Zvbb.

@Hamlin-Li
Copy link
Author

Hamlin-Li commented Sep 30, 2025

Hi, You need merge and rebase :-)

Thanks for reminding :) I think my forked master needs to be adjusted in some way, as seems I previously accidently pushed some commit to master instead of branch, I'll figure out it later.

But the order of the detection of these extesions (the order in RiscvHwprobe::add_features_from_query_result()) still matters, right? Say we must detect ext_v before ext_Zvbb.

Yes, you're right.
But seems previous way (assert introduced in #24094) does not work as expected, I moved ext_V below other ext_Zv ones, the assert was not triggerred, it's verified in commit 7853415, check below for a simple patch. I'll do more investigation and find out a way to catch the out of order detections in another PR.

diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp
index 4214d6c53dc..80896f8fffc 100644
--- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp
+++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp
@@ -169,7 +169,6 @@ class VM_Version : public Abstract_VM_Version {
   decl(ext_C           , "c"           ,    ('C' - 'A'), true , UPDATE_DEFAULT(UseRVC))             \
   decl(ext_Q           , "q"           ,    ('Q' - 'A'), true , NO_UPDATE_DEFAULT)                  \
   decl(ext_H           , "h"           ,    ('H' - 'A'), true , NO_UPDATE_DEFAULT)                  \
-  decl(ext_V           , "v"           ,    ('V' - 'A'), true , UPDATE_DEFAULT(UseRVV))             \
   decl(ext_Zicbom      , "Zicbom"      , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZicbom))          \
   decl(ext_Zicboz      , "Zicboz"      , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZicboz))          \
   decl(ext_Zicbop      , "Zicbop"      , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZicbop))          \
@@ -193,6 +192,7 @@ class VM_Version : public Abstract_VM_Version {
   decl(ext_Zvbc        , "Zvbc"        , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT_DEP(UseZvbc, ext_V)) \
   decl(ext_Zvfh        , "Zvfh"        , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT_DEP(UseZvfh, ext_V)) \
   decl(ext_Zvkn        , "Zvkn"        , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT_DEP(UseZvkn, ext_V)) \
+  decl(ext_V           , "v"           ,    ('V' - 'A'), true , UPDATE_DEFAULT(UseRVV))             \
   decl(ext_Zicond      , "Zicond"      , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZicond))          \
   decl(mvendorid       , "VendorId"    , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT)                  \
   decl(marchid         , "ArchId"      , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT)                  \

@openjdk
Copy link

openjdk bot commented Sep 30, 2025

⚠️ @Hamlin-Li This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@Hamlin-Li
Copy link
Author

I'm also considering if we should remove the column ext_xx in RV_EXT_FEATURE_FLAGS, and the similar column in RV_NON_EXT_FEATURE_FLAGS in this pr, as it should be able to be generated from the pretty string. How do you think about it?

The different opinions could be:

  • for RV_EXT_FEATURE_FLAGS, should we take for example i or I as pretty string?
  • for RV_NON_EXT_FEATURE_FLAGS, should we use mvendorid or VendorId as pretty string?
    let me know how do you think about it.

@Hamlin-Li
Copy link
Author

Hamlin-Li commented Sep 30, 2025

I file https://bugs.openjdk.org/browse/JDK-8368950 to track the out of order declarations in RV_FEATURE_FLAGS.
PR is here: #27572

@RealFYang
Copy link
Member

I'm also considering if we should remove the column ext_xx in RV_EXT_FEATURE_FLAGS, and the similar column in RV_NON_EXT_FEATURE_FLAGS in this pr, as it should be able to be generated from the pretty string. How do you think about it?

The different opinions could be:

  • for RV_EXT_FEATURE_FLAGS, should we take for example i or I as pretty string?

The current _features_string on linux-riscv64 looks like:

rv64 rvi rvm rva rvf rvd rvc rvv zicboz zba zbb zbs zfa zfh zfhmin zvfh zicond

We append a rv prefix for i, m, a, f, d, c and v.

  • for RV_NON_EXT_FEATURE_FLAGS, should we use mvendorid or VendorId as pretty string?
    let me know how do you think about it.

Seems not necessary to have a pretty string for non-extension flags. Is it used anywhere?

@Hamlin-Li
Copy link
Author

  • for RV_EXT_FEATURE_FLAGS, should we take for example i or I as pretty string?

The current _features_string on linux-riscv64 looks like:

rv64 rvi rvm rva rvf rvd rvc rvv zicboz zba zbb zbs zfa zfh zfhmin zvfh zicond

We append a rv prefix for i, m, a, f, d, c and v.

OK, I'll keep the pretty string as lower cases.

  • for RV_NON_EXT_FEATURE_FLAGS, should we use mvendorid or VendorId as pretty string?
    let me know how do you think about it.

Seems not necessary to have a pretty string for non-extension flags. Is it used anywhere?

Yes, it's printed out by log_debug(os, cpu), e.g.

[0.070s][debug][os,cpu] Enabled RV64 feature "VendorId" (1743)
[0.070s][debug][os,cpu] Enabled RV64 feature "ArchId" (0)
[0.070s][debug][os,cpu] Enabled RV64 feature "ImpId" (0)
[0.070s][debug][os,cpu] Enabled RV64 feature "SATP" (48)
[0.070s][debug][os,cpu] Enabled RV64 feature "UnalignedScalar" (3)
[0.070s][debug][os,cpu] Enabled RV64 feature "ZicbozBlockSize" (64)

@Hamlin-Li
Copy link
Author

@RealFYang Take your time, no hurry. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants