rcupdate_wait.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_SCHED_RCUPDATE_WAIT_H
  3. #define _LINUX_SCHED_RCUPDATE_WAIT_H
  4. /*
  5. * RCU synchronization types and methods:
  6. */
  7. #include <linux/rcupdate.h>
  8. #include <linux/completion.h>
  9. /*
  10. * Structure allowing asynchronous waiting on RCU.
  11. */
  12. struct rcu_synchronize {
  13. struct rcu_head head;
  14. struct completion completion;
  15. };
  16. void wakeme_after_rcu(struct rcu_head *head);
  17. void __wait_rcu_gp(bool checktiny, int n, call_rcu_func_t *crcu_array,
  18. struct rcu_synchronize *rs_array);
  19. #define _wait_rcu_gp(checktiny, ...) \
  20. do { \
  21. call_rcu_func_t __crcu_array[] = { __VA_ARGS__ }; \
  22. struct rcu_synchronize __rs_array[ARRAY_SIZE(__crcu_array)]; \
  23. __wait_rcu_gp(checktiny, ARRAY_SIZE(__crcu_array), \
  24. __crcu_array, __rs_array); \
  25. } while (0)
  26. #define wait_rcu_gp(...) _wait_rcu_gp(false, __VA_ARGS__)
  27. /**
  28. * synchronize_rcu_mult - Wait concurrently for multiple grace periods
  29. * @...: List of call_rcu() functions for different grace periods to wait on
  30. *
  31. * This macro waits concurrently for multiple types of RCU grace periods.
  32. * For example, synchronize_rcu_mult(call_rcu, call_rcu_tasks) would wait
  33. * on concurrent RCU and RCU-tasks grace periods. Waiting on a given SRCU
  34. * domain requires you to write a wrapper function for that SRCU domain's
  35. * call_srcu() function, with this wrapper supplying the pointer to the
  36. * corresponding srcu_struct.
  37. *
  38. * The first argument tells Tiny RCU's _wait_rcu_gp() not to
  39. * bother waiting for RCU. The reason for this is because anywhere
  40. * synchronize_rcu_mult() can be called is automatically already a full
  41. * grace period.
  42. */
  43. #define synchronize_rcu_mult(...) \
  44. _wait_rcu_gp(IS_ENABLED(CONFIG_TINY_RCU), __VA_ARGS__)
  45. #endif /* _LINUX_SCHED_RCUPDATE_WAIT_H */