Skip to contentSkip to conversation

config/arm: adds Arm Neoverse N3 SoC

PATCH Superseded Wathsala Vithanage 5 participants 32 messages Jun 4, 2024 – Oct 10, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 config/arm: adds Arm Neoverse N3 SoC

Add Arm Neoverse N3 part number to build configuration.

---
 config/arm/meson.build | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
config/arm/meson.build +21 -1
index a45aa9e466..ec7588f055 100644
@@ -116,6 +116,18 @@ part_number_config_arm = {
             ['RTE_MAX_LCORE', 144],
             ['RTE_MAX_NUMA_NODES', 2]
         ]
+    },
+    '0xd8e': {
+        'march': 'armv8.7-a',
+        'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
+        'flags': [
+            ['RTE_MACHINE', '"neoverse-n3"'],
+            ['RTE_ARM_FEATURE_ATOMICS', true],
+            ['RTE_ARM_FEATURE_WFXT', true],
+            ['RTE_MAX_LCORE', 192],
+            ['RTE_MAX_NUMA_NODES', 2]
+        ]
     }
 }
 implementer_arm = {
@@ -555,6 +567,13 @@ soc_n2 = {
     'numa': false
 }
 
+soc_n3 = {
+    'description': 'Arm Neoverse N3',
+    'implementer': '0x41',
+    'part_number': '0xd8e',
+    'numa': false
+}
+
 soc_odyssey = {
     'description': 'Marvell Odyssey',
     'implementer': '0x41',
@@ -680,6 +699,7 @@ socs = {
     'kunpeng930': soc_kunpeng930,
     'n1sdp': soc_n1sdp,
     'n2': soc_n2,
+    'n3': soc_n3,
     'odyssey' : soc_odyssey,
     'stingray': soc_stingray,
     'thunderx2': soc_thunderx2,
@@ -833,7 +853,7 @@ if update_flags
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
-            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.7-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 eal: add Arm WFET in power management intrinsics

Wait for event with timeout (WFET) puts the CPU in a low power mode and stays there until an event is signalled (SEV), loss of an exclusive monitor or a timeout.
WFET is enabled selectively by checking FEAT_WFxT in Linux auxiliary vector. If FEAT_WFxT is not available power management will fallback to WFE.
RTE_ARM_USE_WFE macro is not required to enable WFE feature for PMD power monitoring.

---
 .mailmap                                   |  4 +-
 app/test/test_cpuflags.c                   |  3 ++
 lib/eal/arm/include/rte_cpuflags_64.h      |  1 +
 lib/eal/arm/include/rte_pause_64.h         | 21 ++++++--
 lib/eal/arm/include/rte_power_intrinsics.h |  6 +++
 lib/eal/arm/rte_cpuflags.c                 |  3 +-
 lib/eal/arm/rte_power_intrinsics.c         | 56 ++++++++++++----------
 7 files changed, 62 insertions(+), 32 deletions(-)
.mailmap +3 -1
index 3843868716..eefcce4935 100644
@@ -332,6 +332,7 @@ Dexia Li <[email protected]>
 Dexuan Cui <[email protected]>
 Dharmik Thakkar <[email protected]> <[email protected]>
 Dheemanth Mallikarjun <[email protected]>
+Dhruv Tripathi <[email protected]>
 Diana Wang <[email protected]>
 Didier Pallard <[email protected]>
 Dilshod Urazov <[email protected]>
@@ -1027,7 +1028,7 @@ Netanel Belgazal <[email protected]>
 Netanel Gonen <[email protected]>
 Niall Power <[email protected]>
 Nicholas Pratte <[email protected]>
-Nick Connolly <[email protected]>
+Nick Connolly <[email protected]> <[email protected]>
 Nick Nunley <[email protected]>
 Niclas Storm <[email protected]>
 Nicolas Chautru <[email protected]>
@@ -1516,6 +1517,7 @@ Vincent Jardin <[email protected]>
 Vincent Li <[email protected]>
 Vincent S. Cojot <[email protected]>
 Vinh Tran <[email protected]>
+Vinod Krishna <[email protected]>
 Vipin Varghese <[email protected]> <[email protected]>
 Vipul Ashri <[email protected]>
 Visa Hankala <[email protected]>
app/test/test_cpuflags.c +3 -0
index a0ff74720c..22ab4dff0a 100644
@@ -156,6 +156,9 @@ test_cpuflags(void)
 
 	printf("Check for SVEBF16:\t");
 	CHECK_FOR_FLAG(RTE_CPUFLAG_SVEBF16);
+
+	printf("Check for WFXT:\t");
+	CHECK_FOR_FLAG(RTE_CPUFLAG_WFXT);
 #endif
 
 #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
lib/eal/arm/include/rte_cpuflags_64.h +1 -0
index afe70209c3..db61539db2 100644
@@ -35,6 +35,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_SVEF32MM,
 	RTE_CPUFLAG_SVEF64MM,
 	RTE_CPUFLAG_SVEBF16,
+	RTE_CPUFLAG_WFXT,
 	RTE_CPUFLAG_AARCH64,
 };
 
lib/eal/arm/include/rte_pause_64.h +17 -4
index 5cb8b59056..f732407425 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Cavium, Inc
- * Copyright(c) 2019 Arm Limited
+ * Copyright(c) 2024 Arm Limited
  */
 
 #ifndef _RTE_PAUSE_ARM64_H_
@@ -23,17 +23,28 @@ static inline void rte_pause(void)
 	asm volatile("yield" ::: "memory");
 }
 
-#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
 
-/* Send a local event to quit WFE. */
+/* Send a local event to quit WFE/WFxT. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
-/* Send a global event to quit WFE for all cores. */
+/* Send a global event to quit WFE/WFxT for all cores. */
 #define __RTE_ARM_SEV() { asm volatile("sev" : : : "memory"); }
 
 /* Put processor into low power WFE(Wait For Event) state. */
 #define __RTE_ARM_WFE() { asm volatile("wfe" : : : "memory"); }
 
+/* Put processor into low power WFET (WFE with Timeout) state. */
+#ifdef RTE_ARM_FEATURE_WFXT
+#define __RTE_ARM_WFET(t) {                              \
+	asm volatile("wfet %x[to]"                        \
+			:                                 \
+			: [to] "r" (t)                    \
+			: "memory");                      \
+	}
+#else
+#define __RTE_ARM_WFET(t) { RTE_SET_USED(t); }
+#endif
+
 /*
  * Atomic exclusive load from addr, it returns the 8-bit content of
  * *addr while making it 'monitored', when it is written by someone
@@ -147,6 +158,8 @@ static inline void rte_pause(void)
 		__RTE_ARM_LOAD_EXC_128(src, dst, memorder) \
 }
 
+#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
+
 static __rte_always_inline void
 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
 		int memorder)
lib/eal/arm/include/rte_power_intrinsics.h +6 -0
index 9e498e9ebf..dc80fca60b 100644
@@ -13,6 +13,12 @@ extern "C" {
 
 #include "generic/rte_power_intrinsics.h"
 
+struct rte_power_monitor_info {
+	uint16_t init_done:1,   /* Initialization status bit */
+		wfet_en:1,	/* FEAT_WFET enabled bit */
+		reserved:14;	/* Reserved */
+};
+
 #ifdef __cplusplus
 }
 #endif
lib/eal/arm/rte_cpuflags.c +1 -2
index 7ba4f8ba97..ad76f2448b 100644
@@ -115,6 +115,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(SVEF32MM,	REG_HWCAP2,   10)
 	FEAT_DEF(SVEF64MM,	REG_HWCAP2,   11)
 	FEAT_DEF(SVEBF16,	REG_HWCAP2,   12)
+	FEAT_DEF(WFXT,		REG_HWCAP2,   31)
 	FEAT_DEF(AARCH64,	REG_PLATFORM,  0)
 };
 #endif /* RTE_ARCH */
@@ -163,7 +164,5 @@ void
 rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics)
 {
 	memset(intrinsics, 0, sizeof(*intrinsics));
-#ifdef RTE_ARM_USE_WFE
 	intrinsics->power_monitor = 1;
-#endif
 }
lib/eal/arm/rte_power_intrinsics.c +31 -25

98 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] eal: add Arm WFET in power management intrinsics

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t { · line 40

Quoted 9 lines · On Tue, 4 Jun 2024 04:44:01 +0000 Wathsala Vithanage…
lib/eal/arm/include/rte_cpuflags_64.h +1 -0
@@ -35,6 +35,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_SVEF32MM,
 	RTE_CPUFLAG_SVEF64MM,
 	RTE_CPUFLAG_SVEBF16,
+	RTE_CPUFLAG_WFXT,
 	RTE_CPUFLAG_AARCH64,
 };

Adding new entry in middle of enum will cause ABI to change.

#3 lore raw

PATCH v2 1/2 config/arm: adds Arm Neoverse N3 SoC

In reply to Wathsala Vithanage

Add Arm Neoverse N3 part number to build configuration.

---
 config/arm/meson.build | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
config/arm/meson.build +21 -1
index a45aa9e466..ec7588f055 100644
@@ -116,6 +116,18 @@ part_number_config_arm = {
             ['RTE_MAX_LCORE', 144],
             ['RTE_MAX_NUMA_NODES', 2]
         ]
