Skip to contentSkip to conversation

docs: riscv: Some clarifies on hwprobe misaligned performance

PATCH In review Yangyu Chen 3 participants 6 messages May 24, 2024 – Jun 26, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover docs: riscv: Some clarifies on hwprobe misaligned performance

This patchset clarifies some unclear things about hwprobe's misaligned performance. Including:

- hwprobe misaligned performance is only applied to scalar from patch [1]
- The defined keys of RISCV_HWPROBE_MISALIGNED_* are values not bitmasks

I cherry-picked [1] rather than write dependency because the original patch was submitted with lines wrapped to 80 characters. We can't directly apply that patch using git am .

Changes in v2:
- Add fixes to the code in arch/riscv/and include/asm/hwprobe.h

v1: https://lore.kernel.org/linux-riscv/[email protected]/

[1] https://lore.kernel.org/linux-riscv/CAJgzZorn5anPH8dVPqvjVWmLKqTi5bkLDR=FH-ZAcdXFnNe8Eg@mail.gmail.com/

Yangyu Chen (2):
docs: riscv: hwprobe: Clarify misaligned keys are values not bitmasks
RISC-V: hwprobe: not treat KEY_CPUPERF_0 as bitmask

enh (1):
docs: riscv: Clarify risc-v hwprobe RISCV_HWPROBE_MISALIGNED_* docs.

 Documentation/arch/riscv/hwprobe.rst | 31 ++++++++++++++++------------
 arch/riscv/include/asm/hwprobe.h     |  1 -
 2 files changed, 18 insertions(+), 14 deletions(-)
Signature · 1 line
2.45.1
#1 lore raw

PATCH v2 1/3 docs: riscv: Clarify risc-v hwprobe RISCV_HWPROBE_MISALIGNED_* docs.

From: enh <[email protected]>

These only tell you about scalar accesses, not vector accesses.

---
 Documentation/arch/riscv/hwprobe.rst | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
Documentation/arch/riscv/hwprobe.rst +8 -8
index 204cd4433af5..d720712e9734 100644
@@ -196,21 +196,21 @@ The following keys are defined:
   information about the selected set of processors.
 
   * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misaligned
-    accesses is unknown.
+    scalar accesses is unknown.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned accesses are
+  * :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned scalar accesses are
     emulated via software, either in or below the kernel.  These accesses are
     always extremely slow.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are slower
-    than equivalent byte accesses.  Misaligned accesses may be supported
+  * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned scalar accesses are
+    slower than equivalent byte accesses.  Misaligned accesses may be supported
     directly in hardware, or trapped and emulated by software.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are faster
-    than equivalent byte accesses.
+  * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned scalar accesses are
+    faster than equivalent byte accesses.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are
-    not supported at all and will generate a misaligned address fault.
+  * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned scalar accesses
+    are not supported at all and will generate a misaligned address fault.
 
 * :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which
   represents the size of the Zicboz block in bytes.
Signature · 1 line
2.45.1
#2 lore raw

PATCH v2 2/3 docs: riscv: hwprobe: Clarify misaligned keys are values not bitmasks

In reply to Yangyu Chen

The original documentation says hwprobe keys are bitmasks, but actually, they are values. This patch clarifies this to avoid confusion.

---
 Documentation/arch/riscv/hwprobe.rst | 31 ++++++++++++++++------------
 1 file changed, 18 insertions(+), 13 deletions(-)
Documentation/arch/riscv/hwprobe.rst +18 -13
index d720712e9734..2e212956185d 100644
@@ -192,25 +192,30 @@ The following keys are defined:
        supported as defined in the RISC-V ISA manual starting from commit
        d8ab5c78c207 ("Zihintpause is ratified").
 
-* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
+* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A value that contains performance
   information about the selected set of processors.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misaligned
-    scalar accesses is unknown.
+  * :c:macro:`RISCV_HWPROBE_MISALIGNED_MASK`: The bitmask of the misaligned
+    access performance field in the value of key `RISCV_HWPROBE_KEY_CPUPERF_0`.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned scalar accesses are
-    emulated via software, either in or below the kernel.  These accesses are
-    always extremely slow.
+    The following values (not bitmasks) in this field are defined:
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned scalar accesses are
-    slower than equivalent byte accesses.  Misaligned accesses may be supported
-    directly in hardware, or trapped and emulated by software.
+    * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misaligned
+      scalar accesses is unknown.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned scalar accesses are
-    faster than equivalent byte accesses.
+    * :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned scalar accesses are
+      emulated via software, either in or below the kernel.  These accesses are
+      always extremely slow.
 
