[v2] app/crypto-perf-test: fix unset crc algorithm

Message ID 20240315104434.2531-1-arkadiuszx.kusztal@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series [v2] app/crypto-perf-test: fix unset crc algorithm |

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/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Arkadiusz Kusztal March 15, 2024, 10:44 a.m. UTC
  Because net crc api is not thread-safe, setting crc algorithm
by the application will prevent race condition in the calc function.
Race condition still may occur when any of the threads will call this
function again. Function is called with the highest possible SIMD
extension, which is AVX512, but if this is not found, CRC API will
pick the other highest possible extension, or scalar if no SIMD
available.

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
v2:
- narrowed down the case to the docsis only

 app/test-crypto-perf/main.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Power, Ciara March 15, 2024, 10:49 a.m. UTC | #1
> -----Original Message-----
> From: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Sent: Friday, March 15, 2024 10:45 AM
> To: dev@dpdk.org
> Cc: gakhil@marvell.com; Power, Ciara <ciara.power@intel.com>; Kusztal,
> ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Subject: [PATCH v2] app/crypto-perf-test: fix unset crc algorithm
> 
> Because net crc api is not thread-safe, setting crc algorithm by the application
> will prevent race condition in the calc function.
> Race condition still may occur when any of the threads will call this function
> again. Function is called with the highest possible SIMD extension, which is
> AVX512, but if this is not found, CRC API will pick the other highest possible
> extension, or scalar if no SIMD available.
> 
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
> v2:
> - narrowed down the case to the docsis only
> 
>  app/test-crypto-perf/main.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
Acked-by: Ciara Power <ciara.power@intel.com>
  

Patch

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 40c0b4b54f..1b23dd5fb2 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -11,6 +11,7 @@ 
 #include <rte_eal.h>
 #include <rte_errno.h>
 #include <rte_cryptodev.h>
+#include <rte_net_crc.h>
 #ifdef RTE_CRYPTO_SCHEDULER
 #include <rte_cryptodev_scheduler.h>
 #endif
@@ -599,6 +600,9 @@  main(int argc, char **argv)
 		goto err;
 	}
 
+	if (opts.op_type == CPERF_DOCSIS)
+		rte_net_crc_set_alg(RTE_NET_CRC_AVX512);
+
 	ret = cperf_verify_devices_capabilities(&opts, enabled_cdevs,
 			nb_cryptodevs);
 	if (ret) {