+    },
+    '0xd8e': {
+        'march': 'armv8.7-a',
+        'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
+        'flags': [
+            ['RTE_MACHINE', '"neoverse-n3"'],
+            ['RTE_ARM_FEATURE_ATOMICS', true],
+            ['RTE_ARM_FEATURE_WFXT', true],
+            ['RTE_MAX_LCORE', 192],
+            ['RTE_MAX_NUMA_NODES', 2]
+        ]
     }
 }
 implementer_arm = {
@@ -555,6 +567,13 @@ soc_n2 = {
     'numa': false
 }
 
+soc_n3 = {
+    'description': 'Arm Neoverse N3',
+    'implementer': '0x41',
+    'part_number': '0xd8e',
+    'numa': false
+}
+
 soc_odyssey = {
     'description': 'Marvell Odyssey',
     'implementer': '0x41',
@@ -680,6 +699,7 @@ socs = {
     'kunpeng930': soc_kunpeng930,
     'n1sdp': soc_n1sdp,
     'n2': soc_n2,
+    'n3': soc_n3,
     'odyssey' : soc_odyssey,
     'stingray': soc_stingray,
     'thunderx2': soc_thunderx2,
@@ -833,7 +853,7 @@ if update_flags
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
-            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.7-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 2/2 eal: add Arm WFET in power management intrinsics

Wait for event with timeout (WFET) puts the CPU in a low power mode and stays there until an event is signalled (SEV), loss of an exclusive monitor or a timeout.
WFET is enabled selectively by checking FEAT_WFxT in Linux auxiliary vector. If FEAT_WFxT is not available power management will fallback to WFE.
RTE_ARM_USE_WFE macro is not required to enable WFE feature for PMD power monitoring.

---
 .mailmap                              |  2 ++
 app/test/test_cpuflags.c              |  3 ++
 lib/eal/arm/include/rte_cpuflags_64.h |  1 +
 lib/eal/arm/include/rte_pause_64.h    | 21 ++++++++++---
 lib/eal/arm/rte_cpuflags.c            |  3 +-
 lib/eal/arm/rte_power_intrinsics.c    | 45 +++++++++++++++++----------
 6 files changed, 52 insertions(+), 23 deletions(-)
.mailmap +2 -0
index 3843868716..31995d492d 100644
@@ -332,6 +332,7 @@ Dexia Li <[email protected]>
 Dexuan Cui <[email protected]>
 Dharmik Thakkar <[email protected]> <[email protected]>
 Dheemanth Mallikarjun <[email protected]>
+Dhruv Tripathi <[email protected]>
 Diana Wang <[email protected]>
 Didier Pallard <[email protected]>
 Dilshod Urazov <[email protected]>
@@ -1516,6 +1517,7 @@ Vincent Jardin <[email protected]>
 Vincent Li <[email protected]>
 Vincent S. Cojot <[email protected]>
 Vinh Tran <[email protected]>
+Vinod Krishna <[email protected]>
 Vipin Varghese <[email protected]> <[email protected]>
 Vipul Ashri <[email protected]>
 Visa Hankala <[email protected]>
app/test/test_cpuflags.c +3 -0
index a0ff74720c..22ab4dff0a 100644
@@ -156,6 +156,9 @@ test_cpuflags(void)
 
 	printf("Check for SVEBF16:\t");
 	CHECK_FOR_FLAG(RTE_CPUFLAG_SVEBF16);
+
+	printf("Check for WFXT:\t");
+	CHECK_FOR_FLAG(RTE_CPUFLAG_WFXT);
 #endif
 
 #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
lib/eal/arm/include/rte_cpuflags_64.h +1 -0
index afe70209c3..1945a97ca1 100644
@@ -36,6 +36,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_SVEF64MM,
 	RTE_CPUFLAG_SVEBF16,
 	RTE_CPUFLAG_AARCH64,
+	RTE_CPUFLAG_WFXT,
 };
 
 #include "generic/rte_cpuflags.h"
lib/eal/arm/include/rte_pause_64.h +17 -4
index 5cb8b59056..f732407425 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2017 Cavium, Inc
- * Copyright(c) 2019 Arm Limited
+ * Copyright(c) 2024 Arm Limited
  */
 
 #ifndef _RTE_PAUSE_ARM64_H_
@@ -23,17 +23,28 @@ static inline void rte_pause(void)
 	asm volatile("yield" ::: "memory");
 }
 
-#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
 
-/* Send a local event to quit WFE. */
+/* Send a local event to quit WFE/WFxT. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
-/* Send a global event to quit WFE for all cores. */
+/* Send a global event to quit WFE/WFxT for all cores. */
 #define __RTE_ARM_SEV() { asm volatile("sev" : : : "memory"); }
 
 /* Put processor into low power WFE(Wait For Event) state. */
 #define __RTE_ARM_WFE() { asm volatile("wfe" : : : "memory"); }
 
+/* Put processor into low power WFET (WFE with Timeout) state. */
+#ifdef RTE_ARM_FEATURE_WFXT
+#define __RTE_ARM_WFET(t) {                              \
+	asm volatile("wfet %x[to]"                        \
+			:                                 \
+			: [to] "r" (t)                    \
+			: "memory");                      \
+	}
+#else
+#define __RTE_ARM_WFET(t) { RTE_SET_USED(t); }
+#endif
+
 /*
  * Atomic exclusive load from addr, it returns the 8-bit content of
  * *addr while making it 'monitored', when it is written by someone
@@ -147,6 +158,8 @@ static inline void rte_pause(void)
 		__RTE_ARM_LOAD_EXC_128(src, dst, memorder) \
 }
 
+#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
+
 static __rte_always_inline void
 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
 		int memorder)
lib/eal/arm/rte_cpuflags.c +1 -2
index 7ba4f8ba97..ad76f2448b 100644
@@ -115,6 +115,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(SVEF32MM,	REG_HWCAP2,   10)
 	FEAT_DEF(SVEF64MM,	REG_HWCAP2,   11)
 	FEAT_DEF(SVEBF16,	REG_HWCAP2,   12)
+	FEAT_DEF(WFXT,		REG_HWCAP2,   31)
 	FEAT_DEF(AARCH64,	REG_PLATFORM,  0)
 };
 #endif /* RTE_ARCH */
@@ -163,7 +164,5 @@ void
 rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics)
 {
 	memset(intrinsics, 0, sizeof(*intrinsics));
-#ifdef RTE_ARM_USE_WFE
 	intrinsics->power_monitor = 1;
-#endif
 }
lib/eal/arm/rte_power_intrinsics.c +28 -17

86 lines not on this page · raw message

Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

19/06/2024 08:45, Wathsala Vithanage:

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t { · line 40

Quoted 8 lines
lib/eal/arm/include/rte_cpuflags_64.h +1 -0
@@ -36,6 +36,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_SVEF64MM,
 	RTE_CPUFLAG_SVEBF16,
 	RTE_CPUFLAG_AARCH64,
+	RTE_CPUFLAG_WFXT,
 };

