app/crypto-perf: fix socket ID default value
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).
--- app/test-crypto-perf/main.c | 5 +++++ 1 file changed, 5 insertions(+)
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 ; ctx[i] = cperf_testmap[opts.test].constructor( session_pool_socket[socket_id].sess_mp,
Signature · 1 line
2.25.1
________________________________
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).
--- app/test-crypto-perf/main.c | 5 +++++ 1 file changed, 5 insertions(+)
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 ; ctx[i] = cperf_testmap[opts.test].constructor( session_pool_socket[socket_id].sess_mp,
--
2.25.1
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 bydefault")
Cc: [email protected]
Cc: [email protected]Signed-off-by Ciara Power <[email protected]>--- app/test-crypto-perf/main.c | 5 +++++ 1 file changed, 5 insertions(+)app/test-crypto-perf/main.c +0
-0
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.
PATCH v2 1/1 app/crypto-perf: fix socket ID default value
In reply to Ciara PowerDue 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).
---
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
@@ -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
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 bydefault")
Quoted 8 lines
Fixes 64c469b9e7d8 ("app/crypto-perf: check range of socket id")Signed-off-by Ciara Power <[email protected]>Acked-by Kai Ji <[email protected]>---
Applied to dpdk-next-crypto
Thanks.