diff mbox series

[ovs-dev,ovs-dev,v1,1/2] ovs-rcu: add rcu_barrier

Message ID 20220326024306.27661-1-hepeng.0320@bytedance.com
State Superseded
Headers show
Series [ovs-dev,ovs-dev,v1,1/2] ovs-rcu: add rcu_barrier | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Peng He March 26, 2022, 2:43 a.m. UTC
rcu_barrier will block the current thread until all the postponed
rcu job has been finished. it's like the OVS's version of
the kernel rcu_barrier()

Signed-off-by: Peng He <hepeng.0320@bytedance.com>
---
 lib/ovs-rcu.c | 31 +++++++++++++++++++++++++++++++
 lib/ovs-rcu.h |  4 ++++
 2 files changed, 35 insertions(+)

Comments

0-day Robot March 26, 2022, 3:58 a.m. UTC | #1
Bleep bloop.  Greetings Peng He, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author Peng He <xnhp0320@gmail.com> needs to sign off.
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Peng He <hepeng.0320@bytedance.com>
ERROR: Inappropriate spacing in pointer declaration
ERROR: Inappropriate spacing around cast
WARNING: Line lacks whitespace around operator
#28 FILE: lib/ovs-rcu.c:451:
    struct seq *seq = (struct seq*)seq_;

ERROR: Inappropriate spacing in pointer declaration
ERROR: Inappropriate spacing around cast
WARNING: Line lacks whitespace around operator
#42 FILE: lib/ovs-rcu.c:465:
    ovsrcu_postpone__(ovsrcu_barrier_func, (void*)seq);

Lines checked: 78, Warnings: 3, Errors: 5


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/lib/ovs-rcu.c b/lib/ovs-rcu.c
index 1866bd308..2bf6b6eae 100644
--- a/lib/ovs-rcu.c
+++ b/lib/ovs-rcu.c
@@ -444,3 +444,34 @@  ovsrcu_init_module(void)
         ovsthread_once_done(&once);
     }
 }
+
+static void
+ovsrcu_barrier_func(void *seq_)
+{
+    struct seq *seq = (struct seq*)seq_;
+    seq_change(seq);
+}
+
+bool
+ovsrcu_barrier(struct seq *seq, long long int timeout)
+{
+    /* first let all threads flush their cbset */
+    ovsrcu_synchronize();
+
+    /* then register a new cbset, ensure this cbset
+     * is at the tail of global listi
+     */
+    uint64_t seqno = seq_read(seq);
+    ovsrcu_postpone__(ovsrcu_barrier_func, (void*)seq);
+    long long int now = time_msec();
+    long long int deadline = now + timeout;
+
+    do {
+        seq_wait(seq, seqno);
+        poll_timer_wait_until(deadline);
+        poll_block();
+        now = time_msec(); /* update now */
+    } while (seqno == seq_read(seq) && now < deadline);
+
+    return !(seqno == seq_read(seq));
+}
diff --git a/lib/ovs-rcu.h b/lib/ovs-rcu.h
index ecc4c9201..c9c044e06 100644
--- a/lib/ovs-rcu.h
+++ b/lib/ovs-rcu.h
@@ -159,6 +159,7 @@ 
 
 #include "compiler.h"
 #include "ovs-atomic.h"
+#include "seq.h"
 
 #if __GNUC__
 #define OVSRCU_TYPE(TYPE) struct { ATOMIC(TYPE) p; }
@@ -310,4 +311,7 @@  void ovsrcu_synchronize(void);
 
 void ovsrcu_exit(void);
 
+bool ovsrcu_barrier(struct seq *seq, long long int timeout);
+
+
 #endif /* ovs-rcu.h */