Commit | Line | Data |
---|---|---|
9f77da9f PM |
1 | /* |
2 | * Read-Copy Update mechanism for mutual exclusion (tree-based version) | |
3 | * Internal non-public definitions. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
87de1cfd PM |
16 | * along with this program; if not, you can access it online at |
17 | * http://www.gnu.org/licenses/gpl-2.0.html. | |
9f77da9f PM |
18 | * |
19 | * Copyright IBM Corporation, 2008 | |
20 | * | |
21 | * Author: Ingo Molnar <mingo@elte.hu> | |
22 | * Paul E. McKenney <paulmck@linux.vnet.ibm.com> | |
23 | */ | |
24 | ||
25 | #include <linux/cache.h> | |
26 | #include <linux/spinlock.h> | |
037741a6 | 27 | #include <linux/rtmutex.h> |
9f77da9f PM |
28 | #include <linux/threads.h> |
29 | #include <linux/cpumask.h> | |
30 | #include <linux/seqlock.h> | |
abedf8e2 | 31 | #include <linux/swait.h> |
3a6d7c64 | 32 | #include <linux/stop_machine.h> |
f2425b4e | 33 | #include <linux/rcu_node_tree.h> |
f885b7f2 | 34 | |
45753c5f IM |
35 | #include "rcu_segcblist.h" |
36 | ||
25f3d7ef PM |
37 | /* Communicate arguments to a workqueue handler. */ |
38 | struct rcu_exp_work { | |
39 | smp_call_func_t rew_func; | |
25f3d7ef PM |
40 | unsigned long rew_s; |
41 | struct work_struct rew_work; | |
42 | }; | |
43 | ||
d71df90e PM |
44 | /* RCU's kthread states for tracing. */ |
45 | #define RCU_KTHREAD_STOPPED 0 | |
46 | #define RCU_KTHREAD_RUNNING 1 | |
47 | #define RCU_KTHREAD_WAITING 2 | |
15ba0ba8 PM |
48 | #define RCU_KTHREAD_OFFCPU 3 |
49 | #define RCU_KTHREAD_YIELDING 4 | |
50 | #define RCU_KTHREAD_MAX 4 | |
d71df90e | 51 | |
9f77da9f PM |
52 | /* |
53 | * Definition for node within the RCU grace-period-detection hierarchy. | |
54 | */ | |
55 | struct rcu_node { | |
67c583a7 BF |
56 | raw_spinlock_t __private lock; /* Root rcu_node's lock protects */ |
57 | /* some rcu_state fields as well as */ | |
58 | /* following. */ | |
de30ad51 | 59 | unsigned long gp_seq; /* Track rsp->rcu_gp_seq. */ |
adbccddb | 60 | unsigned long gp_seq_needed; /* Track furthest future GP request. */ |
4bc8d555 | 61 | unsigned long completedqs; /* All QSes done for this node. */ |
9f77da9f PM |
62 | unsigned long qsmask; /* CPUs or groups that need to switch in */ |
63 | /* order for current grace period to proceed.*/ | |
1eba8f84 PM |
64 | /* In leaf rcu_node, each bit corresponds to */ |
65 | /* an rcu_data structure, otherwise, each */ | |
66 | /* bit corresponds to a child rcu_node */ | |
67 | /* structure. */ | |
f2e2df59 | 68 | unsigned long rcu_gp_init_mask; /* Mask of offline CPUs at GP init. */ |
9f77da9f | 69 | unsigned long qsmaskinit; |
b9585e94 | 70 | /* Per-GP initial value for qsmask. */ |
0aa04b05 PM |
71 | /* Initialized from ->qsmaskinitnext at the */ |
72 | /* beginning of each grace period. */ | |
73 | unsigned long qsmaskinitnext; | |
74 | /* Online CPUs for next grace period. */ | |
b9585e94 PM |
75 | unsigned long expmask; /* CPUs or groups that need to check in */ |
76 | /* to allow the current expedited GP */ | |
77 | /* to complete. */ | |
78 | unsigned long expmaskinit; | |
79 | /* Per-GP initial values for expmask. */ | |
80 | /* Initialized from ->expmaskinitnext at the */ | |
81 | /* beginning of each expedited GP. */ | |
82 | unsigned long expmaskinitnext; | |
83 | /* Online CPUs for next expedited GP. */ | |
1de6e56d PM |
84 | /* Any CPU that has ever been online will */ |
85 | /* have its bit set. */ | |
9b9500da | 86 | unsigned long ffmask; /* Fully functional CPUs. */ |
9f77da9f | 87 | unsigned long grpmask; /* Mask to apply to parent qsmask. */ |
1eba8f84 | 88 | /* Only one bit will be set in this mask. */ |
9f77da9f PM |
89 | int grplo; /* lowest-numbered CPU or group here. */ |
90 | int grphi; /* highest-numbered CPU or group here. */ | |
91 | u8 grpnum; /* CPU/group number for next level up. */ | |
92 | u8 level; /* root is at level 0. */ | |
0aa04b05 PM |
93 | bool wait_blkd_tasks;/* Necessary to wait for blocked tasks to */ |
94 | /* exit RCU read-side critical sections */ | |
95 | /* before propagating offline up the */ | |
96 | /* rcu_node tree? */ | |
9f77da9f | 97 | struct rcu_node *parent; |
12f5f524 PM |
98 | struct list_head blkd_tasks; |
99 | /* Tasks blocked in RCU read-side critical */ | |
100 | /* section. Tasks are placed at the head */ | |
101 | /* of this list and age towards the tail. */ | |
102 | struct list_head *gp_tasks; | |
103 | /* Pointer to the first task blocking the */ | |
104 | /* current grace period, or NULL if there */ | |
105 | /* is no such task. */ | |
106 | struct list_head *exp_tasks; | |
107 | /* Pointer to the first task blocking the */ | |
108 | /* current expedited grace period, or NULL */ | |
109 | /* if there is no such task. If there */ | |
110 | /* is no current expedited grace period, */ | |
111 | /* then there can cannot be any such task. */ | |
27f4d280 PM |
112 | struct list_head *boost_tasks; |
113 | /* Pointer to first task that needs to be */ | |
114 | /* priority boosted, or NULL if no priority */ | |
115 | /* boosting is needed for this rcu_node */ | |
116 | /* structure. If there are no tasks */ | |
117 | /* queued on this rcu_node structure that */ | |
118 | /* are blocking the current grace period, */ | |
119 | /* there can be no such task. */ | |
abaa93d9 PM |
120 | struct rt_mutex boost_mtx; |
121 | /* Used only for the priority-boosting */ | |
122 | /* side effect, not as a lock. */ | |
27f4d280 PM |
123 | unsigned long boost_time; |
124 | /* When to start boosting (jiffies). */ | |
125 | struct task_struct *boost_kthread_task; | |
126 | /* kthread that takes care of priority */ | |
127 | /* boosting for this rcu_node structure. */ | |
d71df90e PM |
128 | unsigned int boost_kthread_status; |
129 | /* State of boost_kthread_task for tracing. */ | |
dae6e64d | 130 | #ifdef CONFIG_RCU_NOCB_CPU |
abedf8e2 | 131 | struct swait_queue_head nocb_gp_wq[2]; |
dae6e64d | 132 | /* Place for rcu_nocb_kthread() to wait GP. */ |
dae6e64d | 133 | #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ |
394f2769 | 134 | raw_spinlock_t fqslock ____cacheline_internodealigned_in_smp; |
385b73c0 | 135 | |
f6a12f34 PM |
136 | spinlock_t exp_lock ____cacheline_internodealigned_in_smp; |
137 | unsigned long exp_seq_rq; | |
3b5f668e | 138 | wait_queue_head_t exp_wq[4]; |
25f3d7ef PM |
139 | struct rcu_exp_work rew; |
140 | bool exp_need_flush; /* Need to flush workitem? */ | |
9f77da9f PM |
141 | } ____cacheline_internodealigned_in_smp; |
142 | ||
bc75e999 MR |
143 | /* |
144 | * Bitmasks in an rcu_node cover the interval [grplo, grphi] of CPU IDs, and | |
145 | * are indexed relative to this interval rather than the global CPU ID space. | |
146 | * This generates the bit for a CPU in node-local masks. | |
147 | */ | |
df63fa5b | 148 | #define leaf_node_cpu_bit(rnp, cpu) (BIT((cpu) - (rnp)->grplo)) |
bc75e999 | 149 | |
5b74c458 PM |
150 | /* |
151 | * Union to allow "aggregate OR" operation on the need for a quiescent | |
152 | * state by the normal and expedited grace periods. | |
153 | */ | |
154 | union rcu_noqs { | |
155 | struct { | |
156 | u8 norm; | |
157 | u8 exp; | |
158 | } b; /* Bits. */ | |
159 | u16 s; /* Set of bits, aggregate OR here. */ | |
160 | }; | |
161 | ||
9f77da9f PM |
162 | /* Per-CPU data for read-copy update. */ |
163 | struct rcu_data { | |
164 | /* 1) quiescent-state and grace-period handling : */ | |
de30ad51 | 165 | unsigned long gp_seq; /* Track rsp->rcu_gp_seq counter. */ |
adbccddb | 166 | unsigned long gp_seq_needed; /* Track furthest future GP request. */ |
5b74c458 | 167 | union rcu_noqs cpu_no_qs; /* No QSes yet for this CPU. */ |
97c668b8 | 168 | bool core_needs_qs; /* Core waits for quiesc state. */ |
9f77da9f | 169 | bool beenonline; /* CPU online at least once. */ |
ff3bb6f4 | 170 | bool gpwrap; /* Possible ->gp_seq wrap. */ |
3e310098 | 171 | bool deferred_qs; /* This CPU awaiting a deferred QS? */ |
9f77da9f PM |
172 | struct rcu_node *mynode; /* This CPU's leaf of hierarchy */ |
173 | unsigned long grpmask; /* Mask to apply to leaf qsmask. */ | |
a858af28 PM |
174 | unsigned long ticks_this_gp; /* The number of scheduling-clock */ |
175 | /* ticks this CPU has handled */ | |
176 | /* during and after the last grace */ | |
177 | /* period it is aware of. */ | |
9f77da9f PM |
178 | |
179 | /* 2) batch handling */ | |
15fecf89 PM |
180 | struct rcu_segcblist cblist; /* Segmented callback list, with */ |
181 | /* different callbacks waiting for */ | |
182 | /* different grace periods. */ | |
37c72e56 PM |
183 | long qlen_last_fqs_check; |
184 | /* qlen at last check for QS forcing */ | |
185 | unsigned long n_force_qs_snap; | |
186 | /* did other CPU force QS recently? */ | |
9f77da9f PM |
187 | long blimit; /* Upper limit on a processed batch */ |
188 | ||
9f77da9f | 189 | /* 3) dynticks interface. */ |
9f77da9f | 190 | int dynticks_snap; /* Per-GP tracking for dynticks. */ |
dc5a4f29 PM |
191 | long dynticks_nesting; /* Track process nesting level. */ |
192 | long dynticks_nmi_nesting; /* Track irq/NMI nesting level. */ | |
193 | atomic_t dynticks; /* Even value for idle, else odd. */ | |
194 | bool rcu_need_heavy_qs; /* GP old, so heavy quiescent state! */ | |
195 | bool rcu_urgent_qs; /* GP old need light quiescent state. */ | |
cc72046c | 196 | #ifdef CONFIG_RCU_FAST_NO_HZ |
dc5a4f29 PM |
197 | bool all_lazy; /* Are all CPU's CBs lazy? */ |
198 | unsigned long nonlazy_posted; /* # times non-lazy CB posted to CPU. */ | |
cc72046c | 199 | unsigned long nonlazy_posted_snap; |
dc5a4f29 PM |
200 | /* Nonlazy_posted snapshot. */ |
201 | unsigned long last_accelerate; /* Last jiffy CBs were accelerated. */ | |
202 | unsigned long last_advance_all; /* Last jiffy CBs were all advanced. */ | |
203 | int tick_nohz_enabled_snap; /* Previously seen value from sysfs. */ | |
cc72046c | 204 | #endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */ |
9f77da9f | 205 | |
8d8a9d0e | 206 | /* 4) rcu_barrier(), OOM callbacks, and expediting. */ |
06668efa | 207 | struct rcu_head barrier_head; |
0742ac3e | 208 | int exp_dynticks_snap; /* Double-check need for IPI. */ |
06668efa | 209 | |
8d8a9d0e | 210 | /* 5) Callback offloading. */ |
3fbfbf7a PM |
211 | #ifdef CONFIG_RCU_NOCB_CPU |
212 | struct rcu_head *nocb_head; /* CBs waiting for kthread. */ | |
213 | struct rcu_head **nocb_tail; | |
41050a00 PM |
214 | atomic_long_t nocb_q_count; /* # CBs waiting for nocb */ |
215 | atomic_long_t nocb_q_count_lazy; /* invocation (all stages). */ | |
fbce7497 PM |
216 | struct rcu_head *nocb_follower_head; /* CBs ready to invoke. */ |
217 | struct rcu_head **nocb_follower_tail; | |
abedf8e2 | 218 | struct swait_queue_head nocb_wq; /* For nocb kthreads to sleep on. */ |
3fbfbf7a | 219 | struct task_struct *nocb_kthread; |
8be6e1b1 | 220 | raw_spinlock_t nocb_lock; /* Guard following pair of fields. */ |
9fdd3bc9 | 221 | int nocb_defer_wakeup; /* Defer wakeup of nocb_kthread. */ |
8be6e1b1 | 222 | struct timer_list nocb_timer; /* Enforce finite deferral. */ |
fbce7497 PM |
223 | |
224 | /* The following fields are used by the leader, hence own cacheline. */ | |
225 | struct rcu_head *nocb_gp_head ____cacheline_internodealigned_in_smp; | |
226 | /* CBs waiting for GP. */ | |
227 | struct rcu_head **nocb_gp_tail; | |
11ed7f93 | 228 | bool nocb_leader_sleep; /* Is the nocb leader thread asleep? */ |
fbce7497 PM |
229 | struct rcu_data *nocb_next_follower; |
230 | /* Next follower in wakeup chain. */ | |
231 | ||
232 | /* The following fields are used by the follower, hence new cachline. */ | |
233 | struct rcu_data *nocb_leader ____cacheline_internodealigned_in_smp; | |
234 | /* Leader CPU takes GP-end wakeups. */ | |
3fbfbf7a PM |
235 | #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ |
236 | ||
8d8a9d0e | 237 | /* 6) Diagnostic data, including RCU CPU stall warnings. */ |
6231069b | 238 | unsigned int softirq_snap; /* Snapshot of softirq activity. */ |
9b9500da PM |
239 | /* ->rcu_iw* fields protected by leaf rcu_node ->lock. */ |
240 | struct irq_work rcu_iw; /* Check for non-irq activity. */ | |
241 | bool rcu_iw_pending; /* Is ->rcu_iw pending? */ | |
8aa670cd | 242 | unsigned long rcu_iw_gp_seq; /* ->gp_seq associated with ->rcu_iw. */ |
57738942 PM |
243 | unsigned long rcu_ofl_gp_seq; /* ->gp_seq at last offline. */ |
244 | short rcu_ofl_gp_flags; /* ->gp_flags at last offline. */ | |
245 | unsigned long rcu_onl_gp_seq; /* ->gp_seq at last online. */ | |
246 | short rcu_onl_gp_flags; /* ->gp_flags at last online. */ | |
d3052109 | 247 | unsigned long last_fqs_resched; /* Time of last rcu_resched(). */ |
6231069b | 248 | |
9f77da9f PM |
249 | int cpu; |
250 | }; | |
251 | ||
9fdd3bc9 | 252 | /* Values for nocb_defer_wakeup field in struct rcu_data. */ |
511324e4 PM |
253 | #define RCU_NOCB_WAKE_NOT 0 |
254 | #define RCU_NOCB_WAKE 1 | |
255 | #define RCU_NOCB_WAKE_FORCE 2 | |
9fdd3bc9 | 256 | |
026ad283 PM |
257 | #define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500)) |
258 | /* For jiffies_till_first_fqs and */ | |
259 | /* and jiffies_till_next_fqs. */ | |
007b0924 | 260 | |
026ad283 PM |
261 | #define RCU_JIFFIES_FQS_DIV 256 /* Very large systems need more */ |
262 | /* delay between bouts of */ | |
263 | /* quiescent-state forcing. */ | |
264 | ||
265 | #define RCU_STALL_RAT_DELAY 2 /* Allow other CPUs time to take */ | |
266 | /* at least one scheduling clock */ | |
267 | /* irq before ratting on them. */ | |
9f77da9f | 268 | |
08bca60a PZ |
269 | #define rcu_wait(cond) \ |
270 | do { \ | |
271 | for (;;) { \ | |
272 | set_current_state(TASK_INTERRUPTIBLE); \ | |
273 | if (cond) \ | |
274 | break; \ | |
275 | schedule(); \ | |
276 | } \ | |
277 | __set_current_state(TASK_RUNNING); \ | |
278 | } while (0) | |
9f77da9f PM |
279 | |
280 | /* | |
281 | * RCU global state, including node hierarchy. This hierarchy is | |
282 | * represented in "heap" form in a dense array. The root (first level) | |
283 | * of the hierarchy is in ->node[0] (referenced by ->level[0]), the second | |
284 | * level in ->node[1] through ->node[m] (->node[1] referenced by ->level[1]), | |
285 | * and the third level in ->node[m+1] and following (->node[m+1] referenced | |
286 | * by ->level[2]). The number of levels is determined by the number of | |
287 | * CPUs and by CONFIG_RCU_FANOUT. Small systems will have a "hierarchy" | |
288 | * consisting of a single rcu_node. | |
289 | */ | |
290 | struct rcu_state { | |
291 | struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */ | |
032dfc87 AG |
292 | struct rcu_node *level[RCU_NUM_LVLS + 1]; |
293 | /* Hierarchy levels (+1 to */ | |
294 | /* shut bogus gcc warning) */ | |
b9585e94 | 295 | int ncpus; /* # CPUs seen so far. */ |
9f77da9f PM |
296 | |
297 | /* The following fields are guarded by the root rcu_node's lock. */ | |
298 | ||
77f81fe0 PM |
299 | u8 boost ____cacheline_internodealigned_in_smp; |
300 | /* Subject to priority boost. */ | |
de30ad51 | 301 | unsigned long gp_seq; /* Grace-period sequence #. */ |
b3dbec76 | 302 | struct task_struct *gp_kthread; /* Task for grace periods. */ |
abedf8e2 | 303 | struct swait_queue_head gp_wq; /* Where GP task waits. */ |
afea227f PM |
304 | short gp_flags; /* Commands for GP task. */ |
305 | short gp_state; /* GP kthread sleep state. */ | |
1eba8f84 | 306 | |
d9a3da06 | 307 | /* End of fields guarded by root rcu_node's lock. */ |
1eba8f84 | 308 | |
7be7f0be | 309 | struct mutex barrier_mutex; /* Guards barrier fields. */ |
24ebbca8 | 310 | atomic_t barrier_cpu_count; /* # CPUs waiting on. */ |
7db74df8 | 311 | struct completion barrier_completion; /* Wake at barrier end. */ |
4f525a52 | 312 | unsigned long barrier_sequence; /* ++ at start and end of */ |
dd46a788 | 313 | /* rcu_barrier(). */ |
a4fbe35a PM |
314 | /* End of fields guarded by barrier_mutex. */ |
315 | ||
f6a12f34 | 316 | struct mutex exp_mutex; /* Serialize expedited GP. */ |
3b5f668e | 317 | struct mutex exp_wake_mutex; /* Serialize wakeup. */ |
d6ada2cf | 318 | unsigned long expedited_sequence; /* Take a ticket. */ |
3a6d7c64 | 319 | atomic_t expedited_need_qs; /* # CPUs left to check in. */ |
abedf8e2 | 320 | struct swait_queue_head expedited_wq; /* Wait for check-ins. */ |
b9585e94 | 321 | int ncpus_snap; /* # CPUs seen last time. */ |
40694d66 | 322 | |
9f77da9f PM |
323 | unsigned long jiffies_force_qs; /* Time at which to invoke */ |
324 | /* force_quiescent_state(). */ | |
8c7c4829 PM |
325 | unsigned long jiffies_kick_kthreads; /* Time at which to kick */ |
326 | /* kthreads, if configured. */ | |
9f77da9f PM |
327 | unsigned long n_force_qs; /* Number of calls to */ |
328 | /* force_quiescent_state(). */ | |
9f77da9f PM |
329 | unsigned long gp_start; /* Time at which GP started, */ |
330 | /* but in jiffies. */ | |
c51d7b5e PM |
331 | unsigned long gp_end; /* Time last GP ended, again */ |
332 | /* in jiffies. */ | |
6ccd2ecd PM |
333 | unsigned long gp_activity; /* Time of last GP kthread */ |
334 | /* activity in jiffies. */ | |
26d950a9 PM |
335 | unsigned long gp_req_activity; /* Time of last GP request */ |
336 | /* in jiffies. */ | |
9f77da9f PM |
337 | unsigned long jiffies_stall; /* Time at which to check */ |
338 | /* for CPU stalls. */ | |
6193c76a PM |
339 | unsigned long jiffies_resched; /* Time at which to resched */ |
340 | /* a reluctant CPU. */ | |
fc908ed3 PM |
341 | unsigned long n_force_qs_gpstart; /* Snapshot of n_force_qs at */ |
342 | /* GP start. */ | |
15ba0ba8 PM |
343 | unsigned long gp_max; /* Maximum GP duration in */ |
344 | /* jiffies. */ | |
e66c33d5 | 345 | const char *name; /* Name of structure. */ |
a4889858 | 346 | char abbr; /* Abbreviated name. */ |
1e64b15a | 347 | |
894d45bb | 348 | raw_spinlock_t ofl_lock ____cacheline_internodealigned_in_smp; |
1e64b15a PM |
349 | /* Synchronize offline with */ |
350 | /* GP pre-initialization. */ | |
9f77da9f PM |
351 | }; |
352 | ||
4cdfc175 PM |
353 | /* Values for rcu_state structure's gp_flags field. */ |
354 | #define RCU_GP_FLAG_INIT 0x1 /* Need grace-period initialization. */ | |
355 | #define RCU_GP_FLAG_FQS 0x2 /* Need grace-period quiescent-state forcing. */ | |
356 | ||
c34d2f41 | 357 | /* Values for rcu_state structure's gp_state field. */ |
77f81fe0 | 358 | #define RCU_GP_IDLE 0 /* Initial state and no GP in progress. */ |
afea227f | 359 | #define RCU_GP_WAIT_GPS 1 /* Wait for grace-period start. */ |
319362c9 | 360 | #define RCU_GP_DONE_GPS 2 /* Wait done for grace-period start. */ |
fea3f222 PM |
361 | #define RCU_GP_ONOFF 3 /* Grace-period initialization hotplug. */ |
362 | #define RCU_GP_INIT 4 /* Grace-period initialization. */ | |
363 | #define RCU_GP_WAIT_FQS 5 /* Wait for force-quiescent-state time. */ | |
364 | #define RCU_GP_DOING_FQS 6 /* Wait done for force-quiescent-state time. */ | |
365 | #define RCU_GP_CLEANUP 7 /* Grace-period cleanup started. */ | |
366 | #define RCU_GP_CLEANED 8 /* Grace-period cleanup complete. */ | |
afea227f | 367 | |
6b50e119 PM |
368 | static const char * const gp_state_names[] = { |
369 | "RCU_GP_IDLE", | |
370 | "RCU_GP_WAIT_GPS", | |
371 | "RCU_GP_DONE_GPS", | |
fea3f222 PM |
372 | "RCU_GP_ONOFF", |
373 | "RCU_GP_INIT", | |
6b50e119 PM |
374 | "RCU_GP_WAIT_FQS", |
375 | "RCU_GP_DOING_FQS", | |
376 | "RCU_GP_CLEANUP", | |
377 | "RCU_GP_CLEANED", | |
378 | }; | |
358be2d3 PM |
379 | |
380 | /* | |
381 | * In order to export the rcu_state name to the tracing tools, it | |
382 | * needs to be added in the __tracepoint_string section. | |
383 | * This requires defining a separate variable tp_<sname>_varname | |
384 | * that points to the string being used, and this will allow | |
385 | * the tracing userspace tools to be able to decipher the string | |
386 | * address to the matching string. | |
387 | */ | |
388 | #ifdef CONFIG_PREEMPT_RCU | |
389 | #define RCU_ABBR 'p' | |
390 | #define RCU_NAME_RAW "rcu_preempt" | |
391 | #else /* #ifdef CONFIG_PREEMPT_RCU */ | |
392 | #define RCU_ABBR 's' | |
393 | #define RCU_NAME_RAW "rcu_sched" | |
394 | #endif /* #else #ifdef CONFIG_PREEMPT_RCU */ | |
395 | #ifndef CONFIG_TRACING | |
396 | #define RCU_NAME RCU_NAME_RAW | |
397 | #else /* #ifdef CONFIG_TRACING */ | |
398 | static char rcu_name[] = RCU_NAME_RAW; | |
399 | static const char *tp_rcu_varname __used __tracepoint_string = rcu_name; | |
400 | #define RCU_NAME rcu_name | |
401 | #endif /* #else #ifdef CONFIG_TRACING */ | |
6b50e119 | 402 | |
dc5a4f29 | 403 | int rcu_dynticks_snap(struct rcu_data *rdp); |
02a5c550 | 404 | |
eab0993c PM |
405 | #ifdef CONFIG_RCU_BOOST |
406 | DECLARE_PER_CPU(unsigned int, rcu_cpu_kthread_status); | |
407 | DECLARE_PER_CPU(int, rcu_cpu_kthread_cpu); | |
408 | DECLARE_PER_CPU(unsigned int, rcu_cpu_kthread_loops); | |
409 | DECLARE_PER_CPU(char, rcu_cpu_has_work); | |
410 | #endif /* #ifdef CONFIG_RCU_BOOST */ | |
411 | ||
9b2619af | 412 | /* Forward declarations for rcutree_plugin.h */ |
dbe01350 | 413 | static void rcu_bootup_announce(void); |
45975c7d | 414 | static void rcu_qs(void); |
27f4d280 | 415 | static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp); |
b668c9cf | 416 | #ifdef CONFIG_HOTPLUG_CPU |
8af3a5e7 | 417 | static bool rcu_preempt_has_tasks(struct rcu_node *rnp); |
b668c9cf | 418 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
a2887cd8 | 419 | static void rcu_print_detail_task_stall(void); |
9bc8b558 | 420 | static int rcu_print_task_stall(struct rcu_node *rnp); |
74611ecb | 421 | static int rcu_print_task_exp_stall(struct rcu_node *rnp); |
81ab59a3 | 422 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp); |
45975c7d | 423 | static void rcu_flavor_check_callbacks(int user); |
b6a4ae76 | 424 | void call_rcu(struct rcu_head *head, rcu_callback_t func); |
81ab59a3 | 425 | static void dump_blkd_tasks(struct rcu_node *rnp, int ncheck); |
1217ed1b | 426 | static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); |
a46e0899 PM |
427 | static void rcu_preempt_boost_start_gp(struct rcu_node *rnp); |
428 | static void invoke_rcu_callbacks_kthread(void); | |
dff1672d | 429 | static bool rcu_is_callbacks_kthread(void); |
9386c0b7 | 430 | static void __init rcu_spawn_boost_kthreads(void); |
49fb4c62 | 431 | static void rcu_prepare_kthreads(int cpu); |
8fa7845d | 432 | static void rcu_cleanup_after_idle(void); |
198bbf81 | 433 | static void rcu_prepare_for_idle(void); |
c57afe80 | 434 | static void rcu_idle_count_callbacks_posted(void); |
0aa04b05 | 435 | static bool rcu_preempt_has_tasks(struct rcu_node *rnp); |
3e310098 PM |
436 | static bool rcu_preempt_need_deferred_qs(struct task_struct *t); |
437 | static void rcu_preempt_deferred_qs(struct task_struct *t); | |
a858af28 | 438 | static void print_cpu_stall_info_begin(void); |
b21ebed9 | 439 | static void print_cpu_stall_info(int cpu); |
a858af28 PM |
440 | static void print_cpu_stall_info_end(void); |
441 | static void zero_cpu_stall_ticks(struct rcu_data *rdp); | |
4580b054 | 442 | static bool rcu_nocb_cpu_needs_barrier(int cpu); |
abedf8e2 PG |
443 | static struct swait_queue_head *rcu_nocb_gp_get(struct rcu_node *rnp); |
444 | static void rcu_nocb_gp_cleanup(struct swait_queue_head *sq); | |
dae6e64d | 445 | static void rcu_init_one_nocb(struct rcu_node *rnp); |
3fbfbf7a | 446 | static bool __call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *rhp, |
96d3fd0d | 447 | bool lazy, unsigned long flags); |
b1a2d79f | 448 | static bool rcu_nocb_adopt_orphan_cbs(struct rcu_data *my_rdp, |
96d3fd0d PM |
449 | struct rcu_data *rdp, |
450 | unsigned long flags); | |
9fdd3bc9 | 451 | static int rcu_nocb_need_deferred_wakeup(struct rcu_data *rdp); |
96d3fd0d | 452 | static void do_nocb_deferred_wakeup(struct rcu_data *rdp); |
3fbfbf7a | 453 | static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp); |
35ce7f29 PM |
454 | static void rcu_spawn_all_nocb_kthreads(int cpu); |
455 | static void __init rcu_spawn_nocb_kthreads(void); | |
456 | #ifdef CONFIG_RCU_NOCB_CPU | |
4580b054 | 457 | static void __init rcu_organize_nocb_kthreads(void); |
35ce7f29 | 458 | #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ |
34ed6246 | 459 | static bool init_nocb_callback_list(struct rcu_data *rdp); |
903ee83d | 460 | static unsigned long rcu_get_n_cbs_nocb_cpu(struct rcu_data *rdp); |
eb75767b | 461 | static void rcu_bind_gp_kthread(void); |
4580b054 | 462 | static bool rcu_nohz_full_cpu(void); |
176f8f7a PM |
463 | static void rcu_dynticks_task_enter(void); |
464 | static void rcu_dynticks_task_exit(void); | |
9b2619af | 465 | |
da915ad5 PM |
466 | #ifdef CONFIG_SRCU |
467 | void srcu_online_cpu(unsigned int cpu); | |
468 | void srcu_offline_cpu(unsigned int cpu); | |
469 | #else /* #ifdef CONFIG_SRCU */ | |
470 | void srcu_online_cpu(unsigned int cpu) { } | |
471 | void srcu_offline_cpu(unsigned int cpu) { } | |
472 | #endif /* #else #ifdef CONFIG_SRCU */ |