-  * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned scalar accesses
-    are not supported at all and will generate a misaligned address fault.
+    * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned scalar accesses are
+      slower than equivalent byte accesses.  Misaligned accesses may be supported
+      directly in hardware, or trapped and emulated by software.
+
+    * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned scalar accesses are
+      faster than equivalent byte accesses.
+
+    * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned scalar accesses
+      are not supported at all and will generate a misaligned address fault.
 
 * :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which
   represents the size of the Zicboz block in bytes.
Signature · 1 line
2.45.1
#3 lore raw

PATCH v2 3/3 RISC-V: hwprobe: not treat KEY_CPUPERF_0 as bitmask

In reply to Yangyu Chen

Since the value in KEY_CPUPERF_0 is not bitmask, remove the wrong code in hwprobe.h.

---
 arch/riscv/include/asm/hwprobe.h | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/include/asm/hwprobe.h +0 -1
index 630507dff5ea..f24cad22bbe1 100644
@@ -20,7 +20,6 @@ static inline bool hwprobe_key_is_bitmask(__s64 key)
 	switch (key) {
 	case RISCV_HWPROBE_KEY_BASE_BEHAVIOR:
 	case RISCV_HWPROBE_KEY_IMA_EXT_0:
-	case RISCV_HWPROBE_KEY_CPUPERF_0:
 		return true;
 	}
 
Signature · 1 line
2.45.1
#4 lore raw

Re: [PATCH v2 3/3] RISC-V: hwprobe: not treat KEY_CPUPERF_0 as bitmask

Quoted 5 lines · Yangyu Chen

Since the value in KEY_CPUPERF_0 is not bitmask, remove the wrong code in hwprobe.h.

I'd expect a Fixes tag, and ideally some discussion on the reasoning and ramifications of this change.

I posted the other possible fix, declaring a new key, at [1], mostly so we could see the two options and discuss. I'm okay with either patch.
-Evan

[1] https://lore.kernel.org/lkml/[email protected]/T/#u

Quoted 19 lines
---
 arch/riscv/include/asm/hwprobe.h | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/include/asm/hwprobe.h +0 -2
index 630507dff5ea..f24cad22bbe1 100644
@@ -20,7 +20,6 @@ static inline bool hwprobe_key_is_bitmask(__s64 key)
        switch (key) {
        case RISCV_HWPROBE_KEY_BASE_BEHAVIOR:
        case RISCV_HWPROBE_KEY_IMA_EXT_0:
-       case RISCV_HWPROBE_KEY_CPUPERF_0:
                return true;
        }
 
--

2.45.1

maintainer
#5 lore raw

Re: [PATCH v2 3/3] RISC-V: hwprobe: not treat KEY_CPUPERF_0 as bitmask

Quoted 5 lines · Evan Green
Quoted 4 lines · Yangyu Chen

Since the value in KEY_CPUPERF_0 is not bitmask, remove the wrong code in hwprobe.h.

Quoted 8 lines
Quoted 1 line

I'd expect a Fixes tag, and ideally some discussion on the reasoning and ramifications of this change.

I posted the other possible fix, declaring a new key, at [1], mostly so we could see the two options and discuss. I'm okay with either patch.

Just to close the loop here as the discussions are on other threads: after a bunch of discussions we're going with the new key version. Maybe it's a bit pedantic, but since hwprobe is such a fundamental compatibility interface we're just going to be super careful.

Quoted 23 lines

-Evan

[1] https://lore.kernel.org/lkml/[email protected]/T/#u

Quoted 19 lines
---
 arch/riscv/include/asm/hwprobe.h | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/include/asm/hwprobe.h +0 -2
index 630507dff5ea..f24cad22bbe1 100644
@@ -20,7 +20,6 @@ static inline bool hwprobe_key_is_bitmask(__s64 key)
        switch (key) {
        case RISCV_HWPROBE_KEY_BASE_BEHAVIOR:
        case RISCV_HWPROBE_KEY_IMA_EXT_0:
-       case RISCV_HWPROBE_KEY_CPUPERF_0:
                return true;
        }
 
--

2.45.1