From e8e114e5256e32002d7fe686d87dc364bc632802 Mon Sep 17 00:00:00 2001 From: Olivier Dion Date: Fri, 14 Jul 2023 12:59:23 -0400 Subject: [PATCH] tests/regression/rcutorture: Add wait state pthread_cond_wait(3) can have spurious wakeups. Fix this by polling a state associated with the the wait. Change-Id: Iba034cba5f72ad88388d1b90a6093f4ae9f9beb9 Signed-off-by: Olivier Dion Signed-off-by: Mathieu Desnoyers --- tests/regression/rcutorture.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/regression/rcutorture.h b/tests/regression/rcutorture.h index c4455a0..1d4d05e 100644 --- a/tests/regression/rcutorture.h +++ b/tests/regression/rcutorture.h @@ -342,6 +342,7 @@ void *rcu_read_stress_test(void *arg __attribute__((unused))) static pthread_mutex_t call_rcu_test_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t call_rcu_test_cond = PTHREAD_COND_INITIALIZER; +static bool call_rcu_wait; static void rcu_update_stress_test_rcu(struct rcu_head *head __attribute__((unused))) @@ -362,6 +363,7 @@ void rcu_update_stress_test_rcu(struct rcu_head *head __attribute__((unused))) strerror(errno)); abort(); } + call_rcu_wait = false; ret = pthread_mutex_unlock(&call_rcu_test_mutex); if (ret) { errno = ret; @@ -423,8 +425,11 @@ void *rcu_update_stress_test(void *arg __attribute__((unused))) * immediately after call_rcu (call_rcu needs * us to be registered RCU readers). */ - ret = pthread_cond_wait(&call_rcu_test_cond, - &call_rcu_test_mutex); + call_rcu_wait = true; + do { + ret = pthread_cond_wait(&call_rcu_test_cond, + &call_rcu_test_mutex); + } while (call_rcu_wait); if (ret) { errno = ret; diag("pthread_cond_signal: %s", -- 2.34.1