summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeng He <hepeng.0320@bytedance.com>2022-05-26 02:47:45 +0000
committerIlya Maximets <i.maximets@ovn.org>2022-05-30 23:34:39 +0200
commitc67941e974da243795806e9ad478d49a2f1aa793 (patch)
tree9fb56f1a97e27d54b4bdddcdaad6a278b4fbd76e /tests
parentba462b358929e249448254d92e9058c6b4f3de61 (diff)
downloadopenvswitch-c67941e974da243795806e9ad478d49a2f1aa793.tar.gz
ovs-rcu: Add ovsrcu_barrier.
ovsrcu_barrier will block the current thread until all the postponed rcu job has been finished. it's like a OVS version of the Linux kernel rcu_barrier(). Signed-off-by: Peng He <hepeng.0320@bytedance.com> Co-authored-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: David Marchand <david.marchand@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/library.at2
-rw-r--r--tests/test-rcu.c29
2 files changed, 28 insertions, 3 deletions
diff --git a/tests/library.at b/tests/library.at
index ab56f3672..e60d7707b 100644
--- a/tests/library.at
+++ b/tests/library.at
@@ -252,7 +252,7 @@ AT_CHECK([ovstest test-barrier], [0], [])
AT_CLEANUP
AT_SETUP([rcu])
-AT_CHECK([ovstest test-rcu-quiesce], [0], [])
+AT_CHECK([ovstest test-rcu], [0], [])
AT_CLEANUP
AT_SETUP([stopwatch module])
diff --git a/tests/test-rcu.c b/tests/test-rcu.c
index 965f3c49f..bb17092bf 100644
--- a/tests/test-rcu.c
+++ b/tests/test-rcu.c
@@ -35,7 +35,7 @@ quiescer_main(void *aux OVS_UNUSED)
}
static void
-test_rcu_quiesce(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+test_rcu_quiesce(void)
{
pthread_t quiescer;
@@ -48,4 +48,29 @@ test_rcu_quiesce(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
xpthread_join(quiescer, NULL);
}
-OVSTEST_REGISTER("test-rcu-quiesce", test_rcu_quiesce);
+static void
+add_count(void *_count)
+{
+ unsigned *count = (unsigned *)_count;
+ (*count) ++;
+}
+
+static void
+test_rcu_barrier(void)
+{
+ unsigned count = 0;
+ for (int i = 0; i < 10; i ++) {
+ ovsrcu_postpone(add_count, &count);
+ }
+
+ ovsrcu_barrier();
+ ovs_assert(count == 10);
+}
+
+static void
+test_rcu(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) {
+ test_rcu_quiesce();
+ test_rcu_barrier();
+}
+
+OVSTEST_REGISTER("test-rcu", test_rcu);