Skip to contentSkip to conversation

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

PATCH Superseded David Christensen 3 participants 5 messages Sep 2, 2021 – Oct 14, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 app/test/test_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_atomic.c +1 -1
index f10f555af8..ce0c259bd7 100644
@@ -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;
 	}
Signature · 1 line
2.27.0
Tested-by Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of David Christensen
Sent: Friday, September 3, 2021 1:41 AM
To: [email protected]
Cc: Phil Yang <[email protected]>; [email protected]; David Christensen <[email protected]>
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.

Quoted 3 lines
Fixes fa3253c534b1 ("test/atomic: add 128-bit atomic compare exchange

test")
Cc: [email protected]

This mail address is unreachable.

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

Quoted 21 lines
---
 app/test/test_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_atomic.c index renamed from app/test/test_atomic.c +0 -0

f10f555af8..ce0c259bd7 100644

app/test/test_atomic.c +1 -2
@@ -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

#2 lore raw

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

In reply to David Christensen

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 mismatch 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")

---
v2:
- Fixed commit message spelling error

---
 app/test/test_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_atomic.c +1 -1
index f10f555af8..ce0c259bd7 100644
@@ -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

#3 lore raw

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

In reply to David Christensen

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 mismatch 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")

---
v2:
- Fixed commit message spelling error

---
 app/test/test_atomic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_atomic.c +1 -1
index f10f555af8..ce0c259bd7 100644
@@ -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

#4 lore raw
Quoted 7 lines · David Christensen

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 mismatch can cause a false test failure. Modify the comparison to compare uint64_t values.

Quoted 5 lines
Fixes fa3253c534b1 ("test/atomic: add 128-bit atomic compare exchange test")

Applied, thanks.

Signature · 1 line
David Marchand