It may be useful to add comments explaining each flag. May be a separate patch in this series?

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t { · line 41

Quoted 2 lines
lib/eal/arm/include/rte_cpuflags_64.h +1 -1
- * Copyright(c) 2019 Arm Limited
+ * Copyright(c) 2024 Arm Limited

No, it's wrong to remove initial date,
and no, you don't need to update dates at all.

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t { · line 41

Quoted 1 line
lib/eal/arm/include/rte_cpuflags_64.h +0 -1
-#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED

Why removing this #ifdef?

Quoted 9 lines
lib/eal/arm/include/rte_cpuflags_64.h +2 -2
-/* Send a local event to quit WFE. */
+/* Send a local event to quit WFE/WFxT. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
-/* Send a global event to quit WFE for all cores. */
+/* Send a global event to quit WFE/WFxT for all cores. */
 #define __RTE_ARM_SEV() { asm volatile("sev" : : : "memory"); }
 
 /* Put processor into low power WFE(Wait For Event) state. */

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t {

Quoted 10 lines
lib/eal/arm/include/rte_cpuflags_64.h +8 -0
 #define __RTE_ARM_WFE() { asm volatile("wfe" : : : "memory"); }
 
+/* Put processor into low power WFET (WFE with Timeout) state. */
+#ifdef RTE_ARM_FEATURE_WFXT
+#define __RTE_ARM_WFET(t) {                              \
+	asm volatile("wfet %x[to]"                        \
+			:                                 \
+			: [to] "r" (t)                    \
+			: "memory");                      \
+	}

Is there any intrinsic function available?

[...]

lib/eal/arm/rte_cpuflags.c const struct feature_entry rte_cpu_feature_table[] = { · line 119

Quoted 8 lines
lib/eal/arm/rte_cpuflags.c +1 -0
@@ -115,6 +115,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(SVEF32MM,	REG_HWCAP2,   10)
 	FEAT_DEF(SVEF64MM,	REG_HWCAP2,   11)
 	FEAT_DEF(SVEBF16,	REG_HWCAP2,   12)
+	FEAT_DEF(WFXT,		REG_HWCAP2,   31)
 	FEAT_DEF(AARCH64,	REG_PLATFORM,  0)

Are you sure of alignment? (looks wrong in my email client)

[...]

lib/eal/arm/rte_cpuflags.c void · line 168

Quoted 6 lines
lib/eal/arm/rte_cpuflags.c +0 -0
 rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics)
 {
lib/eal/arm/rte_cpuflags.c +0 -2
 	memset(intrinsics, 0, sizeof(*intrinsics));
-#ifdef RTE_ARM_USE_WFE
 	intrinsics->power_monitor = 1;
-#endif

Why removing this #ifdef?

Quoted 1 line

+uint8_t wfet_en;

It should be made static probably.
This variable will be unused in some cases, needs #ifdef.

Quoted 12 lines
lib/eal/arm/rte_cpuflags.c +11 -0
+
+RTE_INIT(rte_power_intrinsics_init)
+{
+#ifdef RTE_ARCH_64
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_WFXT))
+		wfet_en = 1;
+#endif
+}
+
+/**
+ * This function uses WFE/WFET instruction to make lcore suspend
  * execution on ARM.

lib/eal/arm/rte_cpuflags.c

Quoted 10 lines
lib/eal/arm/rte_cpuflags.c +1 -4
- * Note that timestamp based timeout is not supported yet.
  */
 int
 rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 		const uint64_t tsc_timestamp)
 {
-	RTE_SET_USED(tsc_timestamp);
-
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64

It looks wrong.
If RTE_ARM_USE_WFE is disabled, you should not call __RTE_ARM_WFE().

Quoted 10 lines
lib/eal/arm/rte_cpuflags.c +1 -2
 	const unsigned int lcore_id = rte_lcore_id();
 	uint64_t cur_value;
@@ -33,28 +44,30 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 
 	switch (pmc->size) {
 	case sizeof(uint8_t):
-		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value, rte_memory_order_relaxed);
#6 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 13 lines

19/06/2024 08:45, Wathsala Vithanage:

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t { · line 40

Quoted 8 lines
lib/eal/arm/include/rte_cpuflags_64.h +1 -0
@@ -36,6 +36,7 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_SVEF64MM,
 	RTE_CPUFLAG_SVEBF16,
 	RTE_CPUFLAG_AARCH64,
+	RTE_CPUFLAG_WFXT,
 };

It may be useful to add comments explaining each flag. May be a separate patch in this series?

+1

Quoted 11 lines

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t { · line 41

Quoted 3 lines
lib/eal/arm/include/rte_cpuflags_64.h +1 -1
- * Copyright(c) 2019 Arm Limited
+ * Copyright(c) 2024 Arm Limited

No, it's wrong to remove initial date,
and no, you don't need to update dates at all.

lib/eal/arm/include/rte_cpuflags_64.h enum rte_cpu_flag_t { · line 41

Quoted 1 line
lib/eal/arm/include/rte_cpuflags_64.h +0 -1
-#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED

Why removing this #ifdef?

It's not removed, it's moved further down and just above rte_wait_until_equal_X functions. Use of SEV, and WFE are not limited to rte_wait_until_equal_X functions, PMDs should be able to use them for power management.

Quoted 12 lines
Quoted 12 lines
lib/eal/arm/include/rte_cpuflags_64.h +2 -2
-/* Send a local event to quit WFE. */
+/* Send a local event to quit WFE/WFxT. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
-/* Send a global event to quit WFE for all cores. */
+/* Send a global event to quit WFE/WFxT for all cores. */
 #define __RTE_ARM_SEV() { asm volatile("sev" : : : "memory"); }
 
 /* Put processor into low power WFE(Wait For Event) state. */

#define __RTE_ARM_WFE() { asm volatile("wfe" : : : "memory"); }

Quoted 11 lines

lib/eal/arm/include/rte_cpuflags_64.h

Quoted 8 lines
lib/eal/arm/include/rte_cpuflags_64.h +8 -0
+/* Put processor into low power WFET (WFE with Timeout) state. */
+#ifdef RTE_ARM_FEATURE_WFXT
+#define __RTE_ARM_WFET(t) {                              \
+	asm volatile("wfet %x[to]"                        \
+			:                                 \
+			: [to] "r" (t)                    \
+			: "memory");                      \
+	}

Is there any intrinsic function available?

We don't have an intrinsic at the moment.

Quoted 6 lines

[...]

lib/eal/arm/rte_cpuflags.c const struct feature_entry rte_cpu_feature_table[] =

Quoted 3 lines
lib/eal/arm/rte_cpuflags.c +0 -0
@@ -115,6 +115,7 @@ const struct feature_entry rte_cpu_feature_table[] =

{

Quoted 7 lines

lib/eal/arm/rte_cpuflags.c const struct feature_entry rte_cpu_feature_table[] = { · line 119

Quoted 5 lines
lib/eal/arm/rte_cpuflags.c +1 -0
 	FEAT_DEF(SVEF32MM,	REG_HWCAP2,   10)
 	FEAT_DEF(SVEF64MM,	REG_HWCAP2,   11)
 	FEAT_DEF(SVEBF16,	REG_HWCAP2,   12)
+	FEAT_DEF(WFXT,		REG_HWCAP2,   31)
 	FEAT_DEF(AARCH64,	REG_PLATFORM,  0)

Are you sure of alignment? (looks wrong in my email client)

Didn't see this before, I will check.

Quoted 10 lines

[...]

lib/eal/arm/rte_cpuflags.c void · line 168

Quoted 5 lines

rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics)
{

lib/eal/arm/rte_cpuflags.c +0 -1
 	memset(intrinsics, 0, sizeof(*intrinsics)); -#ifdef RTE_ARM_USE_WFE
 	intrinsics->power_monitor = 1;
-#endif

Why removing this #ifdef?

WFE is available in all the Arm platforms DPDK currently supports. Therefore, an explicit flag is not required at build time.

The purpose of RTE_ARM_USE_WFE seems to be controlling the use of WFE in rte_wait_until_equal functions by defining RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED macro only when RTE_ARM_USE_WFE is defined. (eal/arm/include/rte_pause_64.h:15)
From what I'm hearing this was done due to a performance issue rte_wait_until_equal_X functions had when using WFE.
However, that design is flawed because it made other users of WFE dependent on the choice of the use of WFE in rte_wait_until_equal functions as __RTE_ARM_WFE was wrapped in an RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED #ifdef block.
This patch fixes this issue by moving __RTE_ARM_WFE out of RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED block.

Perhaps we should change RTE_ARM_USE_WFE to something like RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL ?

Quoted 7 lines
Quoted 3 lines

+uint8_t wfet_en;

It should be made static probably.
This variable will be unused in some cases, needs #ifdef.

This variable is used in all cases. It's 1 when WFET is available, 0 when it's not.

Quoted 17 lines
Quoted 17 lines
lib/eal/arm/rte_cpuflags.c +11 -1
+
+RTE_INIT(rte_power_intrinsics_init)
+{
+#ifdef RTE_ARCH_64
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_WFXT))
+		wfet_en = 1;
+#endif
+}
+
+/**
+ * This function uses WFE/WFET instruction to make lcore suspend
  * execution on ARM.
- * Note that timestamp based timeout is not supported yet.
  */
 int
 rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 		const uint64_t tsc_timestamp)
Quoted 9 lines

lib/eal/arm/rte_cpuflags.c

Quoted 5 lines

{

lib/eal/arm/rte_cpuflags.c +1 -3
-	RTE_SET_USED(tsc_timestamp);
-
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64

It looks wrong.
If RTE_ARM_USE_WFE is disabled, you should not call __RTE_ARM_WFE().

RTE_ARM_USE_WFE should be renamed to reflect its actual use. It's safe to assume that WFE is available universally in Arm DPDK context.

Quoted 15 lines

lib/eal/arm/rte_cpuflags.c rte_power_monitor(const struct · line 37

Quoted 9 lines
lib/eal/arm/rte_cpuflags.c +0 -1
 	const unsigned int lcore_id = rte_lcore_id();
 	uint64_t cur_value;
@@ -33,28 +44,30 @@ rte_power_monitor(const struct
 rte_power_monitor_cond *pmc,
 
 	switch (pmc->size) {
 	case sizeof(uint8_t):
-		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value,

rte_memory_order_relaxed)

Quoted 3 lines
lib/eal/arm/rte_cpuflags.c +2 -1
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value,
+rte_memory_order_relaxed);
#7 lore raw

Re: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

01/07/2024 23:34, Wathsala Wathawana Vithanage:

Quoted 23 lines
Quoted 8 lines

19/06/2024 08:45, Wathsala Vithanage:

lib/eal/arm/rte_cpuflags.c void · line 168

Quoted 5 lines

rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics)
{

lib/eal/arm/rte_cpuflags.c +0 -1
 	memset(intrinsics, 0, sizeof(*intrinsics)); -#ifdef RTE_ARM_USE_WFE
 	intrinsics->power_monitor = 1;
-#endif

Why removing this #ifdef?

WFE is available in all the Arm platforms DPDK currently supports. Therefore, an explicit flag is not required at build time.

The purpose of RTE_ARM_USE_WFE seems to be controlling the use of WFE in rte_wait_until_equal functions by defining RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED macro only when RTE_ARM_USE_WFE is defined. (eal/arm/include/rte_pause_64.h:15)
From what I'm hearing this was done due to a performance issue rte_wait_until_equal_X functions had when using WFE.
However, that design is flawed because it made other users of WFE dependent on the choice of the use of WFE in rte_wait_until_equal functions as __RTE_ARM_WFE was wrapped in an RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED #ifdef block.
This patch fixes this issue by moving __RTE_ARM_WFE out of RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED block.

Quoted 2 lines

Perhaps we should change RTE_ARM_USE_WFE to something like RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL ?

Yes perhaps.
And more importantly, you should do such change in a separate patch. Don't hide it in WFET patch.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+uint8_t wfet_en;

It should be made static probably.
This variable will be unused in some cases, needs #ifdef.

This variable is used in all cases. It's 1 when WFET is available, 0 when it's not.

It would be 0 if you make it static yes.

Quoted 29 lines
Quoted 17 lines
Quoted 17 lines
lib/eal/arm/rte_power_intrinsics.c +11 -1
+
+RTE_INIT(rte_power_intrinsics_init)
+{
+#ifdef RTE_ARCH_64
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_WFXT))
+		wfet_en = 1;
+#endif
+}
+
+/**
+ * This function uses WFE/WFET instruction to make lcore suspend
  * execution on ARM.
- * Note that timestamp based timeout is not supported yet.
  */
 int
 rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 		const uint64_t tsc_timestamp)
Quoted 9 lines

lib/eal/arm/rte_power_intrinsics.c line 31

Quoted 5 lines

