rcutiny.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Read-Copy Update mechanism for mutual exclusion, the Bloatwatch edition.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright IBM Corporation, 2008
  19. *
  20. * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  21. *
  22. * For detailed explanation of Read-Copy Update mechanism see -
  23. * Documentation/RCU
  24. */
  25. #ifndef __LINUX_TINY_H
  26. #define __LINUX_TINY_H
  27. #include <linux/cache.h>
  28. void rcu_sched_qs(int cpu);
  29. void rcu_bh_qs(int cpu);
  30. #ifdef CONFIG_TINY_RCU
  31. #define __rcu_read_lock() preempt_disable()
  32. #define __rcu_read_unlock() preempt_enable()
  33. #else /* #ifdef CONFIG_TINY_RCU */
  34. void __rcu_read_lock(void);
  35. void __rcu_read_unlock(void);
  36. #endif /* #else #ifdef CONFIG_TINY_RCU */
  37. #define __rcu_read_lock_bh() local_bh_disable()
  38. #define __rcu_read_unlock_bh() local_bh_enable()
  39. extern void call_rcu_sched(struct rcu_head *head,
  40. void (*func)(struct rcu_head *rcu));
  41. #define rcu_init_sched() do { } while (0)
  42. extern void synchronize_sched(void);
  43. #ifdef CONFIG_TINY_RCU
  44. #define call_rcu call_rcu_sched
  45. static inline void synchronize_rcu(void)
  46. {
  47. synchronize_sched();
  48. }
  49. static inline void synchronize_rcu_expedited(void)
  50. {
  51. synchronize_sched(); /* Only one CPU, so pretty fast anyway!!! */
  52. }
  53. static inline void rcu_barrier(void)
  54. {
  55. rcu_barrier_sched(); /* Only one CPU, so only one list of callbacks! */
  56. }
  57. #else /* #ifdef CONFIG_TINY_RCU */
  58. void synchronize_rcu(void);
  59. void rcu_barrier(void);
  60. void synchronize_rcu_expedited(void);
  61. #endif /* #else #ifdef CONFIG_TINY_RCU */
  62. static inline void synchronize_rcu_bh(void)
  63. {
  64. synchronize_sched();
  65. }
  66. static inline void synchronize_rcu_bh_expedited(void)
  67. {
  68. synchronize_sched();
  69. }
  70. struct notifier_block;
  71. #ifdef CONFIG_NO_HZ
  72. extern void rcu_enter_nohz(void);
  73. extern void rcu_exit_nohz(void);
  74. #else /* #ifdef CONFIG_NO_HZ */
  75. static inline void rcu_enter_nohz(void)
  76. {
  77. }
  78. static inline void rcu_exit_nohz(void)
  79. {
  80. }
  81. #endif /* #else #ifdef CONFIG_NO_HZ */
  82. #ifdef CONFIG_TINY_RCU
  83. static inline void rcu_preempt_note_context_switch(void)
  84. {
  85. }
  86. static inline void exit_rcu(void)
  87. {
  88. }
  89. static inline int rcu_needs_cpu(int cpu)
  90. {
  91. return 0;
  92. }
  93. static inline int rcu_preempt_depth(void)
  94. {
  95. return 0;
  96. }
  97. #else /* #ifdef CONFIG_TINY_RCU */
  98. void rcu_preempt_note_context_switch(void);
  99. extern void exit_rcu(void);
  100. int rcu_preempt_needs_cpu(void);
  101. static inline int rcu_needs_cpu(int cpu)
  102. {
  103. return rcu_preempt_needs_cpu();
  104. }
  105. #endif /* #else #ifdef CONFIG_TINY_RCU */
  106. static inline void rcu_note_context_switch(int cpu)
  107. {
  108. rcu_sched_qs(cpu);
  109. rcu_preempt_note_context_switch();
  110. }
  111. extern void rcu_check_callbacks(int cpu, int user);
  112. /*
  113. * Return the number of grace periods.
  114. */
  115. static inline long rcu_batches_completed(void)
  116. {
  117. return 0;
  118. }
  119. /*
  120. * Return the number of bottom-half grace periods.
  121. */
  122. static inline long rcu_batches_completed_bh(void)
  123. {
  124. return 0;
  125. }
  126. static inline void rcu_force_quiescent_state(void)
  127. {
  128. }
  129. static inline void rcu_bh_force_quiescent_state(void)
  130. {
  131. }
  132. static inline void rcu_sched_force_quiescent_state(void)
  133. {
  134. }
  135. static inline void rcu_cpu_stall_reset(void)
  136. {
  137. }
  138. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  139. extern int rcu_scheduler_active __read_mostly;
  140. extern void rcu_scheduler_starting(void);
  141. #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
  142. static inline void rcu_scheduler_starting(void)
  143. {
  144. }
  145. #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
  146. #endif /* __LINUX_RCUTINY_H */