app/crypto-perf: fix socket ID default value

Message ID 20230705103047.1127985-1-ciara.power@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series app/crypto-perf: fix socket ID default value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Power, Ciara July 5, 2023, 10:30 a.m. UTC
  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: olivier.matz@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 app/test-crypto-perf/main.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Ji, Kai July 5, 2023, 1:08 p.m. UTC | #1
Acked-by: Kai Ji <kai.ji@intel.com<mailto:kai.ji@intel.com>>
  
Akhil Goyal July 5, 2023, 6:07 p.m. UTC | #2
> 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: olivier.matz@6wind.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> ---
>  app/test-crypto-perf/main.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
> index af5bd0d23b..b74e7ba118 100644
> --- a/app/test-crypto-perf/main.c
> +++ b/app/test-crypto-perf/main.c
> @@ -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

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index af5bd0d23b..b74e7ba118 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -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,