Merge tag 'for-linus-2023083101' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / kernel / rcu / rcu.h
CommitLineData
b5b11890 1/* SPDX-License-Identifier: GPL-2.0+ */
29c00b4a
PM
2/*
3 * Read-Copy Update definitions shared among RCU implementations.
4 *
29c00b4a
PM
5 * Copyright IBM Corporation, 2011
6 *
b5b11890 7 * Author: Paul E. McKenney <paulmck@linux.ibm.com>
29c00b4a
PM
8 */
9
10#ifndef __LINUX_RCU_H
11#define __LINUX_RCU_H
12
5cb5c6e1 13#include <trace/events/rcu.h>
e99033c5 14
2e8c28c2
PM
15/*
16 * Grace-period counter management.
3636d8d1
FW
17 *
18 * The two least significant bits contain the control flags.
19 * The most significant bits contain the grace-period sequence counter.
20 *
21 * When both control flags are zero, no grace period is in progress.
22 * When either bit is non-zero, a grace period has started and is in
23 * progress. When the grace period completes, the control flags are reset
24 * to 0 and the grace-period sequence counter is incremented.
25 *
26 * However some specific RCU usages make use of custom values.
27 *
28 * SRCU special control values:
29 *
30 * SRCU_SNP_INIT_SEQ : Invalid/init value set when SRCU node
31 * is initialized.
32 *
33 * SRCU_STATE_IDLE : No SRCU gp is in progress
34 *
35 * SRCU_STATE_SCAN1 : State set by rcu_seq_start(). Indicates
36 * we are scanning the readers on the slot
37 * defined as inactive (there might well
38 * be pending readers that will use that
39 * index, but their number is bounded).
40 *
41 * SRCU_STATE_SCAN2 : State set manually via rcu_seq_set_state()
42 * Indicates we are flipping the readers
43 * index and then scanning the readers on the
44 * slot newly designated as inactive (again,
45 * the number of pending readers that will use
46 * this inactive index is bounded).
47 *
48 * RCU polled GP special control value:
49 *
50 * RCU_GET_STATE_COMPLETED : State value indicating an already-completed
51 * polled GP has completed. This value covers
52 * both the state and the counter of the
53 * grace-period sequence number.
2e8c28c2
PM
54 */
55
f1ec57a4 56#define RCU_SEQ_CTR_SHIFT 2
031aeee0
PM
57#define RCU_SEQ_STATE_MASK ((1 << RCU_SEQ_CTR_SHIFT) - 1)
58
414c1238
PM
59/* Low-order bit definition for polled grace-period APIs. */
60#define RCU_GET_STATE_COMPLETED 0x1
61
d9ab0e63
ZN
62extern int sysctl_sched_rt_runtime;
63
031aeee0
PM
64/*
65 * Return the counter portion of a sequence number previously returned
66 * by rcu_seq_snap() or rcu_seq_current().
67 */
68static inline unsigned long rcu_seq_ctr(unsigned long s)
69{
70 return s >> RCU_SEQ_CTR_SHIFT;
71}
72
73/*
74 * Return the state portion of a sequence number previously returned
75 * by rcu_seq_snap() or rcu_seq_current().
76 */
77static inline int rcu_seq_state(unsigned long s)
78{
79 return s & RCU_SEQ_STATE_MASK;
80}
81
80a7956f
PM
82/*
83 * Set the state portion of the pointed-to sequence number.
84 * The caller is responsible for preventing conflicting updates.
85 */
86static inline void rcu_seq_set_state(unsigned long *sp, int newstate)
87{
88 WARN_ON_ONCE(newstate & ~RCU_SEQ_STATE_MASK);
89 WRITE_ONCE(*sp, (*sp & ~RCU_SEQ_STATE_MASK) + newstate);
90}
91
2e8c28c2
PM
92/* Adjust sequence number for start of update-side operation. */
93static inline void rcu_seq_start(unsigned long *sp)
94{
95 WRITE_ONCE(*sp, *sp + 1);
96 smp_mb(); /* Ensure update-side operation after counter increment. */
031aeee0 97 WARN_ON_ONCE(rcu_seq_state(*sp) != 1);
2e8c28c2
PM
98}
99
9a414201
PM
100/* Compute the end-of-grace-period value for the specified sequence number. */
101static inline unsigned long rcu_seq_endval(unsigned long *sp)
102{
103 return (*sp | RCU_SEQ_STATE_MASK) + 1;
104}
105
2e8c28c2
PM
106/* Adjust sequence number for end of update-side operation. */
107static inline void rcu_seq_end(unsigned long *sp)
108{
109 smp_mb(); /* Ensure update-side operation before counter increment. */
031aeee0 110 WARN_ON_ONCE(!rcu_seq_state(*sp));
9a414201 111 WRITE_ONCE(*sp, rcu_seq_endval(sp));
2e8c28c2
PM
112}
113
0d805a70
JFG
114/*
115 * rcu_seq_snap - Take a snapshot of the update side's sequence number.
116 *
117 * This function returns the earliest value of the grace-period sequence number
118 * that will indicate that a full grace period has elapsed since the current
119 * time. Once the grace-period sequence number has reached this value, it will
120 * be safe to invoke all callbacks that have been registered prior to the
121 * current time. This value is the current grace-period number plus two to the
122 * power of the number of low-order bits reserved for state, then rounded up to
123 * the next value in which the state bits are all zero.
124 */
2e8c28c2
PM
125static inline unsigned long rcu_seq_snap(unsigned long *sp)
126{
127 unsigned long s;
128
031aeee0 129 s = (READ_ONCE(*sp) + 2 * RCU_SEQ_STATE_MASK + 1) & ~RCU_SEQ_STATE_MASK;
2e8c28c2
PM
130 smp_mb(); /* Above access must not bleed into critical section. */
131 return s;
132}
133
8660b7d8
PM
134/* Return the current value the update side's sequence number, no ordering. */
135static inline unsigned long rcu_seq_current(unsigned long *sp)
136{
137 return READ_ONCE(*sp);
138}
139
2e3e5e55
PM
140/*
141 * Given a snapshot from rcu_seq_snap(), determine whether or not the
142 * corresponding update-side operation has started.
143 */
144static inline bool rcu_seq_started(unsigned long *sp, unsigned long s)
145{
146 return ULONG_CMP_LT((s - 1) & ~RCU_SEQ_STATE_MASK, READ_ONCE(*sp));
147}
148
2e8c28c2
PM
149/*
150 * Given a snapshot from rcu_seq_snap(), determine whether or not a
151 * full update-side operation has occurred.
152 */
153static inline bool rcu_seq_done(unsigned long *sp, unsigned long s)
154{
155 return ULONG_CMP_GE(READ_ONCE(*sp), s);
156}
157
2403e804
PM
158/*
159 * Given a snapshot from rcu_seq_snap(), determine whether or not a
160 * full update-side operation has occurred, but do not allow the
161 * (ULONG_MAX / 2) safety-factor/guard-band.
162 */
163static inline bool rcu_seq_done_exact(unsigned long *sp, unsigned long s)
164{
165 unsigned long cur_s = READ_ONCE(*sp);
166
167 return ULONG_CMP_GE(cur_s, s) || ULONG_CMP_LT(cur_s, s - (2 * RCU_SEQ_STATE_MASK + 1));
168}
169
67e14c1e
PM
170/*
171 * Has a grace period completed since the time the old gp_seq was collected?
172 */
173static inline bool rcu_seq_completed_gp(unsigned long old, unsigned long new)
174{
175 return ULONG_CMP_LT(old, new & ~RCU_SEQ_STATE_MASK);
176}
177
178/*
179 * Has a grace period started since the time the old gp_seq was collected?
180 */
181static inline bool rcu_seq_new_gp(unsigned long old, unsigned long new)
182{
183 return ULONG_CMP_LT((old + RCU_SEQ_STATE_MASK) & ~RCU_SEQ_STATE_MASK,
184 new);
185}
186
d7219312
PM
187/*
188 * Roughly how many full grace periods have elapsed between the collection
189 * of the two specified grace periods?
190 */
191static inline unsigned long rcu_seq_diff(unsigned long new, unsigned long old)
192{
2ee5aca5
PM
193 unsigned long rnd_diff;
194
195 if (old == new)
196 return 0;
197 /*
198 * Compute the number of grace periods (still shifted up), plus
199 * one if either of new and old is not an exact grace period.
200 */
201 rnd_diff = (new & ~RCU_SEQ_STATE_MASK) -
202 ((old + RCU_SEQ_STATE_MASK) & ~RCU_SEQ_STATE_MASK) +
203 ((new & RCU_SEQ_STATE_MASK) || (old & RCU_SEQ_STATE_MASK));
204 if (ULONG_CMP_GE(RCU_SEQ_STATE_MASK, rnd_diff))
205 return 1; /* Definitely no grace period has elapsed. */
206 return ((rnd_diff - RCU_SEQ_STATE_MASK - 1) >> RCU_SEQ_CTR_SHIFT) + 2;
d7219312
PM
207}
208
29c00b4a
PM
209/*
210 * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally
7f87c036
PM
211 * by call_rcu() and rcu callback execution, and are therefore not part
212 * of the RCU API. These are in rcupdate.h because they are used by all
213 * RCU implementations.
29c00b4a
PM
214 */
215
216#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
217# define STATE_RCU_HEAD_READY 0
218# define STATE_RCU_HEAD_QUEUED 1
219
f9e62f31 220extern const struct debug_obj_descr rcuhead_debug_descr;
29c00b4a 221
ae150184 222static inline int debug_rcu_head_queue(struct rcu_head *head)
29c00b4a 223{
ae150184
PM
224 int r1;
225
226 r1 = debug_object_activate(head, &rcuhead_debug_descr);
29c00b4a
PM
227 debug_object_active_state(head, &rcuhead_debug_descr,
228 STATE_RCU_HEAD_READY,
229 STATE_RCU_HEAD_QUEUED);
ae150184 230 return r1;
29c00b4a
PM
231}
232
233static inline void debug_rcu_head_unqueue(struct rcu_head *head)
234{
235 debug_object_active_state(head, &rcuhead_debug_descr,
236 STATE_RCU_HEAD_QUEUED,
237 STATE_RCU_HEAD_READY);
238 debug_object_deactivate(head, &rcuhead_debug_descr);
239}
240#else /* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
ae150184 241static inline int debug_rcu_head_queue(struct rcu_head *head)
29c00b4a 242{
ae150184 243 return 0;
29c00b4a
PM
244}
245
246static inline void debug_rcu_head_unqueue(struct rcu_head *head)
247{
248}
249#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
250
58c53360
PM
251extern int rcu_cpu_stall_suppress_at_boot;
252
253static inline bool rcu_stall_is_suppressed_at_boot(void)
254{
255 return rcu_cpu_stall_suppress_at_boot && !rcu_inkernel_boot_has_ended();
256}
257
6bfc09e2
PM
258#ifdef CONFIG_RCU_STALL_COMMON
259
cdc694b2 260extern int rcu_cpu_stall_ftrace_dump;
6bfc09e2 261extern int rcu_cpu_stall_suppress;
10462d6f 262extern int rcu_cpu_stall_timeout;
28b3ae42 263extern int rcu_exp_cpu_stall_timeout;
be42f00b 264extern int rcu_cpu_stall_cputime;
92987fe8 265extern bool rcu_exp_stall_task_details __read_mostly;
6bfc09e2 266int rcu_jiffies_till_stall_check(void);
28b3ae42 267int rcu_exp_jiffies_till_stall_check(void);
6bfc09e2 268
58c53360
PM
269static inline bool rcu_stall_is_suppressed(void)
270{
271 return rcu_stall_is_suppressed_at_boot() || rcu_cpu_stall_suppress;
272}
273
f22ce091
PM
274#define rcu_ftrace_dump_stall_suppress() \
275do { \
276 if (!rcu_cpu_stall_suppress) \
277 rcu_cpu_stall_suppress = 3; \
278} while (0)
279
280#define rcu_ftrace_dump_stall_unsuppress() \
281do { \
282 if (rcu_cpu_stall_suppress == 3) \
283 rcu_cpu_stall_suppress = 0; \
284} while (0)
285
286#else /* #endif #ifdef CONFIG_RCU_STALL_COMMON */
58c53360
PM
287
288static inline bool rcu_stall_is_suppressed(void)
289{
290 return rcu_stall_is_suppressed_at_boot();
291}
f22ce091
PM
292#define rcu_ftrace_dump_stall_suppress()
293#define rcu_ftrace_dump_stall_unsuppress()
6bfc09e2
PM
294#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
295
0d752924
PM
296/*
297 * Strings used in tracepoints need to be exported via the
298 * tracing system such that tools like perf and trace-cmd can
299 * translate the string address pointers to actual text.
300 */
301#define TPS(x) tracepoint_string(x)
302
b8989b76
PM
303/*
304 * Dump the ftrace buffer, but only one time per callsite per boot.
305 */
306#define rcu_ftrace_dump(oops_dump_mode) \
307do { \
308 static atomic_t ___rfd_beenhere = ATOMIC_INIT(0); \
309 \
310 if (!atomic_read(&___rfd_beenhere) && \
83b6ca1f
PM
311 !atomic_xchg(&___rfd_beenhere, 1)) { \
312 tracing_off(); \
f22ce091 313 rcu_ftrace_dump_stall_suppress(); \
b8989b76 314 ftrace_dump(oops_dump_mode); \
f22ce091 315 rcu_ftrace_dump_stall_unsuppress(); \
83b6ca1f 316 } \
b8989b76
PM
317} while (0)
318
aa23c6fb 319void rcu_early_boot_tests(void);
52d7e48b 320void rcu_test_sync_prims(void);
aa23c6fb 321
5f6130fa
LJ
322/*
323 * This function really isn't for public consumption, but RCU is special in
324 * that context switches can allow the state machine to make progress.
325 */
326extern void resched_cpu(int cpu);
327
0cd7e350 328#if !defined(CONFIG_TINY_RCU)
2b34c43c
PM
329
330#include <linux/rcu_node_tree.h>
331
332extern int rcu_num_lvls;
e95d68d2 333extern int num_rcu_lvl[];
2b34c43c
PM
334extern int rcu_num_nodes;
335static bool rcu_fanout_exact;
336static int rcu_fanout_leaf;
337
338/*
339 * Compute the per-level fanout, either using the exact fanout specified
340 * or balancing the tree, depending on the rcu_fanout_exact boot parameter.
341 */
342static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
343{
344 int i;
345
36b5dae6
PM
346 for (i = 0; i < RCU_NUM_LVLS; i++)
347 levelspread[i] = INT_MIN;
2b34c43c
PM
348 if (rcu_fanout_exact) {
349 levelspread[rcu_num_lvls - 1] = rcu_fanout_leaf;
350 for (i = rcu_num_lvls - 2; i >= 0; i--)
351 levelspread[i] = RCU_FANOUT;
352 } else {
353 int ccur;
354 int cprv;
355
356 cprv = nr_cpu_ids;
357 for (i = rcu_num_lvls - 1; i >= 0; i--) {
358 ccur = levelcnt[i];
359 levelspread[i] = (cprv + ccur - 1) / ccur;
360 cprv = ccur;
361 }
362 }
363}
364
b5befe84
FW
365extern void rcu_init_geometry(void);
366
7f87c036 367/* Returns a pointer to the first leaf rcu_node structure. */
aedf4ba9 368#define rcu_first_leaf_node() (rcu_state.level[rcu_num_lvls - 1])
5b4c11d5
PM
369
370/* Is this rcu_node a leaf? */
371#define rcu_is_leaf_node(rnp) ((rnp)->level == rcu_num_lvls - 1)
372
5257514d 373/* Is this rcu_node the last leaf? */
aedf4ba9 374#define rcu_is_last_leaf_node(rnp) ((rnp) == &rcu_state.node[rcu_num_nodes - 1])
5257514d 375
efbe451d 376/*
aedf4ba9 377 * Do a full breadth-first scan of the {s,}rcu_node structures for the
7f87c036
PM
378 * specified state structure (for SRCU) or the only rcu_state structure
379 * (for RCU).
efbe451d 380 */
95433f72 381#define _rcu_for_each_node_breadth_first(sp, rnp) \
aedf4ba9
PM
382 for ((rnp) = &(sp)->node[0]; \
383 (rnp) < &(sp)->node[rcu_num_nodes]; (rnp)++)
384#define rcu_for_each_node_breadth_first(rnp) \
95433f72
PM
385 _rcu_for_each_node_breadth_first(&rcu_state, rnp)
386#define srcu_for_each_node_breadth_first(ssp, rnp) \
387 _rcu_for_each_node_breadth_first(ssp->srcu_sup, rnp)
efbe451d
PM
388
389/*
7f87c036
PM
390 * Scan the leaves of the rcu_node hierarchy for the rcu_state structure.
391 * Note that if there is a singleton rcu_node tree with but one rcu_node
392 * structure, this loop -will- visit the rcu_node structure. It is still
393 * a leaf node, even if it is also the root node.
efbe451d 394 */
aedf4ba9
PM
395#define rcu_for_each_leaf_node(rnp) \
396 for ((rnp) = rcu_first_leaf_node(); \
397 (rnp) < &rcu_state.node[rcu_num_nodes]; (rnp)++)
efbe451d
PM
398
399/*
400 * Iterate over all possible CPUs in a leaf RCU node.
401 */
402#define for_each_leaf_node_possible_cpu(rnp, cpu) \
82dd8419
PM
403 for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
404 (cpu) = cpumask_next((rnp)->grplo - 1, cpu_possible_mask); \
65963d24
PM
405 (cpu) <= rnp->grphi; \
406 (cpu) = cpumask_next((cpu), cpu_possible_mask))
407
408/*
409 * Iterate over all CPUs in a leaf RCU node's specified mask.
410 */
411#define rcu_find_next_bit(rnp, cpu, mask) \
412 ((rnp)->grplo + find_next_bit(&(mask), BITS_PER_LONG, (cpu)))
413#define for_each_leaf_node_cpu_mask(rnp, cpu, mask) \
82dd8419
PM
414 for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
415 (cpu) = rcu_find_next_bit((rnp), 0, (mask)); \
65963d24
PM
416 (cpu) <= rnp->grphi; \
417 (cpu) = rcu_find_next_bit((rnp), (cpu) + 1 - (rnp->grplo), (mask)))
efbe451d 418
0cd7e350
PM
419#endif /* !defined(CONFIG_TINY_RCU) */
420
421#if !defined(CONFIG_TINY_RCU) || defined(CONFIG_TASKS_RCU_GENERIC)
422
83d40bd3
PM
423/*
424 * Wrappers for the rcu_node::lock acquire and release.
425 *
426 * Because the rcu_nodes form a tree, the tree traversal locking will observe
427 * different lock values, this in turn means that an UNLOCK of one level
428 * followed by a LOCK of another level does not imply a full memory barrier;
429 * and most importantly transitivity is lost.
430 *
431 * In order to restore full ordering between tree levels, augment the regular
432 * lock acquire functions with smp_mb__after_unlock_lock().
433 *
434 * As ->lock of struct rcu_node is a __private field, therefore one should use
435 * these wrappers rather than directly call raw_spin_{lock,unlock}* on ->lock.
436 */
437#define raw_spin_lock_rcu_node(p) \
438do { \
439 raw_spin_lock(&ACCESS_PRIVATE(p, lock)); \
440 smp_mb__after_unlock_lock(); \
441} while (0)
442
7dffe017
PM
443#define raw_spin_unlock_rcu_node(p) \
444do { \
445 lockdep_assert_irqs_disabled(); \
446 raw_spin_unlock(&ACCESS_PRIVATE(p, lock)); \
447} while (0)
83d40bd3
PM
448
449#define raw_spin_lock_irq_rcu_node(p) \
450do { \
451 raw_spin_lock_irq(&ACCESS_PRIVATE(p, lock)); \
452 smp_mb__after_unlock_lock(); \
453} while (0)
454
455#define raw_spin_unlock_irq_rcu_node(p) \
7dffe017
PM
456do { \
457 lockdep_assert_irqs_disabled(); \
458 raw_spin_unlock_irq(&ACCESS_PRIVATE(p, lock)); \
459} while (0)
83d40bd3 460
4e4bea74 461#define raw_spin_lock_irqsave_rcu_node(p, flags) \
83d40bd3 462do { \
4e4bea74 463 raw_spin_lock_irqsave(&ACCESS_PRIVATE(p, lock), flags); \
83d40bd3
PM
464 smp_mb__after_unlock_lock(); \
465} while (0)
466
4e4bea74 467#define raw_spin_unlock_irqrestore_rcu_node(p, flags) \
7dffe017
PM
468do { \
469 lockdep_assert_irqs_disabled(); \
470 raw_spin_unlock_irqrestore(&ACCESS_PRIVATE(p, lock), flags); \
471} while (0)
83d40bd3
PM
472
473#define raw_spin_trylock_rcu_node(p) \
474({ \
475 bool ___locked = raw_spin_trylock(&ACCESS_PRIVATE(p, lock)); \
476 \
477 if (___locked) \
478 smp_mb__after_unlock_lock(); \
479 ___locked; \
480})
481
a32e01ee
MW
482#define raw_lockdep_assert_held_rcu_node(p) \
483 lockdep_assert_held(&ACCESS_PRIVATE(p, lock))
484
0cd7e350 485#endif // #if !defined(CONFIG_TINY_RCU) || defined(CONFIG_TASKS_RCU_GENERIC)
2b34c43c 486
25c36329
PM
487#ifdef CONFIG_TINY_RCU
488/* Tiny RCU doesn't expedite, as its purpose in life is instead to be tiny. */
7414fac0
PM
489static inline bool rcu_gp_is_normal(void) { return true; }
490static inline bool rcu_gp_is_expedited(void) { return false; }
6efdda8b 491static inline bool rcu_async_should_hurry(void) { return false; }
7414fac0
PM
492static inline void rcu_expedite_gp(void) { }
493static inline void rcu_unexpedite_gp(void) { }
6efdda8b
JFG
494static inline void rcu_async_hurry(void) { }
495static inline void rcu_async_relax(void) { }
25c36329
PM
496#else /* #ifdef CONFIG_TINY_RCU */
497bool rcu_gp_is_normal(void); /* Internal RCU use. */
498bool rcu_gp_is_expedited(void); /* Internal RCU use. */
6efdda8b 499bool rcu_async_should_hurry(void); /* Internal RCU use. */
25c36329
PM
500void rcu_expedite_gp(void);
501void rcu_unexpedite_gp(void);
6efdda8b
JFG
502void rcu_async_hurry(void);
503void rcu_async_relax(void);
25c36329 504void rcupdate_announce_bootup_oddness(void);
474d0997 505#ifdef CONFIG_TASKS_RCU_GENERIC
e21408ce 506void show_rcu_tasks_gp_kthreads(void);
474d0997
PM
507#else /* #ifdef CONFIG_TASKS_RCU_GENERIC */
508static inline void show_rcu_tasks_gp_kthreads(void) {}
509#endif /* #else #ifdef CONFIG_TASKS_RCU_GENERIC */
25c36329
PM
510#endif /* #else #ifdef CONFIG_TINY_RCU */
511
e0a34641
AB
512#ifdef CONFIG_TASKS_RCU
513struct task_struct *get_rcu_tasks_gp_kthread(void);
514#endif // # ifdef CONFIG_TASKS_RCU
515
516#ifdef CONFIG_TASKS_RUDE_RCU
517struct task_struct *get_rcu_tasks_rude_gp_kthread(void);
518#endif // # ifdef CONFIG_TASKS_RUDE_RCU
519
82118249
PM
520#define RCU_SCHEDULER_INACTIVE 0
521#define RCU_SCHEDULER_INIT 1
522#define RCU_SCHEDULER_RUNNING 2
523
cad7b389
PM
524enum rcutorture_type {
525 RCU_FLAVOR,
cad7b389 526 RCU_TASKS_FLAVOR,
3d6e43c7 527 RCU_TASKS_RUDE_FLAVOR,
c1a76c0b 528 RCU_TASKS_TRACING_FLAVOR,
c682db55 529 RCU_TRIVIAL_FLAVOR,
cad7b389
PM
530 SRCU_FLAVOR,
531 INVALID_RCU_FLAVOR
532};
533
3cb278e7
JFG
534#if defined(CONFIG_RCU_LAZY)
535unsigned long rcu_lazy_get_jiffies_till_flush(void);
536void rcu_lazy_set_jiffies_till_flush(unsigned long j);
537#else
538static inline unsigned long rcu_lazy_get_jiffies_till_flush(void) { return 0; }
539static inline void rcu_lazy_set_jiffies_till_flush(unsigned long j) { }
540#endif
541
b3e627d3 542#if defined(CONFIG_TREE_RCU)
cad7b389 543void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
aebc8264 544 unsigned long *gp_seq);
cad7b389
PM
545void do_trace_rcu_torture_read(const char *rcutorturename,
546 struct rcu_head *rhp,
547 unsigned long secs,
548 unsigned long c_old,
549 unsigned long c);
55b2dcf5 550void rcu_gp_set_torture_wait(int duration);
cad7b389
PM
551#else
552static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
aebc8264 553 int *flags, unsigned long *gp_seq)
cad7b389
PM
554{
555 *flags = 0;
aebc8264 556 *gp_seq = 0;
cad7b389 557}
cad7b389
PM
558#ifdef CONFIG_RCU_TRACE
559void do_trace_rcu_torture_read(const char *rcutorturename,
560 struct rcu_head *rhp,
561 unsigned long secs,
562 unsigned long c_old,
563 unsigned long c);
564#else
565#define do_trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
566 do { } while (0)
567#endif
55b2dcf5 568static inline void rcu_gp_set_torture_wait(int duration) { }
cad7b389
PM
569#endif
570
c682db55
PM
571#if IS_ENABLED(CONFIG_RCU_TORTURE_TEST) || IS_MODULE(CONFIG_RCU_TORTURE_TEST)
572long rcutorture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask);
573#endif
574
cad7b389
PM
575#ifdef CONFIG_TINY_SRCU
576
577static inline void srcutorture_get_gp_data(enum rcutorture_type test_type,
578 struct srcu_struct *sp, int *flags,
aebc8264 579 unsigned long *gp_seq)
cad7b389
PM
580{
581 if (test_type != SRCU_FLAVOR)
582 return;
583 *flags = 0;
aebc8264 584 *gp_seq = sp->srcu_idx;
cad7b389
PM
585}
586
587#elif defined(CONFIG_TREE_SRCU)
588
589void srcutorture_get_gp_data(enum rcutorture_type test_type,
590 struct srcu_struct *sp, int *flags,
aebc8264 591 unsigned long *gp_seq);
cad7b389 592
cad7b389
PM
593#endif
594
e3c8d51e 595#ifdef CONFIG_TINY_RCU
7d0c9c50 596static inline bool rcu_dynticks_zero_in_eqs(int cpu, int *vp) { return false; }
17ef2fe9 597static inline unsigned long rcu_get_gp_seq(void) { return 0; }
7414fac0 598static inline unsigned long rcu_exp_batches_completed(void) { return 0; }
7414fac0
PM
599static inline unsigned long
600srcu_batches_completed(struct srcu_struct *sp) { return 0; }
601static inline void rcu_force_quiescent_state(void) { }
0260b92e 602static inline bool rcu_check_boost_fail(unsigned long gp_state, int *cpup) { return true; }
7414fac0 603static inline void show_rcu_gp_kthreads(void) { }
4babd855 604static inline int rcu_get_gp_kthreads_prio(void) { return 0; }
e0aff973 605static inline void rcu_fwd_progress_check(unsigned long j) { }
99d6a2ac
PM
606static inline void rcu_gp_slow_register(atomic_t *rgssp) { }
607static inline void rcu_gp_slow_unregister(atomic_t *rgssp) { }
e3c8d51e 608#else /* #ifdef CONFIG_TINY_RCU */
7d0c9c50 609bool rcu_dynticks_zero_in_eqs(int cpu, int *vp);
17ef2fe9 610unsigned long rcu_get_gp_seq(void);
e3c8d51e 611unsigned long rcu_exp_batches_completed(void);
5a0465e1 612unsigned long srcu_batches_completed(struct srcu_struct *sp);
0260b92e 613bool rcu_check_boost_fail(unsigned long gp_state, int *cpup);
e3c8d51e 614void show_rcu_gp_kthreads(void);
4babd855 615int rcu_get_gp_kthreads_prio(void);
e0aff973 616void rcu_fwd_progress_check(unsigned long j);
e3c8d51e 617void rcu_force_quiescent_state(void);
ad7c946b 618extern struct workqueue_struct *rcu_gp_wq;
9621fbee
KS
619#ifdef CONFIG_RCU_EXP_KTHREAD
620extern struct kthread_worker *rcu_exp_gp_kworker;
621extern struct kthread_worker *rcu_exp_par_gp_kworker;
622#else /* !CONFIG_RCU_EXP_KTHREAD */
25f3d7ef 623extern struct workqueue_struct *rcu_par_gp_wq;
9621fbee 624#endif /* CONFIG_RCU_EXP_KTHREAD */
99d6a2ac
PM
625void rcu_gp_slow_register(atomic_t *rgssp);
626void rcu_gp_slow_unregister(atomic_t *rgssp);
e3c8d51e
PM
627#endif /* #else #ifdef CONFIG_TINY_RCU */
628
44c65ff2 629#ifdef CONFIG_RCU_NOCB_CPU
5ab7ab83 630void rcu_bind_current_to_nocb(void);
3d54f798 631#else
5ab7ab83 632static inline void rcu_bind_current_to_nocb(void) { }
3d54f798
PM
633#endif
634
27c0f144
PM
635#if !defined(CONFIG_TINY_RCU) && defined(CONFIG_TASKS_RCU)
636void show_rcu_tasks_classic_gp_kthread(void);
637#else
638static inline void show_rcu_tasks_classic_gp_kthread(void) {}
639#endif
640#if !defined(CONFIG_TINY_RCU) && defined(CONFIG_TASKS_RUDE_RCU)
641void show_rcu_tasks_rude_gp_kthread(void);
642#else
643static inline void show_rcu_tasks_rude_gp_kthread(void) {}
644#endif
645#if !defined(CONFIG_TINY_RCU) && defined(CONFIG_TASKS_TRACE_RCU)
646void show_rcu_tasks_trace_gp_kthread(void);
647#else
648static inline void show_rcu_tasks_trace_gp_kthread(void) {}
649#endif
650
401b0de3
PM
651#ifdef CONFIG_TINY_RCU
652static inline bool rcu_cpu_beenfullyonline(int cpu) { return true; }
653#else
654bool rcu_cpu_beenfullyonline(int cpu);
655#endif
656
29c00b4a 657#endif /* __LINUX_RCU_H */