Skip to contentSkip to conversation

app/crypto-perf: fix socket ID default value

PATCH Superseded Ciara Power 3 participants 5 messages Jul 5, 2023 – Jul 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/crypto-perf: fix socket ID default value

Due to recent changes to the default device socket ID, before being used as an index for session mempool list, the socket ID should be set to 0 if unknown (-1).

Fixes 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by default")
---
 app/test-crypto-perf/main.c | 5 +++++
 1 file changed, 5 insertions(+)
app/test-crypto-perf/main.c +5 -0
index af5bd0d23b..b74e7ba118 100644
@@ -651,6 +651,11 @@ main(int argc, char **argv)
 		cdev_id = enabled_cdevs[cdev_index];
 
 		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+		/* range check the socket_id, negative values become big
+		 * positive ones due to use of unsigned value
+		 */
+		if (socket_id >= RTE_MAX_NUMA_NODES)
+			socket_id = 0;
 
 		ctx[i] = cperf_testmap[opts.test].constructor(
 				session_pool_socket[socket_id].sess_mp,
Signature · 1 line
2.25.1
Acked-by Kai Ji on v1 1/1
#1 lore raw

________________________________
From: Ciara Power <[email protected]>
Sent: 05 July 2023 11:30
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>; Power, Ciara <[email protected]>; Matz, Olivier <[email protected]>; [email protected] <[email protected]>
Subject: [PATCH] app/crypto-perf: fix socket ID default value

Due to recent changes to the default device socket ID, before being used as an index for session mempool list, the socket ID should be set to 0 if unknown (-1).

Fixes 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by default")
---
 app/test-crypto-perf/main.c | 5 +++++
 1 file changed, 5 insertions(+)
app/test-crypto-perf/main.c +5 -0
index af5bd0d23b..b74e7ba118 100644
@@ -651,6 +651,11 @@ main(int argc, char **argv)
                 cdev_id = enabled_cdevs[cdev_index];
 
                 uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+               /* range check the socket_id, negative values become big
+                * positive ones due to use of unsigned value
+                */
+               if (socket_id >= RTE_MAX_NUMA_NODES)
+                       socket_id = 0;
 
                 ctx[i] = cperf_testmap[opts.test].constructor(
                                 session_pool_socket[socket_id].sess_mp,

--
2.25.1

#2 lore raw
In reply to Ciara Power
Quoted 19 lines

Due to recent changes to the default device socket ID, before being used as an index for session mempool list, the socket ID should be set to 0 if unknown (-1).

Fixes 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by

default")
Cc: [email protected]
Cc: [email protected]

---
 app/test-crypto-perf/main.c | 5 +++++
 1 file changed, 5 insertions(+)
app/test-crypto-perf/main.c +0 -0
index af5bd0d23b..b74e7ba118 100644

app/test-crypto-perf/main.c main(int argc, char **argv) · line 658

Quoted 8 lines
app/test-crypto-perf/main.c +5 -0
@@ -651,6 +651,11 @@ main(int argc, char **argv)
 		cdev_id = enabled_cdevs[cdev_index];
 
 		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+		/* range check the socket_id, negative values become big
+		 * positive ones due to use of unsigned value
+		 */
+		if (socket_id >= RTE_MAX_NUMA_NODES)
+			socket_id = 0;

Shouldn't we make this as
int socket_id = rte_cryptodev_socket_id(cdev_id);
if (socket_id == SOCKET_ID_ANY)
socket_id = 0; /* Use the first socket if SOCKET_ID_ANY is returned. */

Since rte_cryptodev_socket_id returns signed value,
the application should not typecast it to unsigned value and then check for max value. Same comment for the ipsec-secgw patch.

#3 lore raw

PATCH v2 1/1 app/crypto-perf: fix socket ID default value

In reply to Ciara Power

Due to recent changes to the default device socket ID, before being used as an index for session mempool list, the socket ID should be set to 0 if unknown (-1).

Fixes 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by default")
Fixes 64c469b9e7d8 ("app/crypto-perf: check range of socket id")

---
v2: check if socket ID equals SOCKET_ID_ANY

---
 app/test-crypto-perf/main.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
app/test-crypto-perf/main.c +9 -6
index af5bd0d23b..bc1f0f9659 100644
@@ -193,11 +193,10 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 #endif
 
 		struct rte_cryptodev_info cdev_info;
-		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
-		/* range check the socket_id - negative values become big
-		 * positive ones due to use of unsigned value
-		 */
-		if (socket_id >= RTE_MAX_NUMA_NODES)
+		int socket_id = rte_cryptodev_socket_id(cdev_id);
+
+		/* Use the first socket if SOCKET_ID_ANY is returned. */
+		if (socket_id == SOCKET_ID_ANY)
 			socket_id = 0;
 
 		rte_cryptodev_info_get(cdev_id, &cdev_info);
@@ -650,7 +649,11 @@ main(int argc, char **argv)
 
 		cdev_id = enabled_cdevs[cdev_index];
 
-		uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
+		int socket_id = rte_cryptodev_socket_id(cdev_id);
+
+		/* Use the first socket if SOCKET_ID_ANY is returned. */
+		if (socket_id == SOCKET_ID_ANY)
+			socket_id = 0;
 
 		ctx[i] = cperf_testmap[opts.test].constructor(
 				session_pool_socket[socket_id].sess_mp,
Signature · 1 line
2.25.1
Acked-by on v2 1/1 Applied
#4 lore raw
Quoted 6 lines

Due to recent changes to the default device socket ID, before being used as an index for session mempool list, the socket ID should be set to 0 if unknown (-1).

Fixes 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by

default")

Quoted 8 lines
Fixes 64c469b9e7d8 ("app/crypto-perf: check range of socket id")

---

Applied to dpdk-next-crypto
Thanks.