Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 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 - |
Ingo Molnar | 4ce5b90 | 2009-10-26 07:55:55 +0100 | [diff] [blame] | 23 | * Documentation/RCU |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 24 | */ |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 25 | #ifndef __LINUX_TINY_H |
| 26 | #define __LINUX_TINY_H |
| 27 | |
| 28 | #include <linux/cache.h> |
| 29 | |
| 30 | void rcu_sched_qs(int cpu); |
| 31 | void rcu_bh_qs(int cpu); |
| 32 | |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 33 | #ifdef CONFIG_TINY_RCU |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 34 | #define __rcu_read_lock() preempt_disable() |
| 35 | #define __rcu_read_unlock() preempt_enable() |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 36 | #else /* #ifdef CONFIG_TINY_RCU */ |
| 37 | void __rcu_read_lock(void); |
| 38 | void __rcu_read_unlock(void); |
| 39 | #endif /* #else #ifdef CONFIG_TINY_RCU */ |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 40 | #define __rcu_read_lock_bh() local_bh_disable() |
| 41 | #define __rcu_read_unlock_bh() local_bh_enable() |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 42 | extern void call_rcu_sched(struct rcu_head *head, |
| 43 | void (*func)(struct rcu_head *rcu)); |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 44 | |
| 45 | #define rcu_init_sched() do { } while (0) |
Paul E. McKenney | bf66f18 | 2010-01-04 15:09:10 -0800 | [diff] [blame] | 46 | |
Paul E. McKenney | da848c4 | 2010-03-30 15:46:01 -0700 | [diff] [blame] | 47 | extern void synchronize_sched(void); |
| 48 | |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 49 | #ifdef CONFIG_TINY_RCU |
| 50 | |
| 51 | #define call_rcu call_rcu_sched |
| 52 | |
Paul E. McKenney | da848c4 | 2010-03-30 15:46:01 -0700 | [diff] [blame] | 53 | static inline void synchronize_rcu(void) |
| 54 | { |
| 55 | synchronize_sched(); |
| 56 | } |
| 57 | |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 58 | static inline void synchronize_rcu_expedited(void) |
Paul E. McKenney | da848c4 | 2010-03-30 15:46:01 -0700 | [diff] [blame] | 59 | { |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 60 | synchronize_sched(); /* Only one CPU, so pretty fast anyway!!! */ |
Paul E. McKenney | da848c4 | 2010-03-30 15:46:01 -0700 | [diff] [blame] | 61 | } |
Paul E. McKenney | 6ebb237 | 2009-11-22 08:53:50 -0800 | [diff] [blame] | 62 | |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 63 | static inline void rcu_barrier(void) |
| 64 | { |
| 65 | rcu_barrier_sched(); /* Only one CPU, so only one list of callbacks! */ |
| 66 | } |
| 67 | |
| 68 | #else /* #ifdef CONFIG_TINY_RCU */ |
| 69 | |
| 70 | void synchronize_rcu(void); |
| 71 | void rcu_barrier(void); |
| 72 | void synchronize_rcu_expedited(void); |
| 73 | |
| 74 | #endif /* #else #ifdef CONFIG_TINY_RCU */ |
| 75 | |
| 76 | static inline void synchronize_rcu_bh(void) |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 77 | { |
| 78 | synchronize_sched(); |
| 79 | } |
| 80 | |
| 81 | static inline void synchronize_rcu_bh_expedited(void) |
| 82 | { |
| 83 | synchronize_sched(); |
| 84 | } |
| 85 | |
| 86 | struct notifier_block; |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 87 | |
| 88 | #ifdef CONFIG_NO_HZ |
| 89 | |
| 90 | extern void rcu_enter_nohz(void); |
| 91 | extern void rcu_exit_nohz(void); |
| 92 | |
| 93 | #else /* #ifdef CONFIG_NO_HZ */ |
| 94 | |
| 95 | static inline void rcu_enter_nohz(void) |
| 96 | { |
| 97 | } |
| 98 | |
| 99 | static inline void rcu_exit_nohz(void) |
| 100 | { |
| 101 | } |
| 102 | |
| 103 | #endif /* #else #ifdef CONFIG_NO_HZ */ |
| 104 | |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 105 | #ifdef CONFIG_TINY_RCU |
| 106 | |
| 107 | static inline void rcu_preempt_note_context_switch(void) |
| 108 | { |
| 109 | } |
| 110 | |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 111 | static inline void exit_rcu(void) |
| 112 | { |
| 113 | } |
| 114 | |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 115 | static inline int rcu_needs_cpu(int cpu) |
| 116 | { |
| 117 | return 0; |
| 118 | } |
| 119 | |
Frederic Weisbecker | 234da7b | 2009-12-16 20:21:05 +0100 | [diff] [blame] | 120 | static inline int rcu_preempt_depth(void) |
| 121 | { |
| 122 | return 0; |
| 123 | } |
| 124 | |
Paul E. McKenney | a57eb94 | 2010-06-29 16:49:16 -0700 | [diff] [blame^] | 125 | #else /* #ifdef CONFIG_TINY_RCU */ |
| 126 | |
| 127 | void rcu_preempt_note_context_switch(void); |
| 128 | extern void exit_rcu(void); |
| 129 | int rcu_preempt_needs_cpu(void); |
| 130 | |
| 131 | static inline int rcu_needs_cpu(int cpu) |
| 132 | { |
| 133 | return rcu_preempt_needs_cpu(); |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Defined as macro as it is a very low level header |
| 138 | * included from areas that don't even know about current |
| 139 | * FIXME: combine with include/linux/rcutree.h into rcupdate.h. |
| 140 | */ |
| 141 | #define rcu_preempt_depth() (current->rcu_read_lock_nesting) |
| 142 | |
| 143 | #endif /* #else #ifdef CONFIG_TINY_RCU */ |
| 144 | |
| 145 | static inline void rcu_note_context_switch(int cpu) |
| 146 | { |
| 147 | rcu_sched_qs(cpu); |
| 148 | rcu_preempt_note_context_switch(); |
| 149 | } |
| 150 | |
| 151 | extern void rcu_check_callbacks(int cpu, int user); |
| 152 | |
| 153 | /* |
| 154 | * Return the number of grace periods. |
| 155 | */ |
| 156 | static inline long rcu_batches_completed(void) |
| 157 | { |
| 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | * Return the number of bottom-half grace periods. |
| 163 | */ |
| 164 | static inline long rcu_batches_completed_bh(void) |
| 165 | { |
| 166 | return 0; |
| 167 | } |
| 168 | |
| 169 | static inline void rcu_force_quiescent_state(void) |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | static inline void rcu_bh_force_quiescent_state(void) |
| 174 | { |
| 175 | } |
| 176 | |
| 177 | static inline void rcu_sched_force_quiescent_state(void) |
| 178 | { |
| 179 | } |
| 180 | |
Paul E. McKenney | bbad937 | 2010-04-02 16:17:17 -0700 | [diff] [blame] | 181 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 182 | |
| 183 | extern int rcu_scheduler_active __read_mostly; |
| 184 | extern void rcu_scheduler_starting(void); |
| 185 | |
| 186 | #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ |
| 187 | |
| 188 | static inline void rcu_scheduler_starting(void) |
| 189 | { |
| 190 | } |
| 191 | |
| 192 | #endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ |
| 193 | |
Paul E. McKenney | 9b1d82f | 2009-10-25 19:03:50 -0700 | [diff] [blame] | 194 | #endif /* __LINUX_RCUTINY_H */ |