From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v3 01/14] test: add pause to synchronization spinloops
Date: Wed, 21 Jan 2026 16:50:17 -0800 [thread overview]
Message-ID: <20260122005356.1168221-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20260122005356.1168221-1-stephen@networkplumber.org>
The atomic and thread tests use tight spinloops to synchronize.
These spinloops lack rte_pause() which causes problems on high core
count systems, particularly AMD Zen architectures where:
- Tight spinloops without pause can starve SMT sibling threads
- Memory ordering and store-buffer forwarding behave differently
- Higher core counts amplify timing windows for race conditions
This manifests as sporadic test failures on systems with 32+ cores
that don't reproduce on smaller core count systems.
Add rte_pause() to all seven synchronization spinloops to allow
proper CPU resource sharing and improve memory ordering behavior.
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test/test_atomic.c | 15 ++++++++-------
app/test/test_threads.c | 17 +++++++++--------
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/app/test/test_atomic.c b/app/test/test_atomic.c
index 8160a33e0e..b1a0d40ece 100644
--- a/app/test/test_atomic.c
+++ b/app/test/test_atomic.c
@@ -15,6 +15,7 @@
#include <rte_atomic.h>
#include <rte_eal.h>
#include <rte_lcore.h>
+#include <rte_pause.h>
#include <rte_random.h>
#include <rte_hash_crc.h>
@@ -114,7 +115,7 @@ test_atomic_usual(__rte_unused void *arg)
unsigned i;
while (rte_atomic32_read(&synchro) == 0)
- ;
+ rte_pause();
for (i = 0; i < N; i++)
rte_atomic16_inc(&a16);
@@ -150,7 +151,7 @@ static int
test_atomic_tas(__rte_unused void *arg)
{
while (rte_atomic32_read(&synchro) == 0)
- ;
+ rte_pause();
if (rte_atomic16_test_and_set(&a16))
rte_atomic64_inc(&count);
@@ -171,7 +172,7 @@ test_atomic_addsub_and_return(__rte_unused void *arg)
unsigned i;
while (rte_atomic32_read(&synchro) == 0)
- ;
+ rte_pause();
for (i = 0; i < N; i++) {
tmp16 = rte_atomic16_add_return(&a16, 1);
@@ -210,7 +211,7 @@ static int
test_atomic_inc_and_test(__rte_unused void *arg)
{
while (rte_atomic32_read(&synchro) == 0)
- ;
+ rte_pause();
if (rte_atomic16_inc_and_test(&a16)) {
rte_atomic64_inc(&count);
@@ -237,7 +238,7 @@ static int
test_atomic_dec_and_test(__rte_unused void *arg)
{
while (rte_atomic32_read(&synchro) == 0)
- ;
+ rte_pause();
if (rte_atomic16_dec_and_test(&a16))
rte_atomic64_inc(&count);
@@ -269,7 +270,7 @@ test_atomic128_cmp_exchange(__rte_unused void *arg)
unsigned int i;
while (rte_atomic32_read(&synchro) == 0)
- ;
+ rte_pause();
expected = count128;
@@ -407,7 +408,7 @@ test_atomic_exchange(__rte_unused void *arg)
/* Wait until all of the other threads have been dispatched */
while (rte_atomic32_read(&synchro) == 0)
- ;
+ rte_pause();
/*
* Let the battle begin! Every thread attempts to steal the current
diff --git a/app/test/test_threads.c b/app/test/test_threads.c
index 5cd8bd4559..e2700b4a92 100644
--- a/app/test/test_threads.c
+++ b/app/test/test_threads.c
@@ -7,6 +7,7 @@
#include <rte_thread.h>
#include <rte_debug.h>
#include <rte_stdatomic.h>
+#include <rte_pause.h>
#include "test.h"
@@ -23,7 +24,7 @@ thread_main(void *arg)
rte_atomic_store_explicit(&thread_id_ready, 1, rte_memory_order_release);
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 1)
- ;
+ rte_pause();
return 0;
}
@@ -39,7 +40,7 @@ test_thread_create_join(void)
"Failed to create thread.");
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
- ;
+ rte_pause();
RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0,
"Unexpected thread id.");
@@ -63,7 +64,7 @@ test_thread_create_detach(void)
&thread_main_id) == 0, "Failed to create thread.");
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
- ;
+ rte_pause();
RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0,
"Unexpected thread id.");
@@ -87,7 +88,7 @@ test_thread_priority(void)
"Failed to create thread");
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
- ;
+ rte_pause();
priority = RTE_THREAD_PRIORITY_NORMAL;
RTE_TEST_ASSERT(rte_thread_set_priority(thread_id, priority) == 0,
@@ -139,7 +140,7 @@ test_thread_affinity(void)
"Failed to create thread");
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
- ;
+ rte_pause();
RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset0) == 0,
"Failed to get thread affinity");
@@ -192,7 +193,7 @@ test_thread_attributes_affinity(void)
"Failed to create attributes affinity thread.");
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
- ;
+ rte_pause();
RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset1) == 0,
"Failed to get attributes thread affinity");
@@ -221,7 +222,7 @@ test_thread_attributes_priority(void)
"Failed to create attributes priority thread.");
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
- ;
+ rte_pause();
RTE_TEST_ASSERT(rte_thread_get_priority(thread_id, &priority) == 0,
"Failed to get thread priority");
@@ -245,7 +246,7 @@ test_thread_control_create_join(void)
"Failed to create thread.");
while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
- ;
+ rte_pause();
RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0,
"Unexpected thread id.");
--
2.51.0
next prev parent reply other threads:[~2026-01-22 0:54 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-18 20:09 [PATCH 0/6] test: fix sporadic failures on high core count systems Stephen Hemminger
2026-01-18 20:09 ` [PATCH 1/6] test: add pause to synchronization spinloops Stephen Hemminger
2026-01-18 20:09 ` [PATCH 2/6] test: fix timeout for atomic test on high core count systems Stephen Hemminger
2026-01-18 20:09 ` [PATCH 3/6] test: fix race condition in ELF load tests Stephen Hemminger
2026-01-19 11:42 ` Marat Khalili
2026-01-20 0:03 ` Stephen Hemminger
2026-01-20 10:30 ` Marat Khalili
2026-01-19 18:24 ` Stephen Hemminger
2026-01-18 20:09 ` [PATCH 4/6] test: fix unsupported BPF instructions in elf load test Stephen Hemminger
2026-01-19 11:43 ` Marat Khalili
2026-01-18 20:09 ` [PATCH 5/6] test: add file-prefix for all fast-tests on Linux Stephen Hemminger
2026-01-19 13:06 ` Marat Khalili
2026-01-19 14:01 ` Bruce Richardson
2026-01-18 20:09 ` [PATCH 6/6] test: fix trace_autotest_with_traces parallel execution Stephen Hemminger
2026-01-19 13:13 ` Marat Khalili
2026-01-20 0:07 ` Stephen Hemminger
2026-01-20 11:36 ` Marat Khalili
2026-01-22 0:50 ` [PATCH v3 00/14] test: fix test failures on high cores Stephen Hemminger
2026-01-22 0:50 ` Stephen Hemminger [this message]
2026-01-22 0:50 ` [PATCH v3 02/14] test: scale atomic test based on core count Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 03/14] test/mcslock: scale test based on number of cores Stephen Hemminger
2026-01-22 10:41 ` Konstantin Ananyev
2026-01-27 20:31 ` Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 04/14] test/stack: " Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 05/14] test/timer: " Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 06/14] test/bpf: fix error handling in ELF load tests Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 07/14] test/bpf: fix unsupported BPF instructions in ELF load test Stephen Hemminger
2026-01-22 10:33 ` Konstantin Ananyev
2026-01-22 0:50 ` [PATCH v3 08/14] test/bpf: skip ELF test if null PMD disabled Stephen Hemminger
2026-01-23 11:56 ` Marat Khalili
2026-01-22 0:50 ` [PATCH v3 09/14] test: add file-prefix for all fast-tests on Linux Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 10/14] test: fix trace_autotest_with_traces parallel execution Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 11/14] test/eventdev: skip test if eventdev driver disabled Stephen Hemminger
2026-01-22 20:40 ` Stephen Hemminger
2026-01-23 9:06 ` Bruce Richardson
2026-01-22 0:50 ` [PATCH v3 12/14] test/pcapng: skip test if null driver missing Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 13/14] test/vdev: skip test if no null PMD Stephen Hemminger
2026-01-22 0:50 ` [PATCH v3 14/14] test/bpf: pass correct size for Rx/Tx load tests Stephen Hemminger
2026-01-23 11:50 ` Marat Khalili
2026-03-05 16:39 ` [PATCH v3 00/14] test: fix test failures on high cores David Marchand
2026-03-05 17:50 ` [PATCH v4 00/11] test: fix test failures on high core count systems Stephen Hemminger
2026-03-05 17:50 ` [PATCH v4 01/11] test: add pause to synchronization spinloops Stephen Hemminger
2026-03-05 17:50 ` [PATCH v4 02/11] test/atomic: scale test based on core count Stephen Hemminger
2026-03-05 17:50 ` [PATCH v4 03/11] test/mcslock: scale test based on number of cores Stephen Hemminger
2026-03-05 17:50 ` [PATCH v4 04/11] test/stack: " Stephen Hemminger
2026-03-05 17:50 ` [PATCH v4 05/11] test/timer: " Stephen Hemminger
2026-03-05 17:51 ` [PATCH v4 06/11] test/timer: replace volatile with C11 atomics Stephen Hemminger
2026-03-05 17:51 ` [PATCH v4 07/11] test: add file-prefix for all fast-tests on Linux Stephen Hemminger
2026-03-05 17:51 ` [PATCH v4 08/11] test: fix trace_autotest_with_traces parallel execution Stephen Hemminger
2026-03-05 17:51 ` [PATCH v4 09/11] test/bpf: fix error handling in ELF load tests Stephen Hemminger
2026-03-05 17:51 ` [PATCH v4 10/11] test/bpf: fix unsupported BPF instructions in ELF load test Stephen Hemminger
2026-03-05 17:51 ` [PATCH v4 11/11] test/bpf: pass correct size for Rx/Tx load tests Stephen Hemminger
2026-03-17 13:28 ` [PATCH v4 00/11] test: fix test failures on high core count systems Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260122005356.1168221-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox