DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] bitops: fix issue in parallel atomic tests
@ 2024-10-13 11:57 Mattias Rönnblom
  2024-10-13 13:37 ` Morten Brørup
  2024-10-14 14:14 ` David Marchand
  0 siblings, 2 replies; 7+ messages in thread
From: Mattias Rönnblom @ 2024-10-13 11:57 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, hofors, Morten Brørup, Luka Jankovic, Thomas Monjalon,
	Mattias Rönnblom

The macros generating the parallel test for atomic test-and-
[set|clear|flip] functions used a 64-bit reference word when assuring
no neighbouring bits were modified, even when generating code for the
32-bit version of the test.

This issue causes spurious test failures on GCC 12.2.0 (the default
compiler on for example Debian 12 "bookworm"), when optimization level
2 or higher are used.

The test failures do not occur with GCC 11, 12.3 and 13.2.

To the author, this looks like a promotion-related compiler bug in GCC
12.2.

Fixes: 35326b61aecb ("bitops: add atomic bit operations in new API")

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 app/test/test_bitops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test/test_bitops.c b/app/test/test_bitops.c
index 4200073ae4..681e984037 100644
--- a/app/test/test_bitops.c
+++ b/app/test/test_bitops.c
@@ -227,7 +227,7 @@ test_bit_atomic_parallel_test_and_modify ## size(void) \
 	bool expected_value = total_flips % 2; \
 	TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \
 		"After %"PRId64" flips, the bit value should be %d", total_flips, expected_value); \
-	uint64_t expected_word = 0; \
+	uint ## size ## _t expected_word = 0; \
 	rte_bit_assign(&expected_word, bit, expected_value); \
 	TEST_ASSERT(expected_word == word, "Untouched bits have changed value"); \
 	return TEST_SUCCESS; \
@@ -275,7 +275,7 @@ test_bit_atomic_parallel_flip ## size(void) \
 	bool expected_value = total_flips % 2; \
 	TEST_ASSERT(expected_value == rte_bit_test(&word, bit), \
 		"After %"PRId64" flips, the bit value should be %d", total_flips, expected_value); \
-	uint64_t expected_word = 0; \
+	uint ## size ## _t expected_word = 0; \
 	rte_bit_assign(&expected_word, bit, expected_value); \
 	TEST_ASSERT(expected_word == word, "Untouched bits have changed value"); \
 	return TEST_SUCCESS; \
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-14 14:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-13 11:57 [PATCH] bitops: fix issue in parallel atomic tests Mattias Rönnblom
2024-10-13 13:37 ` Morten Brørup
2024-10-13 15:19   ` Mattias Rönnblom
2024-10-13 15:36     ` Morten Brørup
2024-10-14 14:16       ` David Marchand
2024-10-14 14:33         ` Mattias Rönnblom
2024-10-14 14:14 ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).