blob: 3fa179784e18b24bcce5258e718d7e34a4bb21bc [file] [log] [blame]
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -07001/*
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 Molnar4ce5b902009-10-26 07:55:55 +010023 * Documentation/RCU
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070024 */
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070025#ifndef __LINUX_TINY_H
26#define __LINUX_TINY_H
27
28#include <linux/cache.h>
29
30void rcu_sched_qs(int cpu);
31void rcu_bh_qs(int cpu);
32
Paul E. McKenneya57eb942010-06-29 16:49:16 -070033#ifdef CONFIG_TINY_RCU
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070034#define __rcu_read_lock() preempt_disable()
35#define __rcu_read_unlock() preempt_enable()
Paul E. McKenneya57eb942010-06-29 16:49:16 -070036#else /* #ifdef CONFIG_TINY_RCU */
37void __rcu_read_lock(void);
38void __rcu_read_unlock(void);
39#endif /* #else #ifdef CONFIG_TINY_RCU */
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070040#define __rcu_read_lock_bh() local_bh_disable()
41#define __rcu_read_unlock_bh() local_bh_enable()
Paul E. McKenneya57eb942010-06-29 16:49:16 -070042extern void call_rcu_sched(struct rcu_head *head,
43 void (*func)(struct rcu_head *rcu));
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070044
45#define rcu_init_sched() do { } while (0)
Paul E. McKenneybf66f182010-01-04 15:09:10 -080046
Paul E. McKenneyda848c42010-03-30 15:46:01 -070047extern void synchronize_sched(void);
48
Paul E. McKenneya57eb942010-06-29 16:49:16 -070049#ifdef CONFIG_TINY_RCU
50
51#define call_rcu call_rcu_sched
52
Paul E. McKenneyda848c42010-03-30 15:46:01 -070053static inline void synchronize_rcu(void)
54{
55 synchronize_sched();
56}
57
Paul E. McKenneya57eb942010-06-29 16:49:16 -070058static inline void synchronize_rcu_expedited(void)
Paul E. McKenneyda848c42010-03-30 15:46:01 -070059{
Paul E. McKenneya57eb942010-06-29 16:49:16 -070060 synchronize_sched(); /* Only one CPU, so pretty fast anyway!!! */
Paul E. McKenneyda848c42010-03-30 15:46:01 -070061}
Paul E. McKenney6ebb2372009-11-22 08:53:50 -080062
Paul E. McKenneya57eb942010-06-29 16:49:16 -070063static 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
70void synchronize_rcu(void);
71void rcu_barrier(void);
72void synchronize_rcu_expedited(void);
73
74#endif /* #else #ifdef CONFIG_TINY_RCU */
75
76static inline void synchronize_rcu_bh(void)
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070077{
78 synchronize_sched();
79}
80
81static inline void synchronize_rcu_bh_expedited(void)
82{
83 synchronize_sched();
84}
85
86struct notifier_block;
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -070087
88#ifdef CONFIG_NO_HZ
89
90extern void rcu_enter_nohz(void);
91extern void rcu_exit_nohz(void);
92
93#else /* #ifdef CONFIG_NO_HZ */
94
95static inline void rcu_enter_nohz(void)
96{
97}
98
99static inline void rcu_exit_nohz(void)
100{
101}
102
103#endif /* #else #ifdef CONFIG_NO_HZ */
104
Paul E. McKenneya57eb942010-06-29 16:49:16 -0700105#ifdef CONFIG_TINY_RCU
106
107static inline void rcu_preempt_note_context_switch(void)
108{
109}
110
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -0700111static inline void exit_rcu(void)
112{
113}
114
Paul E. McKenneya57eb942010-06-29 16:49:16 -0700115static inline int rcu_needs_cpu(int cpu)
116{
117 return 0;
118}
119
Frederic Weisbecker234da7b2009-12-16 20:21:05 +0100120static inline int rcu_preempt_depth(void)
121{
122 return 0;
123}
124
Paul E. McKenneya57eb942010-06-29 16:49:16 -0700125#else /* #ifdef CONFIG_TINY_RCU */
126
127void rcu_preempt_note_context_switch(void);
128extern void exit_rcu(void);
129int rcu_preempt_needs_cpu(void);
130
131static 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
145static inline void rcu_note_context_switch(int cpu)
146{
147 rcu_sched_qs(cpu);
148 rcu_preempt_note_context_switch();
149}
150
151extern void rcu_check_callbacks(int cpu, int user);
152
153/*
154 * Return the number of grace periods.
155 */
156static inline long rcu_batches_completed(void)
157{
158 return 0;
159}
160
161/*
162 * Return the number of bottom-half grace periods.
163 */
164static inline long rcu_batches_completed_bh(void)
165{
166 return 0;
167}
168
169static inline void rcu_force_quiescent_state(void)
170{
171}
172
173static inline void rcu_bh_force_quiescent_state(void)
174{
175}
176
177static inline void rcu_sched_force_quiescent_state(void)
178{
179}
180
Paul E. McKenney53d84e02010-08-10 14:28:53 -0700181static inline void rcu_cpu_stall_reset(void)
182{
183}
184
Paul E. McKenneybbad9372010-04-02 16:17:17 -0700185#ifdef CONFIG_DEBUG_LOCK_ALLOC
186
187extern int rcu_scheduler_active __read_mostly;
188extern void rcu_scheduler_starting(void);
189
190#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
191
192static inline void rcu_scheduler_starting(void)
193{
194}
195
196#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
197
Paul E. McKenney9b1d82f2009-10-25 19:03:50 -0700198#endif /* __LINUX_RCUTINY_H */