rcu_segcblist.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * RCU segmented callback lists
  4. *
  5. * This seemingly RCU-private file must be available to SRCU users
  6. * because the size of the TREE SRCU srcu_struct structure depends
  7. * on these definitions.
  8. *
  9. * Copyright IBM Corporation, 2017
  10. *
  11. * Authors: Paul E. McKenney <paulmck@linux.net.ibm.com>
  12. */
  13. #ifndef __INCLUDE_LINUX_RCU_SEGCBLIST_H
  14. #define __INCLUDE_LINUX_RCU_SEGCBLIST_H
  15. #include <linux/types.h>
  16. #include <linux/atomic.h>
  17. /* Simple unsegmented callback lists. */
  18. struct rcu_cblist {
  19. struct rcu_head *head;
  20. struct rcu_head **tail;
  21. long len;
  22. };
  23. #define RCU_CBLIST_INITIALIZER(n) { .head = NULL, .tail = &n.head }
  24. /* Complicated segmented callback lists. ;-) */
  25. /*
  26. * Index values for segments in rcu_segcblist structure.
  27. *
  28. * The segments are as follows:
  29. *
  30. * [head, *tails[RCU_DONE_TAIL]):
  31. * Callbacks whose grace period has elapsed, and thus can be invoked.
  32. * [*tails[RCU_DONE_TAIL], *tails[RCU_WAIT_TAIL]):
  33. * Callbacks waiting for the current GP from the current CPU's viewpoint.
  34. * [*tails[RCU_WAIT_TAIL], *tails[RCU_NEXT_READY_TAIL]):
  35. * Callbacks that arrived before the next GP started, again from
  36. * the current CPU's viewpoint. These can be handled by the next GP.
  37. * [*tails[RCU_NEXT_READY_TAIL], *tails[RCU_NEXT_TAIL]):
  38. * Callbacks that might have arrived after the next GP started.
  39. * There is some uncertainty as to when a given GP starts and
  40. * ends, but a CPU knows the exact times if it is the one starting
  41. * or ending the GP. Other CPUs know that the previous GP ends
  42. * before the next one starts.
  43. *
  44. * Note that RCU_WAIT_TAIL cannot be empty unless RCU_NEXT_READY_TAIL is also
  45. * empty.
  46. *
  47. * The ->gp_seq[] array contains the grace-period number at which the
  48. * corresponding segment of callbacks will be ready to invoke. A given
  49. * element of this array is meaningful only when the corresponding segment
  50. * is non-empty, and it is never valid for RCU_DONE_TAIL (whose callbacks
  51. * are already ready to invoke) or for RCU_NEXT_TAIL (whose callbacks have
  52. * not yet been assigned a grace-period number).
  53. */
  54. #define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */
  55. #define RCU_WAIT_TAIL 1 /* Also RCU_NEXT_READY head. */
  56. #define RCU_NEXT_READY_TAIL 2 /* Also RCU_NEXT head. */
  57. #define RCU_NEXT_TAIL 3
  58. #define RCU_CBLIST_NSEGS 4
  59. struct rcu_segcblist {
  60. struct rcu_head *head;
  61. struct rcu_head **tails[RCU_CBLIST_NSEGS];
  62. unsigned long gp_seq[RCU_CBLIST_NSEGS];
  63. #ifdef CONFIG_RCU_NOCB_CPU
  64. atomic_long_t len;
  65. #else
  66. long len;
  67. #endif
  68. u8 enabled;
  69. u8 offloaded;
  70. };
  71. #define RCU_SEGCBLIST_INITIALIZER(n) \
  72. { \
  73. .head = NULL, \
  74. .tails[RCU_DONE_TAIL] = &n.head, \
  75. .tails[RCU_WAIT_TAIL] = &n.head, \
  76. .tails[RCU_NEXT_READY_TAIL] = &n.head, \
  77. .tails[RCU_NEXT_TAIL] = &n.head, \
  78. }
  79. #endif /* __INCLUDE_LINUX_RCU_SEGCBLIST_H */