test/atomic: fix false failures for 128-bit atomic compare exchange test

Message ID 20210902174104.3181444-1-drc@linux.vnet.ibm.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series test/atomic: fix false failures for 128-bit atomic compare exchange test |

Checks

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

Commit Message

David Christensen Sept. 2, 2021, 5:41 p.m. UTC
  When checking the results of the rte_atomic128_cmp_exchange() function,
current code compares the values of a uint32_t and a uint64_t variable.
If the number of lcores used by the test is large, or the value of the
iteration count N is increased, the variable size mimatch can cause a
false test failure.  Modify the comparison to compare uint64_t values.

Fixes: fa3253c534b1 ("test/atomic: add 128-bit atomic compare exchange test")
Cc: phil.yang@arm.com

Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
---
 app/test/test_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ruifeng Wang Sept. 3, 2021, 6:59 a.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of David Christensen
> Sent: Friday, September 3, 2021 1:41 AM
> To: dev@dpdk.org
> Cc: Phil Yang <Phil.Yang@arm.com>; stable@dpdk.org; David Christensen
> <drc@linux.vnet.ibm.com>
> Subject: [dpdk-dev] [PATCH] test/atomic: fix false failures for 128-bit atomic
> compare exchange test
> 
> When checking the results of the rte_atomic128_cmp_exchange() function,
> current code compares the values of a uint32_t and a uint64_t variable.
> If the number of lcores used by the test is large, or the value of the iteration
> count N is increased, the variable size mimatch can cause a false test failure.
> Modify the comparison to compare uint64_t values.
> 
> Fixes: fa3253c534b1 ("test/atomic: add 128-bit atomic compare exchange
> test")
> Cc: phil.yang@arm.com

This mail address is unreachable. 

I reproduced the issue on a 160-core aarch64 machine with increased N.

Tested-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> 
> Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
> ---
>  app/test/test_atomic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test/test_atomic.c b/app/test/test_atomic.c index
> f10f555af8..ce0c259bd7 100644
> --- a/app/test/test_atomic.c
> +++ b/app/test/test_atomic.c
> @@ -591,7 +591,7 @@ test_atomic(void)
>  	rte_atomic32_clear(&synchro);
> 
>  	iterations = count128.val[0] - count128.val[1];
> -	if (iterations != 4*N*(rte_lcore_count()-1)) {
> +	if (iterations != (uint64_t)4*N*(rte_lcore_count()-1)) {
>  		printf("128-bit compare and swap failed\n");
>  		return -1;
>  	}
> --
> 2.27.0
  

Patch

diff --git a/app/test/test_atomic.c b/app/test/test_atomic.c
index f10f555af8..ce0c259bd7 100644
--- a/app/test/test_atomic.c
+++ b/app/test/test_atomic.c
@@ -591,7 +591,7 @@  test_atomic(void)
 	rte_atomic32_clear(&synchro);
 
 	iterations = count128.val[0] - count128.val[1];
-	if (iterations != 4*N*(rte_lcore_count()-1)) {
+	if (iterations != (uint64_t)4*N*(rte_lcore_count()-1)) {
 		printf("128-bit compare and swap failed\n");
 		return -1;
 	}