diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-03-14 16:37:08 -0700 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-03-20 17:12:25 -0700 |
commit | 765a3f4fed708ae429ee095914a7897acb3a65bd (patch) | |
tree | 1a33b4e0e88cdebf60855f6c3b102819ed6986b0 /include/linux/rcutiny.h | |
parent | f5604f67fe8cbd6f2088b20b9463f721aa613d4b (diff) | |
download | blackbird-op-linux-765a3f4fed708ae429ee095914a7897acb3a65bd.tar.gz blackbird-op-linux-765a3f4fed708ae429ee095914a7897acb3a65bd.zip |
rcu: Provide grace-period piggybacking API
The following pattern is currently not well supported by RCU:
1. Make data element inaccessible to RCU readers.
2. Do work that probably lasts for more than one grace period.
3. Do something to make sure RCU readers in flight before #1 above
have completed.
Here are some things that could currently be done:
a. Do a synchronize_rcu() unconditionally at either #1 or #3 above.
This works, but imposes needless work and latency.
b. Post an RCU callback at #1 above that does a wakeup, then
wait for the wakeup at #3. This works well, but likely results
in an extra unneeded grace period. Open-coding this is also
a bit more semi-tricky code than would be good.
This commit therefore adds get_state_synchronize_rcu() and
cond_synchronize_rcu() APIs. Call get_state_synchronize_rcu() at #1
above and pass its return value to cond_synchronize_rcu() at #3 above.
This results in a call to synchronize_rcu() if no grace period has
elapsed between #1 and #3, but requires only a load, comparison, and
memory barrier if a full grace period did elapse.
Requested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Diffstat (limited to 'include/linux/rcutiny.h')
-rw-r--r-- | include/linux/rcutiny.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h index e8cb6e3b52a7..425c659d54e5 100644 --- a/include/linux/rcutiny.h +++ b/include/linux/rcutiny.h @@ -27,6 +27,16 @@ #include <linux/cache.h> +static inline unsigned long get_state_synchronize_rcu(void) +{ + return 0; +} + +static inline void cond_synchronize_rcu(unsigned long oldstate) +{ + might_sleep(); +} + static inline void rcu_barrier_bh(void) { wait_rcu_gp(call_rcu_bh); |