tests/regression/rcutorture: Add wait state
authorOlivier Dion <odion@efficios.com>
Fri, 14 Jul 2023 16:59:23 +0000 (12:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 14 Jul 2023 17:21:54 +0000 (13:21 -0400)
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 <odion@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/regression/rcutorture.h

index bc394f9f8a048f9ba51575e3d9a1ac4952cf6bdb..fbb22f8727d3c252145a5883482dd30e0d83934a 100644 (file)
@@ -348,6 +348,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)))
@@ -368,6 +369,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;
@@ -449,8 +451,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",
This page took 0.026608 seconds and 4 git commands to generate.