rcutree.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Read-Copy Update mechanism for mutual exclusion (tree-based version)
  4. *
  5. * Copyright IBM Corporation, 2008
  6. *
  7. * Author: Dipankar Sarma <[email protected]>
  8. * Paul E. McKenney <[email protected]> Hierarchical algorithm
  9. *
  10. * Based on the original work by Paul McKenney <[email protected]>
  11. * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
  12. *
  13. * For detailed explanation of Read-Copy Update mechanism see -
  14. * Documentation/RCU
  15. */
  16. #ifndef __LINUX_RCUTREE_H
  17. #define __LINUX_RCUTREE_H
  18. void rcu_softirq_qs(void);
  19. void rcu_note_context_switch(bool preempt);
  20. int rcu_needs_cpu(void);
  21. void rcu_cpu_stall_reset(void);
  22. /*
  23. * Note a virtualization-based context switch. This is simply a
  24. * wrapper around rcu_note_context_switch(), which allows TINY_RCU
  25. * to save a few bytes. The caller must have disabled interrupts.
  26. */
  27. static inline void rcu_virt_note_context_switch(int cpu)
  28. {
  29. rcu_note_context_switch(false);
  30. }
  31. void synchronize_rcu_expedited(void);
  32. void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func);
  33. void rcu_barrier(void);
  34. bool rcu_eqs_special_set(int cpu);
  35. void rcu_momentary_dyntick_idle(void);
  36. void kfree_rcu_scheduler_running(void);
  37. bool rcu_gp_might_be_stalled(void);
  38. struct rcu_gp_oldstate {
  39. unsigned long rgos_norm;
  40. unsigned long rgos_exp;
  41. };
  42. // Maximum number of rcu_gp_oldstate values corresponding to
  43. // not-yet-completed RCU grace periods.
  44. #define NUM_ACTIVE_RCU_POLL_FULL_OLDSTATE 4
  45. /**
  46. * same_state_synchronize_rcu_full - Are two old-state values identical?
  47. * @rgosp1: First old-state value.
  48. * @rgosp2: Second old-state value.
  49. *
  50. * The two old-state values must have been obtained from either
  51. * get_state_synchronize_rcu_full(), start_poll_synchronize_rcu_full(),
  52. * or get_completed_synchronize_rcu_full(). Returns @true if the two
  53. * values are identical and @false otherwise. This allows structures
  54. * whose lifetimes are tracked by old-state values to push these values
  55. * to a list header, allowing those structures to be slightly smaller.
  56. *
  57. * Note that equality is judged on a bitwise basis, so that an
  58. * @rcu_gp_oldstate structure with an already-completed state in one field
  59. * will compare not-equal to a structure with an already-completed state
  60. * in the other field. After all, the @rcu_gp_oldstate structure is opaque
  61. * so how did such a situation come to pass in the first place?
  62. */
  63. static inline bool same_state_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp1,
  64. struct rcu_gp_oldstate *rgosp2)
  65. {
  66. return rgosp1->rgos_norm == rgosp2->rgos_norm && rgosp1->rgos_exp == rgosp2->rgos_exp;
  67. }
  68. unsigned long start_poll_synchronize_rcu_expedited(void);
  69. void start_poll_synchronize_rcu_expedited_full(struct rcu_gp_oldstate *rgosp);
  70. void cond_synchronize_rcu_expedited(unsigned long oldstate);
  71. void cond_synchronize_rcu_expedited_full(struct rcu_gp_oldstate *rgosp);
  72. unsigned long get_state_synchronize_rcu(void);
  73. void get_state_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp);
  74. unsigned long start_poll_synchronize_rcu(void);
  75. void start_poll_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp);
  76. bool poll_state_synchronize_rcu(unsigned long oldstate);
  77. bool poll_state_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp);
  78. void cond_synchronize_rcu(unsigned long oldstate);
  79. void cond_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp);
  80. bool rcu_is_idle_cpu(int cpu);
  81. #ifdef CONFIG_PROVE_RCU
  82. void rcu_irq_exit_check_preempt(void);
  83. #else
  84. static inline void rcu_irq_exit_check_preempt(void) { }
  85. #endif
  86. struct task_struct;
  87. void rcu_preempt_deferred_qs(struct task_struct *t);
  88. void exit_rcu(void);
  89. void rcu_scheduler_starting(void);
  90. extern int rcu_scheduler_active;
  91. void rcu_end_inkernel_boot(void);
  92. bool rcu_inkernel_boot_has_ended(void);
  93. bool rcu_is_watching(void);
  94. #ifndef CONFIG_PREEMPTION
  95. void rcu_all_qs(void);
  96. #endif
  97. /* RCUtree hotplug events */
  98. int rcutree_prepare_cpu(unsigned int cpu);
  99. int rcutree_online_cpu(unsigned int cpu);
  100. int rcutree_offline_cpu(unsigned int cpu);
  101. int rcutree_dead_cpu(unsigned int cpu);
  102. int rcutree_dying_cpu(unsigned int cpu);
  103. void rcu_cpu_starting(unsigned int cpu);
  104. #endif /* __LINUX_RCUTREE_H */