{

lib/eal/arm/rte_power_intrinsics.c +1 -3
-	RTE_SET_USED(tsc_timestamp);
-
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64

It looks wrong.
If RTE_ARM_USE_WFE is disabled, you should not call __RTE_ARM_WFE().

RTE_ARM_USE_WFE should be renamed to reflect its actual use. It's safe to assume that WFE is available universally in Arm DPDK context.

#8 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 8 lines

RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED #ifdef block.

Quoted 5 lines

This patch fixes this issue by moving __RTE_ARM_WFE out of RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED block.

Perhaps we should change RTE_ARM_USE_WFE to something like RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL ?

Yes perhaps.

RTE_ARM_USE_WFE is already used in drivers/event/cnxk/cn10k_worker.h therefore RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL is not suitable.
I wouldn't mind keeping RTE_ARM_USE_WFE because "USE_WFE" sounds like an instruction to use WFE rather than an indication of availability of the WFE instruction.

#9 lore raw

Re: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

03/07/2024 15:27, Wathsala Wathawana Vithanage:

Quoted 4 lines
Quoted 4 lines

RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED #ifdef block.

Quoted 3 lines

This patch fixes this issue by moving __RTE_ARM_WFE out of RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED block.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Perhaps we should change RTE_ARM_USE_WFE to something like RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL ?

Yes perhaps.

RTE_ARM_USE_WFE is already used in drivers/event/cnxk/cn10k_worker.h therefore RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL is not suitable.
I wouldn't mind keeping RTE_ARM_USE_WFE because "USE_WFE" sounds like an instruction to use WFE rather than an indication of availability of the WFE instruction.

The problem is that the definition of this flag is not clear. What is it doing?
If it's really disabling WFE, keep the #ifdef to not use it.

For now, it is a nack of this patch for all reasons described before.

#10 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 13 lines

03/07/2024 15:27, Wathsala Wathawana Vithanage:

Quoted 11 lines
Quoted 8 lines

RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED #ifdef block.

Quoted 5 lines

This patch fixes this issue by moving __RTE_ARM_WFE out of RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED block.

Perhaps we should change RTE_ARM_USE_WFE to something like RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL ?

Yes perhaps.

RTE_ARM_USE_WFE is already used in drivers/event/cnxk/cn10k_worker.h therefore RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL is not suitable. I wouldn't mind keeping RTE_ARM_USE_WFE because "USE_WFE" sounds

like

Quoted 9 lines
Quoted 1 line

an instruction to use WFE rather than an indication of availability of the WFE

instruction.

The problem is that the definition of this flag is not clear. What is it doing?
If it's really disabling WFE, keep the #ifdef to not use it.

For now, it is a nack of this patch for all reasons described before.

Only other place where this flag is used is drivers/event/cnxk/cn10k_worker.h

b8dbcbe8a57 (Pavan Nikhilesh 2024-02-27 13:41:53 +0530 284) #if defined(RTE_ARM_USE_WFE)

Let’s ask Pavan why this flag is used in cn10k driver.

From our perspective, WFE is available on all the supported arm platforms in DPDK. Therefore, RTE_ARM_USE_WFE should be treated as a flag to choose between WFE and non-WFE code paths due to performance reasons rather than as a flag that indicates the availability of the instruction on the target CPU.

#11 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 31 lines
Quoted 5 lines

03/07/2024 15:27, Wathsala Wathawana Vithanage:

Quoted 4 lines
Quoted 4 lines

RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED #ifdef block.

Quoted 3 lines

This patch fixes this issue by moving __RTE_ARM_WFE out of RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED block.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Perhaps we should change RTE_ARM_USE_WFE to something like RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL ?

Yes perhaps.

RTE_ARM_USE_WFE is already used in drivers/event/cnxk/cn10k_worker.h therefore RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL is not suitable. I wouldn't mind keeping RTE_ARM_USE_WFE because "USE_WFE" sounds

like

Quoted 1 line

an instruction to use WFE rather than an indication of availability of the

WFE

Quoted 8 lines

instruction.

The problem is that the definition of this flag is not clear. What is it doing?
If it's really disabling WFE, keep the #ifdef to not use it.

For now, it is a nack of this patch for all reasons described before.

Only other place where this flag is used is drivers/event/cnxk/cn10k_worker.h

b8dbcbe8a57 (Pavan Nikhilesh 2024-02-27 13:41:53 +0530 284) #if
defined(RTE_ARM_USE_WFE)

Let’s ask Pavan why this flag is used in cn10k driver.

Quoted 8 lines

From our perspective, WFE is available on all the supported arm platforms in DPDK.
Therefore, RTE_ARM_USE_WFE should be treated as a flag to choose between WFE
and non-WFE code paths due to performance reasons rather than as a flag that indicates
the availability of the instruction on the target CPU.

We are using this flag to allow application to choose between WFE and non-WFE code path. The non-WFE path performs slightly better.

Quoted 3 lines
#12 lore raw

Re: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

04/07/2024 12:55, Pavan Nikhilesh Bhagavatula:

Quoted 40 lines
Quoted 31 lines
Quoted 5 lines

03/07/2024 15:27, Wathsala Wathawana Vithanage:

Quoted 4 lines
Quoted 4 lines

RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED #ifdef block.

Quoted 3 lines

This patch fixes this issue by moving __RTE_ARM_WFE out of RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED block.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Perhaps we should change RTE_ARM_USE_WFE to something like RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL ?

Yes perhaps.

RTE_ARM_USE_WFE is already used in drivers/event/cnxk/cn10k_worker.h therefore RTE_ARM_USE_WFE_IN_WAIT_UNTIL_EQUAL is not suitable. I wouldn't mind keeping RTE_ARM_USE_WFE because "USE_WFE" sounds

like

Quoted 1 line

an instruction to use WFE rather than an indication of availability of the

WFE

Quoted 8 lines

instruction.

The problem is that the definition of this flag is not clear. What is it doing?
If it's really disabling WFE, keep the #ifdef to not use it.

For now, it is a nack of this patch for all reasons described before.

Only other place where this flag is used is drivers/event/cnxk/cn10k_worker.h

b8dbcbe8a57 (Pavan Nikhilesh 2024-02-27 13:41:53 +0530 284) #if
defined(RTE_ARM_USE_WFE)

Let’s ask Pavan why this flag is used in cn10k driver.

Quoted 8 lines

From our perspective, WFE is available on all the supported arm platforms in DPDK.
Therefore, RTE_ARM_USE_WFE should be treated as a flag to choose between WFE
and non-WFE code paths due to performance reasons rather than as a flag that indicates
the availability of the instruction on the target CPU.

Quoted 2 lines

We are using this flag to allow application to choose between WFE and non-WFE code path. The non-WFE path performs slightly better.

What's the benefit of the WFE path then?

#13 lore raw

Re: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 11 lines · On Thu, 04 Jul 2024 16:14:42 +0200 Thomas Monjalon <[email protected]> wrote:
Quoted 11 lines
Quoted 10 lines

Let’s ask Pavan why this flag is used in cn10k driver.

From our perspective, WFE is available on all the supported arm platforms in DPDK.
Therefore, RTE_ARM_USE_WFE should be treated as a flag to choose between WFE
and non-WFE code paths due to performance reasons rather than as a flag that indicates
the availability of the instruction on the target CPU.

Quoted 4 lines
Quoted 2 lines

We are using this flag to allow application to choose between WFE and non-WFE code path. The non-WFE path performs slightly better.

What's the benefit of the WFE path then?

WFE saves power at the expense of latency.

Maybe some form of hybrid approach would work best and could be always used.

For example, many implementations of mutex do a short spin poll then fall back to a waiting primitive (like futex).

#14 lore raw

Re: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

04/07/2024 16:55, Stephen Hemminger:

Quoted 14 lines
Quoted 11 lines · On Thu, 04 Jul 2024 16:14:42 +0200 Thomas Monjalon <[email protected]> wrote:
Quoted 11 lines
Quoted 10 lines

Let’s ask Pavan why this flag is used in cn10k driver.

From our perspective, WFE is available on all the supported arm platforms in DPDK.
Therefore, RTE_ARM_USE_WFE should be treated as a flag to choose between WFE
and non-WFE code paths due to performance reasons rather than as a flag that indicates
the availability of the instruction on the target CPU.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

We are using this flag to allow application to choose between WFE and non-WFE code path. The non-WFE path performs slightly better.

What's the benefit of the WFE path then?

WFE saves power at the expense of latency.

Yes maybe there is a misunderstanding.
Pavan can you confirm you were saying "throughput is better on non-WFE"? but "power consumption is lower on WFE path"?

Quoted 5 lines

Maybe some form of hybrid approach would work best and could be always used.

For example, many implementations of mutex do a short spin poll then fall back to a waiting primitive (like futex).

#15 lore raw

RE: [EXTERNAL] Re: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 22 lines

04/07/2024 16:55, Stephen Hemminger:

Quoted 6 lines
Quoted 3 lines · On Thu, 04 Jul 2024 16:14:42 +0200 Thomas Monjalon <[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines

Let’s ask Pavan why this flag is used in cn10k driver.

From our perspective, WFE is available on all the supported arm

platforms in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

DPDK.
Therefore, RTE_ARM_USE_WFE should be treated as a flag to choose

between

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

WFE
and non-WFE code paths due to performance reasons rather than as a

flag

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

that indicates
the availability of the instruction on the target CPU.

We are using this flag to allow application to choose between WFE and

non-WFE code path.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

The non-WFE path performs slightly better.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

What's the benefit of the WFE path then?

WFE saves power at the expense of latency.

Yes maybe there is a misunderstanding.
Pavan can you confirm you were saying "throughput is better on non-WFE"? but "power consumption is lower on WFE path"?

Yes, throughput is better on non-WFE and power consumption is lower on WFE path.

But the statement cant be generalized for all use-cases, it depends on lot of factors. So, we use RTE_ARM_USE_WFE to allow applications to decide what they want.

Quoted 5 lines
Quoted 5 lines

Maybe some form of hybrid approach would work best and could be always used.

For example, many implementations of mutex do a short spin poll then fall back to a waiting primitive (like futex).

This is already done across cnxk drivers and common layer I believe.

Quoted 1 line
#16 lore raw

Re: [EXTERNAL] [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 35 lines · Pavan Nikhilesh Bhagavatula
Quoted 23 lines

04/07/2024 16:55, Stephen Hemminger:

Quoted 6 lines
Quoted 3 lines · On Thu, 04 Jul 2024 16:14:42 +0200 Thomas Monjalon <[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines

Let’s ask Pavan why this flag is used in cn10k driver.

From our perspective, WFE is available on all the supported arm

platforms in

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

DPDK.
Therefore, RTE_ARM_USE_WFE should be treated as a flag to choose

between

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

WFE
and non-WFE code paths due to performance reasons rather than as a

flag

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

that indicates
the availability of the instruction on the target CPU.

We are using this flag to allow application to choose between WFE and

non-WFE code path.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

The non-WFE path performs slightly better.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

What's the benefit of the WFE path then?

WFE saves power at the expense of latency.

Yes maybe there is a misunderstanding.
Pavan can you confirm you were saying "throughput is better on non-WFE"? but "power consumption is lower on WFE path"?

Quoted 4 lines

Yes, throughput is better on non-WFE and power consumption is lower on WFE path.

But the statement cant be generalized for all use-cases, it depends on lot of factors. So, we use RTE_ARM_USE_WFE to allow applications to decide what they want.

When WFE was enabled in DPDK, it was introduced in spinlock, ticket lock, ring etc. We ran the relevant micro-benchmarks and realized that with WFE the performance was lower. Hence it was added under a flag to allow the user to choose the feature (not as a way to say that the feature is present in the CPU).

IMO, we should not use this flag for PMD power savings. In PMD, use of WFE is purely for power savings and not performance. IIRC, there is already code and enough configurable parameters available that control when the PMD calls WFE (equivalent in other architectures). So, there is no need of a compile time flag for this.

Quoted 12 lines
Quoted 6 lines
Quoted 6 lines

Maybe some form of hybrid approach would work best and could be always used.

For example, many implementations of mutex do a short spin poll then fall back to a waiting primitive (like futex).

This is already done across cnxk drivers and common layer I believe.

Quoted 1 line
#17 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

In reply to Pavan Nikhilesh Bhagavatula
Quoted 5 lines

We are using this flag to allow application to choose between WFE and non- WFE code path.
The non-WFE path performs slightly better.

Is it correct if I assume that this flag is not used to indicate the availability of WFE instruction in any of your platforms?
If so, then its usage is to choose between WFE and non-WFE implementations for performance reasons.

#18 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 27 lines

-----Original Message-----
From: Wathsala Wathawana Vithanage <[email protected]>
Sent: Friday, July 5, 2024 9:32 PM
To: Pavan Nikhilesh Bhagavatula <[email protected]>; [email protected]
Cc: Tyler Retzlaff <[email protected]>; Ruifeng Wang <[email protected]>; [email protected]; nd <[email protected]>; Dhruv Tripathi <[email protected]>; Honnappa Nagarahalli <[email protected]>; Jack Bond-Preston <jack.bond- [email protected]>; Nick Connolly <[email protected]>; Vinod Krishna <[email protected]>; [email protected]; nd <[email protected]>; nd <[email protected]>
Subject: [EXTERNAL] RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 1 line
Quoted 1 line

We are using this flag to allow application to choose between WFE and

non- > WFE code path. > The non-WFE path performs slightly better. > Is it correct if I assume that this flag is not used to indicate the availability

Quoted 5 lines

We are using this flag to allow application to choose between WFE and non- WFE code path.
The non-WFE path performs slightly better.

Quoted 5 lines

Is it correct if I assume that this flag is not used to indicate the availability of WFE instruction in any of your platforms?
If so, then its usage is to choose between WFE and non-WFE implementations for performance reasons.

Yes, its purely for performance reasons.

Quoted 2 lines
#19 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

Quoted 13 lines
Quoted 13 lines
Quoted 3 lines
Quoted 3 lines

We are using this flag to allow application to choose between WFE and

non- > WFE code path. > The non-WFE path performs slightly better. > Is it correct if I assume that this flag is not used to indicate the availability

Quoted 5 lines

We are using this flag to allow application to choose between WFE and non- WFE code path.
The non-WFE path performs slightly better.

Quoted 8 lines
Quoted 5 lines

Is it correct if I assume that this flag is not used to indicate the availability of WFE instruction in any of your platforms? If so, then its usage is to choose between WFE and non-WFE implementations for performance reasons.

Yes, its purely for performance reasons.

So, in that sense I don't mind keeping the name RTE_ARM_USE_WFE for the purpose of using WFE instruction on a code path based on power/performance bias. This has been the case with rte_wait_until_equal_N functions as well.
If the name RTE_ARM_USE_WFE is confusing, please suggest a better name. We should also document the intended use of this flag.

#20 lore raw

RE: [PATCH v2 2/2] eal: add Arm WFET in power management intrinsics

In reply to Thomas Monjalon
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+uint8_t wfet_en;

It should be made static probably.
This variable will be unused in some cases, needs #ifdef.

This variable is used in all cases. It's 1 when WFET is available, 0 when it's not.

It would be 0 if you make it static yes.

No need to make it static to set it to 0, it will be placed in BSS section as is hence will always be initialized to 0.
Static only limits its scope to this file, has nothing to do with initialization to 0.

#21 lore raw

PATCH v3 1/4 eal: expand the availability of WFE and related instructions

In reply to Wathsala Vithanage

The availability of __RTE_ARM_WFE, __RTE_ARM_SEV, __RTE_ARM_SEVL, and __RTE_ARM_LOAD_EXC_* macros for other applications, such as PMD power management, should not depend on the choice of use of these instructions in rte_wait_until_equal_N functions. Therefore, this patch moves these macros out of control of the RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED macro.

---
 lib/eal/arm/include/rte_pause_64.h | 4 ++--
 lib/eal/arm/rte_cpuflags.c         | 4 ++--
 lib/eal/arm/rte_power_intrinsics.c | 9 ++++-----
 3 files changed, 8 insertions(+), 9 deletions(-)
lib/eal/arm/include/rte_pause_64.h +2 -2
index 9e2dbf3531..8224f09ba7 100644
@@ -24,8 +24,6 @@ static inline void rte_pause(void)
 	asm volatile("yield" ::: "memory");
 }
 
-#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
-
 /* Send a local event to quit WFE. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
@@ -148,6 +146,8 @@ static inline void rte_pause(void)
 		__RTE_ARM_LOAD_EXC_128(src, dst, memorder) \
 }
 
+#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
+
 static __rte_always_inline void
 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
 		rte_memory_order memorder)
lib/eal/arm/rte_cpuflags.c +2 -2
index 7ba4f8ba97..29884c285f 100644
@@ -163,7 +163,7 @@ void
 rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics)
 {
 	memset(intrinsics, 0, sizeof(*intrinsics));
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64
 	intrinsics->power_monitor = 1;
-#endif
+#endif /* RTE_ARCH_64 */
 }
lib/eal/arm/rte_power_intrinsics.c +4 -5
index f54cf59e80..b0056cce8b 100644
@@ -17,7 +17,7 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 {
 	RTE_SET_USED(tsc_timestamp);
 
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64
 	const unsigned int lcore_id = rte_lcore_id();
 	uint64_t cur_value;
 
@@ -57,7 +57,7 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 	RTE_SET_USED(pmc);
 
 	return -ENOTSUP;
-#endif
+#endif /* RTE_ARCH_64 */
 }
 
 /**
@@ -81,13 +81,12 @@ rte_power_monitor_wakeup(const unsigned int lcore_id)
 {
 	RTE_SET_USED(lcore_id);
 
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64
 	__RTE_ARM_SEV()
-
 	return 0;
 #else
 	return -ENOTSUP;
-#endif
+#endif /* RTE_ARCH_64 */
 }
 
 int
Signature · 1 line
2.34.1
#22 lore raw

PATCH v3 2/4 config/arm: adds Arm Neoverse N3 SoC

Add Arm Neoverse N3 part number to build configuration.

---
 config/arm/meson.build | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
config/arm/meson.build +21 -1
index 012935d5d7..8018218b76 100644
@@ -116,6 +116,18 @@ part_number_config_arm = {
             ['RTE_MAX_LCORE', 144],
             ['RTE_MAX_NUMA_NODES', 2]
         ]
+    },
+    '0xd8e': {
+        'march': 'armv8.7-a',
+        'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
+        'flags': [
+            ['RTE_MACHINE', '"neoverse-n3"'],
+            ['RTE_ARM_FEATURE_ATOMICS', true],
+            ['RTE_ARM_FEATURE_WFXT', true],
+            ['RTE_MAX_LCORE', 192],
+            ['RTE_MAX_NUMA_NODES', 2]
+        ]
     }
 }
 implementer_arm = {
@@ -572,6 +584,13 @@ soc_n2 = {
     'numa': false
 }
 
+soc_n3 = {
+    'description': 'Arm Neoverse N3',
+    'implementer': '0x41',
+    'part_number': '0xd8e',
+    'numa': false
+}
+
 soc_odyssey = {
     'description': 'Marvell Odyssey',
     'implementer': '0x41',
@@ -699,6 +718,7 @@ socs = {
     'kunpeng930': soc_kunpeng930,
     'n1sdp': soc_n1sdp,
     'n2': soc_n2,
+    'n3': soc_n3,
     'odyssey' : soc_odyssey,
     'stingray': soc_stingray,
     'thunderx2': soc_thunderx2,
@@ -852,7 +872,7 @@ if update_flags
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
-            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.7-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
Signature · 1 line
2.34.1
#23 lore raw
Quoted 16 lines · Wathsala Vithanage

Add Arm Neoverse N3 part number to build configuration.

---
config/arm/meson.build | 22 +++++++++++++++++++++-

1 file changed, 21 insertions(+), 1 deletion(-)
config/arm/meson.build +0 -0
index 012935d5d7..8018218b76 100644

config/arm/meson.build part_number_config_arm = { · line 121

Quoted 6 lines
config/arm/meson.build +3 -0
@@ -116,6 +116,18 @@ part_number_config_arm = {
            ['RTE_MAX_LCORE', 144],
            ['RTE_MAX_NUMA_NODES', 2]
        ]
+    },
+    '0xd8e': {
+        'march': 'armv8.7-a’,

Should the above be ‘armv9-a’?

Quoted 46 lines
config/arm/meson.build +18 -1
+        'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
+        'flags': [
+            ['RTE_MACHINE', '"neoverse-n3"'],
+            ['RTE_ARM_FEATURE_ATOMICS', true],
+            ['RTE_ARM_FEATURE_WFXT', true],
+            ['RTE_MAX_LCORE', 192],
+            ['RTE_MAX_NUMA_NODES', 2]
+        ]
    }
 }
 implementer_arm = {
@@ -572,6 +584,13 @@ soc_n2 = {
    'numa': false
 }
 
+soc_n3 = {
+    'description': 'Arm Neoverse N3',
+    'implementer': '0x41',
+    'part_number': '0xd8e',
+    'numa': false
+}
+
 soc_odyssey = {
    'description': 'Marvell Odyssey',
    'implementer': '0x41',
@@ -699,6 +718,7 @@ socs = {
    'kunpeng930': soc_kunpeng930,
    'n1sdp': soc_n1sdp,
    'n2': soc_n2,
+    'n3': soc_n3,
    'odyssey' : soc_odyssey,
    'stingray': soc_stingray,
    'thunderx2': soc_thunderx2,
@@ -852,7 +872,7 @@ if update_flags
        if part_number_config.get('force_march', false)
            candidate_march = part_number_config['march']
        else
-            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.7-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                'armv8.2-a', 'armv8.1-a', 'armv8-a']
            check_compiler_support = false
            foreach supported_march: supported_marchs
Signature · 1 line
2.34.1
#24 lore raw

PATCH v3 3/4 eal: add Arm WFET in power management intrinsics

In reply to Wathsala Vithanage

Wait for event with timeout (WFET) puts the CPU in a low power mode and stays there until an event is signalled (SEV), loss of an exclusive monitor or a timeout.
WFET is enabled selectively by checking FEAT_WFxT in Linux auxiliary vector. If FEAT_WFxT is not available power management will fallback to WFE.
WFE is available on all the Arm platforms supported by DPDK. Therefore, the RTE_ARM_USE_WFE macro is not required to enable the WFE feature for PMD power monitoring.
RTE_ARM_USE_WFE is used at the build time to use the WFE instruction where applicable in the code at the developer's discretion rather than as an indicator of the instruction's availability.

---
 .mailmap                              |  2 ++
 app/test/test_cpuflags.c              |  3 +++
 lib/eal/arm/include/rte_cpuflags_64.h |  3 +++
 lib/eal/arm/include/rte_pause_64.h    | 16 +++++++++--
 lib/eal/arm/rte_cpuflags.c            |  1 +
 lib/eal/arm/rte_power_intrinsics.c    | 39 ++++++++++++++++++---------
 6 files changed, 50 insertions(+), 14 deletions(-)
.mailmap +2 -0
index f1e64286a1..a5c49d3702 100644
@@ -338,6 +338,7 @@ Dexia Li <[email protected]>
 Dexuan Cui <[email protected]>
 Dharmik Thakkar <[email protected]> <[email protected]>
 Dheemanth Mallikarjun <[email protected]>
+Dhruv Tripathi <[email protected]>
 Diana Wang <[email protected]>
 Didier Pallard <[email protected]>
 Dilshod Urazov <[email protected]>
@@ -1539,6 +1540,7 @@ Vincent Li <[email protected]>
 Vincent S. Cojot <[email protected]>
 Vinh Tran <[email protected]>
 Vipin Padmam Ramesh <[email protected]>
+Vinod Krishna <[email protected]>
 Vipin Varghese <[email protected]> <[email protected]>
 Vipul Ashri <[email protected]>
 Visa Hankala <[email protected]>
app/test/test_cpuflags.c +3 -0
index a0ff74720c..22ab4dff0a 100644
@@ -156,6 +156,9 @@ test_cpuflags(void)
 
 	printf("Check for SVEBF16:\t");
 	CHECK_FOR_FLAG(RTE_CPUFLAG_SVEBF16);
+
+	printf("Check for WFXT:\t");
+	CHECK_FOR_FLAG(RTE_CPUFLAG_WFXT);
 #endif
 
 #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
lib/eal/arm/include/rte_cpuflags_64.h +3 -0
index afe70209c3..993d980a02 100644
@@ -36,6 +36,9 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_SVEF64MM,
 	RTE_CPUFLAG_SVEBF16,
 	RTE_CPUFLAG_AARCH64,
+
+	/* WFET and WFIT instructions */
+	RTE_CPUFLAG_WFXT,
 };
 
 #include "generic/rte_cpuflags.h"
lib/eal/arm/include/rte_pause_64.h +14 -2
index 8224f09ba7..809403bffa 100644
@@ -24,15 +24,27 @@ static inline void rte_pause(void)
 	asm volatile("yield" ::: "memory");
 }
 
-/* Send a local event to quit WFE. */
+/* Send a local event to quit WFE/WFxT. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
-/* Send a global event to quit WFE for all cores. */
+/* Send a global event to quit WFE/WFxT for all cores. */
 #define __RTE_ARM_SEV() { asm volatile("sev" : : : "memory"); }
 
 /* Put processor into low power WFE(Wait For Event) state. */
 #define __RTE_ARM_WFE() { asm volatile("wfe" : : : "memory"); }
 
+/* Put processor into low power WFET (WFE with Timeout) state. */
+#ifdef RTE_ARM_FEATURE_WFXT
+#define __RTE_ARM_WFET(t) {                              \
+	asm volatile("wfet %x[to]"                        \
+			:                                 \
+			: [to] "r" (t)                    \
+			: "memory");                      \
+	}
+#else
+#define __RTE_ARM_WFET(t) { RTE_SET_USED(t); }
+#endif
+
 /*
  * Atomic exclusive load from addr, it returns the 8-bit content of
  * *addr while making it 'monitored', when it is written by someone
lib/eal/arm/rte_cpuflags.c +1 -0
index 29884c285f..88e10c6da0 100644
@@ -115,6 +115,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(SVEF32MM,	REG_HWCAP2,   10)
 	FEAT_DEF(SVEF64MM,	REG_HWCAP2,   11)
 	FEAT_DEF(SVEBF16,	REG_HWCAP2,   12)
+	FEAT_DEF(WFXT,		REG_HWCAP2,   31)
 	FEAT_DEF(AARCH64,	REG_PLATFORM,  0)
 };
 #endif /* RTE_ARCH */
lib/eal/arm/rte_power_intrinsics.c +27 -12
index b0056cce8b..6475bbca04 100644
@@ -4,19 +4,32 @@
 
 #include <errno.h>
 
+#include "rte_cpuflags.h"
 #include "rte_power_intrinsics.h"
 
 /**
- * This function uses WFE instruction to make lcore suspend
+ *  Set wfet_en if WFET is supported
+ */
+#ifdef RTE_ARCH_64
+static uint8_t wfet_en;
+#endif /* RTE_ARCH_64 */
+
+RTE_INIT(rte_power_intrinsics_init)
+{
+#ifdef RTE_ARCH_64
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_WFXT))
+		wfet_en = 1;
+#endif /* RTE_ARCH_64 */
+}
+
+/**
+ * This function uses WFE/WFET instruction to make lcore suspend
  * execution on ARM.
- * Note that timestamp based timeout is not supported yet.
  */
 int
 rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 		const uint64_t tsc_timestamp)
 {
-	RTE_SET_USED(tsc_timestamp);
-
 #ifdef RTE_ARCH_64
 	const unsigned int lcore_id = rte_lcore_id();
 	uint64_t cur_value;
@@ -33,28 +46,30 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 
 	switch (pmc->size) {
 	case sizeof(uint8_t):
-		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	case sizeof(uint16_t):
-		__RTE_ARM_LOAD_EXC_16(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_16(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	case sizeof(uint32_t):
-		__RTE_ARM_LOAD_EXC_32(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_32(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	case sizeof(uint64_t):
-		__RTE_ARM_LOAD_EXC_64(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_64(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	default:
 		return -EINVAL; /* unexpected size */
 	}
 
+	if (wfet_en)
+		__RTE_ARM_WFET(tsc_timestamp)
+	else
+		__RTE_ARM_WFE()
+
 	return 0;
 #else
 	RTE_SET_USED(pmc);
+	RTE_SET_USED(tsc_timestamp);
 
 	return -ENOTSUP;
 #endif /* RTE_ARCH_64 */
Signature · 1 line
2.34.1
#25 lore raw

PATCH v3 4/4 eal: describe Arm CPU features including WFXT

In reply to Wathsala Vithanage

RTE_CPUFALG_WFXT indicates the availability of WFET and WFIT instructions. To preserve consistency across the rte_cpu_flag_t enumeration, add descriptive comments to each Arm feature listed.

---
 lib/eal/arm/include/rte_cpuflags_64.h | 48 +++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
lib/eal/arm/include/rte_cpuflags_64.h +48 -0
index 993d980a02..eed67bf6ec 100644
@@ -13,28 +13,76 @@ extern "C" {
  * Enumeration of all CPU features supported
  */
 enum rte_cpu_flag_t {
+	/* Floating point capability */
 	RTE_CPUFLAG_FP = 0,
+
+	/* Arm Neon extension */
 	RTE_CPUFLAG_NEON,
+
+	/* Generic timer event stream */
 	RTE_CPUFLAG_EVTSTRM,
+
+	/* AES instructions */
 	RTE_CPUFLAG_AES,
+
+	/* Polynomial multiply long instruction */
 	RTE_CPUFLAG_PMULL,
+
+	/* SHA1 instructions */
 	RTE_CPUFLAG_SHA1,
+
+	/* SHA2 instructions */
 	RTE_CPUFLAG_SHA2,
+
+	/* CRC32 instruction */
 	RTE_CPUFLAG_CRC32,
+
+	/*
+	 * LDADD, LDCLR, LDEOR, LDSET, LDSMAX, LDSMIN, LDUMAX, LDUMIN, CAS,
+	 * CASP, and SWP instructions
+	 */
 	RTE_CPUFLAG_ATOMICS,
+
+	/* Arm SVE extension */
 	RTE_CPUFLAG_SVE,
+
+	/* Arm SVE2 extension */
 	RTE_CPUFLAG_SVE2,
+
+	/* SVE-AES instructions */
 	RTE_CPUFLAG_SVEAES,
+
+	/* SVE-PMULL instruction */
 	RTE_CPUFLAG_SVEPMULL,
+
+	/* SVE bit permute instructions */
 	RTE_CPUFLAG_SVEBITPERM,
+
+	/* SVE-SHA3 instructions */
 	RTE_CPUFLAG_SVESHA3,
+
+	/* SVE-SM4 instructions */
 	RTE_CPUFLAG_SVESM4,
+
+	/* CFINV, RMIF, SETF16, SETF8, AXFLAG, and XAFLAG instructions */
 	RTE_CPUFLAG_FLAGM2,
+
+	/* FRINT32Z, FRINT32X, FRINT64Z, and FRINT64X instructions */
 	RTE_CPUFLAG_FRINT,
+
+	/* SVE Int8 matrix multiplication instructions */
 	RTE_CPUFLAG_SVEI8MM,
+
+	/* SVE FP32 floating-point matrix multiplication instructions */
 	RTE_CPUFLAG_SVEF32MM,
+
+	/* SVE FP64 floating-point matrix multiplication instructions */
 	RTE_CPUFLAG_SVEF64MM,
+
+	/* SVE BFloat16 instructions */
 	RTE_CPUFLAG_SVEBF16,
+
+	/* 64 bit execution state of the Arm architecture */
 	RTE_CPUFLAG_AARCH64,
 
 	/* WFET and WFIT instructions */
Signature · 1 line
2.34.1
Reviewed-by on v3 4/4
#26 lore raw

Re: [PATCH v3 4/4] eal: describe Arm CPU features including WFXT

Quoted 7 lines · Wathsala Vithanage

RTE_CPUFALG_WFXT indicates the availability of WFET and WFIT instructions. To preserve consistency across the rte_cpu_flag_t enumeration, add descriptive comments to each Arm feature listed.

IMO, above can be simpler. “Add descriptive comments to each Arm feature listed in rte_cpu_flag_t"

Quoted 3 lines

Otherwise, looks good.

Quoted 88 lines

---
lib/eal/arm/include/rte_cpuflags_64.h | 48 +++++++++++++++++++++++++++

1 file changed, 48 insertions(+)
lib/eal/arm/include/rte_cpuflags_64.h +48 -0
index 993d980a02..eed67bf6ec 100644
@@ -13,28 +13,76 @@ extern "C" {
 * Enumeration of all CPU features supported
 */
 enum rte_cpu_flag_t {
+ /* Floating point capability */
 RTE_CPUFLAG_FP = 0,
+
+ /* Arm Neon extension */
 RTE_CPUFLAG_NEON,
+
+ /* Generic timer event stream */
 RTE_CPUFLAG_EVTSTRM,
+
+ /* AES instructions */
 RTE_CPUFLAG_AES,
+
+ /* Polynomial multiply long instruction */
 RTE_CPUFLAG_PMULL,
+
+ /* SHA1 instructions */
 RTE_CPUFLAG_SHA1,
+
+ /* SHA2 instructions */
 RTE_CPUFLAG_SHA2,
+
+ /* CRC32 instruction */
 RTE_CPUFLAG_CRC32,
+
+ /*
+ * LDADD, LDCLR, LDEOR, LDSET, LDSMAX, LDSMIN, LDUMAX, LDUMIN, CAS,
+ * CASP, and SWP instructions
+ */
 RTE_CPUFLAG_ATOMICS,
+
+ /* Arm SVE extension */
 RTE_CPUFLAG_SVE,
+
+ /* Arm SVE2 extension */
 RTE_CPUFLAG_SVE2,
+
+ /* SVE-AES instructions */
 RTE_CPUFLAG_SVEAES,
+
+ /* SVE-PMULL instruction */
 RTE_CPUFLAG_SVEPMULL,
+
+ /* SVE bit permute instructions */
 RTE_CPUFLAG_SVEBITPERM,
+
+ /* SVE-SHA3 instructions */
 RTE_CPUFLAG_SVESHA3,
+
+ /* SVE-SM4 instructions */
 RTE_CPUFLAG_SVESM4,
+
+ /* CFINV, RMIF, SETF16, SETF8, AXFLAG, and XAFLAG instructions */
 RTE_CPUFLAG_FLAGM2,
+
+ /* FRINT32Z, FRINT32X, FRINT64Z, and FRINT64X instructions */
 RTE_CPUFLAG_FRINT,
+
+ /* SVE Int8 matrix multiplication instructions */
 RTE_CPUFLAG_SVEI8MM,
+
+ /* SVE FP32 floating-point matrix multiplication instructions */
 RTE_CPUFLAG_SVEF32MM,
+
+ /* SVE FP64 floating-point matrix multiplication instructions */
 RTE_CPUFLAG_SVEF64MM,
+
+ /* SVE BFloat16 instructions */
 RTE_CPUFLAG_SVEBF16,
+
+ /* 64 bit execution state of the Arm architecture */
 RTE_CPUFLAG_AARCH64,
 
 /* WFET and WFIT instructions */
Signature · 1 line
2.34.1
#27 lore raw

PATCH v4 1/4 eal: expand the availability of WFE and related instructions

In reply to Wathsala Vithanage

The availability of __RTE_ARM_WFE, __RTE_ARM_SEV, __RTE_ARM_SEVL, and __RTE_ARM_LOAD_EXC_* macros for other applications, such as PMD power management, should not depend on the choice of use of these instructions in rte_wait_until_equal_N functions. Therefore, this patch moves these macros out of control of the RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED macro.

---
 .mailmap                           | 1 +
 lib/eal/arm/include/rte_pause_64.h | 4 ++--
 lib/eal/arm/rte_cpuflags.c         | 4 ++--
 lib/eal/arm/rte_power_intrinsics.c | 9 ++++-----
 4 files changed, 9 insertions(+), 9 deletions(-)
.mailmap +1 -0
index f1e64286a1..9c28b74655 100644
@@ -338,6 +338,7 @@ Dexia Li <[email protected]>
 Dexuan Cui <[email protected]>
 Dharmik Thakkar <[email protected]> <[email protected]>
 Dheemanth Mallikarjun <[email protected]>
+Dhruv Tripathi <[email protected]>
 Diana Wang <[email protected]>
 Didier Pallard <[email protected]>
 Dilshod Urazov <[email protected]>
lib/eal/arm/include/rte_pause_64.h +2 -2
index 9e2dbf3531..8224f09ba7 100644
@@ -24,8 +24,6 @@ static inline void rte_pause(void)
 	asm volatile("yield" ::: "memory");
 }
 
-#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
-
 /* Send a local event to quit WFE. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
@@ -148,6 +146,8 @@ static inline void rte_pause(void)
 		__RTE_ARM_LOAD_EXC_128(src, dst, memorder) \
 }
 
+#ifdef RTE_WAIT_UNTIL_EQUAL_ARCH_DEFINED
+
 static __rte_always_inline void
 rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
 		rte_memory_order memorder)
lib/eal/arm/rte_cpuflags.c +2 -2
index 7ba4f8ba97..29884c285f 100644
@@ -163,7 +163,7 @@ void
 rte_cpu_get_intrinsics_support(struct rte_cpu_intrinsics *intrinsics)
 {
 	memset(intrinsics, 0, sizeof(*intrinsics));
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64
 	intrinsics->power_monitor = 1;
-#endif
+#endif /* RTE_ARCH_64 */
 }
lib/eal/arm/rte_power_intrinsics.c +4 -5
index f54cf59e80..b0056cce8b 100644
@@ -17,7 +17,7 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 {
 	RTE_SET_USED(tsc_timestamp);
 
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64
 	const unsigned int lcore_id = rte_lcore_id();
 	uint64_t cur_value;
 
@@ -57,7 +57,7 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 	RTE_SET_USED(pmc);
 
 	return -ENOTSUP;
-#endif
+#endif /* RTE_ARCH_64 */
 }
 
 /**
@@ -81,13 +81,12 @@ rte_power_monitor_wakeup(const unsigned int lcore_id)
 {
 	RTE_SET_USED(lcore_id);
 
-#ifdef RTE_ARM_USE_WFE
+#ifdef RTE_ARCH_64
 	__RTE_ARM_SEV()
-
 	return 0;
 #else
 	return -ENOTSUP;
-#endif
+#endif /* RTE_ARCH_64 */
 }
 
 int
Signature · 1 line
2.34.1
#28 lore raw

PATCH v4 2/4 config/arm: adds Arm Neoverse N3 SoC

Add Arm Neoverse N3 part number to build configuration.

---
 config/arm/meson.build | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
config/arm/meson.build +30 -1
index 012935d5d7..acf8e933ab 100644
@@ -116,6 +116,27 @@ part_number_config_arm = {
             ['RTE_MAX_LCORE', 144],
             ['RTE_MAX_NUMA_NODES', 2]
         ]
+    },
+    '0xd8e': {
+# Only when -march=armv9-a+wfxt is used will the WFET
+# feature be compiled with armv9 instructions.
+# However, +wfxt is not supported by GCC at the moment.
+# Although armv9-a is the fitting version of Arm ISA for
+# Neoverse N3, it cannot be used when enabling wfxt for
+# the above reasons.
+# The workaround for this is to use armv8.7-a, which
+# doesn't require +wfxt for binutils version 2.36 or
+# greater.
+        'march': 'armv8.7-a',
+        'march_features': ['sve2'],
+        'fallback_march': 'armv8.5-a',
+        'flags': [
+            ['RTE_MACHINE', '"neoverse-n3"'],
+            ['RTE_ARM_FEATURE_ATOMICS', true],
+            ['RTE_ARM_FEATURE_WFXT', true],
+            ['RTE_MAX_LCORE', 192],
+            ['RTE_MAX_NUMA_NODES', 2]
+        ]
     }
 }
 implementer_arm = {
@@ -572,6 +593,13 @@ soc_n2 = {
     'numa': false
 }
 
+soc_n3 = {
+    'description': 'Arm Neoverse N3',
+    'implementer': '0x41',
+    'part_number': '0xd8e',
+    'numa': false
+}
+
 soc_odyssey = {
     'description': 'Marvell Odyssey',
     'implementer': '0x41',
@@ -699,6 +727,7 @@ socs = {
     'kunpeng930': soc_kunpeng930,
     'n1sdp': soc_n1sdp,
     'n2': soc_n2,
+    'n3': soc_n3,
     'odyssey' : soc_odyssey,
     'stingray': soc_stingray,
     'thunderx2': soc_thunderx2,
@@ -852,7 +881,7 @@ if update_flags
         if part_number_config.get('force_march', false)
             candidate_march = part_number_config['march']
         else
-            supported_marchs = ['armv9-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
+            supported_marchs = ['armv9-a', 'armv8.7-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a',
                                 'armv8.2-a', 'armv8.1-a', 'armv8-a']
             check_compiler_support = false
             foreach supported_march: supported_marchs
Signature · 1 line
2.34.1
#29 lore raw

PATCH v4 3/4 eal: add Arm WFET in power management intrinsics

In reply to Wathsala Vithanage

Wait for event with timeout (WFET) puts the CPU in a low power mode and stays there until an event is signalled (SEV), loss of an exclusive monitor or a timeout.
WFET is enabled selectively by checking FEAT_WFxT in Linux auxiliary vector. If FEAT_WFxT is not available power management will fallback to WFE.
WFE is available on all the Arm platforms supported by DPDK. Therefore, the RTE_ARM_USE_WFE macro is not required to enable the WFE feature for PMD power monitoring.
RTE_ARM_USE_WFE is used at the build time to use the WFE instruction where applicable in the code at the developer's discretion rather than as an indicator of the instruction's availability.

---
 .mailmap                              |  1 +
 app/test/test_cpuflags.c              |  3 +++
 lib/eal/arm/include/rte_cpuflags_64.h |  3 +++
 lib/eal/arm/include/rte_pause_64.h    | 16 +++++++++--
 lib/eal/arm/rte_cpuflags.c            |  1 +
 lib/eal/arm/rte_power_intrinsics.c    | 39 ++++++++++++++++++---------
 6 files changed, 49 insertions(+), 14 deletions(-)
.mailmap +1 -0
index 9c28b74655..a5c49d3702 100644
@@ -1540,6 +1540,7 @@ Vincent Li <[email protected]>
 Vincent S. Cojot <[email protected]>
 Vinh Tran <[email protected]>
 Vipin Padmam Ramesh <[email protected]>
+Vinod Krishna <[email protected]>
 Vipin Varghese <[email protected]> <[email protected]>
 Vipul Ashri <[email protected]>
 Visa Hankala <[email protected]>
app/test/test_cpuflags.c +3 -0
index a0ff74720c..22ab4dff0a 100644
@@ -156,6 +156,9 @@ test_cpuflags(void)
 
 	printf("Check for SVEBF16:\t");
 	CHECK_FOR_FLAG(RTE_CPUFLAG_SVEBF16);
+
+	printf("Check for WFXT:\t");
+	CHECK_FOR_FLAG(RTE_CPUFLAG_WFXT);
 #endif
 
 #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686)
lib/eal/arm/include/rte_cpuflags_64.h +3 -0
index afe70209c3..993d980a02 100644
@@ -36,6 +36,9 @@ enum rte_cpu_flag_t {
 	RTE_CPUFLAG_SVEF64MM,
 	RTE_CPUFLAG_SVEBF16,
 	RTE_CPUFLAG_AARCH64,
+
+	/* WFET and WFIT instructions */
+	RTE_CPUFLAG_WFXT,
 };
 
 #include "generic/rte_cpuflags.h"
lib/eal/arm/include/rte_pause_64.h +14 -2
index 8224f09ba7..809403bffa 100644
@@ -24,15 +24,27 @@ static inline void rte_pause(void)
 	asm volatile("yield" ::: "memory");
 }
 
-/* Send a local event to quit WFE. */
+/* Send a local event to quit WFE/WFxT. */
 #define __RTE_ARM_SEVL() { asm volatile("sevl" : : : "memory"); }
 
-/* Send a global event to quit WFE for all cores. */
+/* Send a global event to quit WFE/WFxT for all cores. */
 #define __RTE_ARM_SEV() { asm volatile("sev" : : : "memory"); }
 
 /* Put processor into low power WFE(Wait For Event) state. */
 #define __RTE_ARM_WFE() { asm volatile("wfe" : : : "memory"); }
 
+/* Put processor into low power WFET (WFE with Timeout) state. */
+#ifdef RTE_ARM_FEATURE_WFXT
+#define __RTE_ARM_WFET(t) {                              \
+	asm volatile("wfet %x[to]"                        \
+			:                                 \
+			: [to] "r" (t)                    \
+			: "memory");                      \
+	}
+#else
+#define __RTE_ARM_WFET(t) { RTE_SET_USED(t); }
+#endif
+
 /*
  * Atomic exclusive load from addr, it returns the 8-bit content of
  * *addr while making it 'monitored', when it is written by someone
lib/eal/arm/rte_cpuflags.c +1 -0
index 29884c285f..88e10c6da0 100644
@@ -115,6 +115,7 @@ const struct feature_entry rte_cpu_feature_table[] = {
 	FEAT_DEF(SVEF32MM,	REG_HWCAP2,   10)
 	FEAT_DEF(SVEF64MM,	REG_HWCAP2,   11)
 	FEAT_DEF(SVEBF16,	REG_HWCAP2,   12)
+	FEAT_DEF(WFXT,		REG_HWCAP2,   31)
 	FEAT_DEF(AARCH64,	REG_PLATFORM,  0)
 };
 #endif /* RTE_ARCH */
lib/eal/arm/rte_power_intrinsics.c +27 -12
index b0056cce8b..6475bbca04 100644
@@ -4,19 +4,32 @@
 
 #include <errno.h>
 
+#include "rte_cpuflags.h"
 #include "rte_power_intrinsics.h"
 
 /**
- * This function uses WFE instruction to make lcore suspend
+ *  Set wfet_en if WFET is supported
+ */
+#ifdef RTE_ARCH_64
+static uint8_t wfet_en;
+#endif /* RTE_ARCH_64 */
+
+RTE_INIT(rte_power_intrinsics_init)
+{
+#ifdef RTE_ARCH_64
+	if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_WFXT))
+		wfet_en = 1;
+#endif /* RTE_ARCH_64 */
+}
+
+/**
+ * This function uses WFE/WFET instruction to make lcore suspend
  * execution on ARM.
- * Note that timestamp based timeout is not supported yet.
  */
 int
 rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 		const uint64_t tsc_timestamp)
 {
-	RTE_SET_USED(tsc_timestamp);
-
 #ifdef RTE_ARCH_64
 	const unsigned int lcore_id = rte_lcore_id();
 	uint64_t cur_value;
@@ -33,28 +46,30 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc,
 
 	switch (pmc->size) {
 	case sizeof(uint8_t):
-		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_8(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	case sizeof(uint16_t):
-		__RTE_ARM_LOAD_EXC_16(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_16(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	case sizeof(uint32_t):
-		__RTE_ARM_LOAD_EXC_32(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_32(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	case sizeof(uint64_t):
-		__RTE_ARM_LOAD_EXC_64(pmc->addr, cur_value, rte_memory_order_relaxed)
-		__RTE_ARM_WFE()
+		__RTE_ARM_LOAD_EXC_64(pmc->addr, cur_value, rte_memory_order_relaxed);
 		break;
 	default:
 		return -EINVAL; /* unexpected size */
 	}
 
+	if (wfet_en)
+		__RTE_ARM_WFET(tsc_timestamp)
+	else
+		__RTE_ARM_WFE()
+
 	return 0;
 #else
 	RTE_SET_USED(pmc);
+	RTE_SET_USED(tsc_timestamp);
 
 	return -ENOTSUP;
 #endif /* RTE_ARCH_64 */
Signature · 1 line
2.34.1
#30 lore raw

Re: [PATCH v4 3/4] eal: add Arm WFET in power management intrinsics

26/07/2024 19:15, Wathsala Vithanage:

Quoted 13 lines

Wait for event with timeout (WFET) puts the CPU in a low power mode and stays there until an event is signalled (SEV), loss of an exclusive monitor or a timeout.
WFET is enabled selectively by checking FEAT_WFxT in Linux auxiliary vector. If FEAT_WFxT is not available power management will fallback to WFE.
WFE is available on all the Arm platforms supported by DPDK. Therefore, the RTE_ARM_USE_WFE macro is not required to enable the WFE feature for PMD power monitoring.
RTE_ARM_USE_WFE is used at the build time to use the WFE instruction where applicable in the code at the developer's discretion rather than as an indicator of the instruction's availability.

Quoted 6 lines

Series applied, thanks.

#31 lore raw

PATCH v4 4/4 eal: describe Arm CPU features including WFXT

In reply to Wathsala Vithanage

Add descriptive comments to each Arm feature listed in rte_cpu_flag_t.

---
 lib/eal/arm/include/rte_cpuflags_64.h | 48 +++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
lib/eal/arm/include/rte_cpuflags_64.h +48 -0
index 993d980a02..eed67bf6ec 100644
@@ -13,28 +13,76 @@ extern "C" {
  * Enumeration of all CPU features supported
  */
 enum rte_cpu_flag_t {
+	/* Floating point capability */
 	RTE_CPUFLAG_FP = 0,
+
+	/* Arm Neon extension */
 	RTE_CPUFLAG_NEON,
+
+	/* Generic timer event stream */
 	RTE_CPUFLAG_EVTSTRM,
+
+	/* AES instructions */
 	RTE_CPUFLAG_AES,
+
+	/* Polynomial multiply long instruction */
 	RTE_CPUFLAG_PMULL,
+
+	/* SHA1 instructions */
 	RTE_CPUFLAG_SHA1,
+
+	/* SHA2 instructions */
 	RTE_CPUFLAG_SHA2,
+
+	/* CRC32 instruction */
 	RTE_CPUFLAG_CRC32,
+
+	/*
+	 * LDADD, LDCLR, LDEOR, LDSET, LDSMAX, LDSMIN, LDUMAX, LDUMIN, CAS,
+	 * CASP, and SWP instructions
+	 */
 	RTE_CPUFLAG_ATOMICS,
+
+	/* Arm SVE extension */
 	RTE_CPUFLAG_SVE,
+
+	/* Arm SVE2 extension */
 	RTE_CPUFLAG_SVE2,
+
+	/* SVE-AES instructions */
 	RTE_CPUFLAG_SVEAES,
+
+	/* SVE-PMULL instruction */
 	RTE_CPUFLAG_SVEPMULL,
+
+	/* SVE bit permute instructions */
 	RTE_CPUFLAG_SVEBITPERM,
+
+	/* SVE-SHA3 instructions */
 	RTE_CPUFLAG_SVESHA3,
+
+	/* SVE-SM4 instructions */
 	RTE_CPUFLAG_SVESM4,
+
+	/* CFINV, RMIF, SETF16, SETF8, AXFLAG, and XAFLAG instructions */
 	RTE_CPUFLAG_FLAGM2,
+
+	/* FRINT32Z, FRINT32X, FRINT64Z, and FRINT64X instructions */
 	RTE_CPUFLAG_FRINT,
+
+	/* SVE Int8 matrix multiplication instructions */
 	RTE_CPUFLAG_SVEI8MM,
+
+	/* SVE FP32 floating-point matrix multiplication instructions */
 	RTE_CPUFLAG_SVEF32MM,
+
+	/* SVE FP64 floating-point matrix multiplication instructions */
 	RTE_CPUFLAG_SVEF64MM,
+
+	/* SVE BFloat16 instructions */
 	RTE_CPUFLAG_SVEBF16,
+
+	/* 64 bit execution state of the Arm architecture */
 	RTE_CPUFLAG_AARCH64,
 
 	/* WFET and WFIT instructions */
Signature · 1 line
2.34.1