[ARM] 5320/1: fix assembly constraints in implementation of do_div()
[linux-2.6/mini2440.git] / include / linux / rcuclassic.h
blob5f89b62e6983192befd7cc827df50fb53cd0a173
1 /*
2 * Read-Copy Update mechanism for mutual exclusion (classic version)
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.
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.
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.
18 * Copyright IBM Corporation, 2001
20 * Author: Dipankar Sarma <dipankar@in.ibm.com>
22 * Based on the original work by Paul McKenney <paulmck@us.ibm.com>
23 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
24 * Papers:
25 * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
26 * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
28 * For detailed explanation of Read-Copy Update mechanism see -
29 * Documentation/RCU
33 #ifndef __LINUX_RCUCLASSIC_H
34 #define __LINUX_RCUCLASSIC_H
36 #include <linux/cache.h>
37 #include <linux/spinlock.h>
38 #include <linux/threads.h>
39 #include <linux/percpu.h>
40 #include <linux/cpumask.h>
41 #include <linux/seqlock.h>
43 #ifdef CONFIG_RCU_CPU_STALL_DETECTOR
44 #define RCU_SECONDS_TILL_STALL_CHECK ( 3 * HZ) /* for rcp->jiffies_stall */
45 #define RCU_SECONDS_TILL_STALL_RECHECK (30 * HZ) /* for rcp->jiffies_stall */
46 #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
48 /* Global control variables for rcupdate callback mechanism. */
49 struct rcu_ctrlblk {
50 long cur; /* Current batch number. */
51 long completed; /* Number of the last completed batch */
52 long pending; /* Number of the last pending batch */
53 #ifdef CONFIG_RCU_CPU_STALL_DETECTOR
54 unsigned long gp_start; /* Time at which GP started in jiffies. */
55 unsigned long jiffies_stall;
56 /* Time at which to check for CPU stalls. */
57 #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
59 int signaled;
61 spinlock_t lock ____cacheline_internodealigned_in_smp;
62 cpumask_t cpumask; /* CPUs that need to switch in order */
63 /* for current batch to proceed. */
64 } ____cacheline_internodealigned_in_smp;
66 /* Is batch a before batch b ? */
67 static inline int rcu_batch_before(long a, long b)
69 return (a - b) < 0;
72 /* Is batch a after batch b ? */
73 static inline int rcu_batch_after(long a, long b)
75 return (a - b) > 0;
78 /* Per-CPU data for Read-Copy UPdate. */
79 struct rcu_data {
80 /* 1) quiescent state handling : */
81 long quiescbatch; /* Batch # for grace period */
82 int passed_quiesc; /* User-mode/idle loop etc. */
83 int qs_pending; /* core waits for quiesc state */
85 /* 2) batch handling */
87 * if nxtlist is not NULL, then:
88 * batch:
89 * The batch # for the last entry of nxtlist
90 * [*nxttail[1], NULL = *nxttail[2]):
91 * Entries that batch # <= batch
92 * [*nxttail[0], *nxttail[1]):
93 * Entries that batch # <= batch - 1
94 * [nxtlist, *nxttail[0]):
95 * Entries that batch # <= batch - 2
96 * The grace period for these entries has completed, and
97 * the other grace-period-completed entries may be moved
98 * here temporarily in rcu_process_callbacks().
100 long batch;
101 struct rcu_head *nxtlist;
102 struct rcu_head **nxttail[3];
103 long qlen; /* # of queued callbacks */
104 struct rcu_head *donelist;
105 struct rcu_head **donetail;
106 long blimit; /* Upper limit on a processed batch */
107 int cpu;
108 struct rcu_head barrier;
111 DECLARE_PER_CPU(struct rcu_data, rcu_data);
112 DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
115 * Increment the quiescent state counter.
116 * The counter is a bit degenerated: We do not need to know
117 * how many quiescent states passed, just if there was at least
118 * one since the start of the grace period. Thus just a flag.
120 static inline void rcu_qsctr_inc(int cpu)
122 struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
123 rdp->passed_quiesc = 1;
125 static inline void rcu_bh_qsctr_inc(int cpu)
127 struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
128 rdp->passed_quiesc = 1;
131 extern int rcu_pending(int cpu);
132 extern int rcu_needs_cpu(int cpu);
134 #ifdef CONFIG_DEBUG_LOCK_ALLOC
135 extern struct lockdep_map rcu_lock_map;
136 # define rcu_read_acquire() \
137 lock_acquire(&rcu_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_)
138 # define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_)
139 #else
140 # define rcu_read_acquire() do { } while (0)
141 # define rcu_read_release() do { } while (0)
142 #endif
144 #define __rcu_read_lock() \
145 do { \
146 preempt_disable(); \
147 __acquire(RCU); \
148 rcu_read_acquire(); \
149 } while (0)
150 #define __rcu_read_unlock() \
151 do { \
152 rcu_read_release(); \
153 __release(RCU); \
154 preempt_enable(); \
155 } while (0)
156 #define __rcu_read_lock_bh() \
157 do { \
158 local_bh_disable(); \
159 __acquire(RCU_BH); \
160 rcu_read_acquire(); \
161 } while (0)
162 #define __rcu_read_unlock_bh() \
163 do { \
164 rcu_read_release(); \
165 __release(RCU_BH); \
166 local_bh_enable(); \
167 } while (0)
169 #define __synchronize_sched() synchronize_rcu()
171 #define call_rcu_sched(head, func) call_rcu(head, func)
173 extern void __rcu_init(void);
174 #define rcu_init_sched() do { } while (0)
175 extern void rcu_check_callbacks(int cpu, int user);
176 extern void rcu_restart_cpu(int cpu);
178 extern long rcu_batches_completed(void);
179 extern long rcu_batches_completed_bh(void);
181 #define rcu_enter_nohz() do { } while (0)
182 #define rcu_exit_nohz() do { } while (0)
184 #endif /* __LINUX_RCUCLASSIC_H */