Ingo Molnar | f9411eb | 2017-02-06 09:50:49 +0100 | [diff] [blame] | 1 | #ifndef _LINUX_SCHED_RCUPDATE_WAIT_H |
| 2 | #define _LINUX_SCHED_RCUPDATE_WAIT_H |
| 3 | |
| 4 | /* |
| 5 | * RCU synchronization types and methods: |
| 6 | */ |
| 7 | |
| 8 | #include <linux/rcupdate.h> |
| 9 | #include <linux/completion.h> |
| 10 | |
| 11 | /* |
| 12 | * Structure allowing asynchronous waiting on RCU. |
| 13 | */ |
| 14 | struct rcu_synchronize { |
| 15 | struct rcu_head head; |
| 16 | struct completion completion; |
| 17 | }; |
| 18 | void wakeme_after_rcu(struct rcu_head *head); |
| 19 | |
| 20 | void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array, |
| 21 | struct rcu_synchronize *rs_array); |
| 22 | |
| 23 | #define _wait_rcu_gp(checktiny, ...) \ |
| 24 | do { \ |
| 25 | call_rcu_func_t __crcu_array[] = { __VA_ARGS__ }; \ |
| 26 | struct rcu_synchronize __rs_array[ARRAY_SIZE(__crcu_array)]; \ |
| 27 | __wait_rcu_gp(checktiny, ARRAY_SIZE(__crcu_array), \ |
| 28 | __crcu_array, __rs_array); \ |
| 29 | } while (0) |
| 30 | |
| 31 | #define wait_rcu_gp(...) _wait_rcu_gp(false, __VA_ARGS__) |
| 32 | |
| 33 | /** |
| 34 | * synchronize_rcu_mult - Wait concurrently for multiple grace periods |
| 35 | * @...: List of call_rcu() functions for the flavors to wait on. |
| 36 | * |
| 37 | * This macro waits concurrently for multiple flavors of RCU grace periods. |
| 38 | * For example, synchronize_rcu_mult(call_rcu, call_rcu_bh) would wait |
| 39 | * on concurrent RCU and RCU-bh grace periods. Waiting on a give SRCU |
| 40 | * domain requires you to write a wrapper function for that SRCU domain's |
| 41 | * call_srcu() function, supplying the corresponding srcu_struct. |
| 42 | * |
| 43 | * If Tiny RCU, tell _wait_rcu_gp() not to bother waiting for RCU |
| 44 | * or RCU-bh, given that anywhere synchronize_rcu_mult() can be called |
| 45 | * is automatically a grace period. |
| 46 | */ |
| 47 | #define synchronize_rcu_mult(...) \ |
| 48 | _wait_rcu_gp(IS_ENABLED(CONFIG_TINY_RCU), __VA_ARGS__) |
| 49 | |
| 50 | #endif /* _LINUX_SCHED_RCUPDATE_WAIT_H */ |