xref: /openbmc/linux/kernel/rcu/rcu.h (revision e0a34641eb551e3c51e1588ef7874f2de2844a06)
1b5b11890SPaul E. McKenney /* SPDX-License-Identifier: GPL-2.0+ */
24102adabSPaul E. McKenney /*
34102adabSPaul E. McKenney  * Read-Copy Update definitions shared among RCU implementations.
44102adabSPaul E. McKenney  *
54102adabSPaul E. McKenney  * Copyright IBM Corporation, 2011
64102adabSPaul E. McKenney  *
7b5b11890SPaul E. McKenney  * Author: Paul E. McKenney <paulmck@linux.ibm.com>
84102adabSPaul E. McKenney  */
94102adabSPaul E. McKenney 
104102adabSPaul E. McKenney #ifndef __LINUX_RCU_H
114102adabSPaul E. McKenney #define __LINUX_RCU_H
124102adabSPaul E. McKenney 
135cb5c6e1SPaul Gortmaker #include <trace/events/rcu.h>
144102adabSPaul E. McKenney 
152e8c28c2SPaul E. McKenney /*
162e8c28c2SPaul E. McKenney  * Grace-period counter management.
173636d8d1SFrederic Weisbecker  *
183636d8d1SFrederic Weisbecker  * The two least significant bits contain the control flags.
193636d8d1SFrederic Weisbecker  * The most significant bits contain the grace-period sequence counter.
203636d8d1SFrederic Weisbecker  *
213636d8d1SFrederic Weisbecker  * When both control flags are zero, no grace period is in progress.
223636d8d1SFrederic Weisbecker  * When either bit is non-zero, a grace period has started and is in
233636d8d1SFrederic Weisbecker  * progress. When the grace period completes, the control flags are reset
243636d8d1SFrederic Weisbecker  * to 0 and the grace-period sequence counter is incremented.
253636d8d1SFrederic Weisbecker  *
263636d8d1SFrederic Weisbecker  * However some specific RCU usages make use of custom values.
273636d8d1SFrederic Weisbecker  *
283636d8d1SFrederic Weisbecker  * SRCU special control values:
293636d8d1SFrederic Weisbecker  *
303636d8d1SFrederic Weisbecker  *	SRCU_SNP_INIT_SEQ	:	Invalid/init value set when SRCU node
313636d8d1SFrederic Weisbecker  *					is initialized.
323636d8d1SFrederic Weisbecker  *
333636d8d1SFrederic Weisbecker  *	SRCU_STATE_IDLE		:	No SRCU gp is in progress
343636d8d1SFrederic Weisbecker  *
353636d8d1SFrederic Weisbecker  *	SRCU_STATE_SCAN1	:	State set by rcu_seq_start(). Indicates
363636d8d1SFrederic Weisbecker  *					we are scanning the readers on the slot
373636d8d1SFrederic Weisbecker  *					defined as inactive (there might well
383636d8d1SFrederic Weisbecker  *					be pending readers that will use that
393636d8d1SFrederic Weisbecker  *					index, but their number is bounded).
403636d8d1SFrederic Weisbecker  *
413636d8d1SFrederic Weisbecker  *	SRCU_STATE_SCAN2	:	State set manually via rcu_seq_set_state()
423636d8d1SFrederic Weisbecker  *					Indicates we are flipping the readers
433636d8d1SFrederic Weisbecker  *					index and then scanning the readers on the
443636d8d1SFrederic Weisbecker  *					slot newly designated as inactive (again,
453636d8d1SFrederic Weisbecker  *					the number of pending readers that will use
463636d8d1SFrederic Weisbecker  *					this inactive index is bounded).
473636d8d1SFrederic Weisbecker  *
483636d8d1SFrederic Weisbecker  * RCU polled GP special control value:
493636d8d1SFrederic Weisbecker  *
503636d8d1SFrederic Weisbecker  *	RCU_GET_STATE_COMPLETED :	State value indicating an already-completed
513636d8d1SFrederic Weisbecker  *					polled GP has completed.  This value covers
523636d8d1SFrederic Weisbecker  *					both the state and the counter of the
533636d8d1SFrederic Weisbecker  *					grace-period sequence number.
542e8c28c2SPaul E. McKenney  */
552e8c28c2SPaul E. McKenney 
56f1ec57a4SPaul E. McKenney #define RCU_SEQ_CTR_SHIFT	2
57031aeee0SPaul E. McKenney #define RCU_SEQ_STATE_MASK	((1 << RCU_SEQ_CTR_SHIFT) - 1)
58031aeee0SPaul E. McKenney 
59414c1238SPaul E. McKenney /* Low-order bit definition for polled grace-period APIs. */
60414c1238SPaul E. McKenney #define RCU_GET_STATE_COMPLETED	0x1
61414c1238SPaul E. McKenney 
62d9ab0e63SZhen Ni extern int sysctl_sched_rt_runtime;
63d9ab0e63SZhen Ni 
64031aeee0SPaul E. McKenney /*
65031aeee0SPaul E. McKenney  * Return the counter portion of a sequence number previously returned
66031aeee0SPaul E. McKenney  * by rcu_seq_snap() or rcu_seq_current().
67031aeee0SPaul E. McKenney  */
68031aeee0SPaul E. McKenney static inline unsigned long rcu_seq_ctr(unsigned long s)
69031aeee0SPaul E. McKenney {
70031aeee0SPaul E. McKenney 	return s >> RCU_SEQ_CTR_SHIFT;
71031aeee0SPaul E. McKenney }
72031aeee0SPaul E. McKenney 
73031aeee0SPaul E. McKenney /*
74031aeee0SPaul E. McKenney  * Return the state portion of a sequence number previously returned
75031aeee0SPaul E. McKenney  * by rcu_seq_snap() or rcu_seq_current().
76031aeee0SPaul E. McKenney  */
77031aeee0SPaul E. McKenney static inline int rcu_seq_state(unsigned long s)
78031aeee0SPaul E. McKenney {
79031aeee0SPaul E. McKenney 	return s & RCU_SEQ_STATE_MASK;
80031aeee0SPaul E. McKenney }
81031aeee0SPaul E. McKenney 
8280a7956fSPaul E. McKenney /*
8380a7956fSPaul E. McKenney  * Set the state portion of the pointed-to sequence number.
8480a7956fSPaul E. McKenney  * The caller is responsible for preventing conflicting updates.
8580a7956fSPaul E. McKenney  */
8680a7956fSPaul E. McKenney static inline void rcu_seq_set_state(unsigned long *sp, int newstate)
8780a7956fSPaul E. McKenney {
8880a7956fSPaul E. McKenney 	WARN_ON_ONCE(newstate & ~RCU_SEQ_STATE_MASK);
8980a7956fSPaul E. McKenney 	WRITE_ONCE(*sp, (*sp & ~RCU_SEQ_STATE_MASK) + newstate);
9080a7956fSPaul E. McKenney }
9180a7956fSPaul E. McKenney 
922e8c28c2SPaul E. McKenney /* Adjust sequence number for start of update-side operation. */
932e8c28c2SPaul E. McKenney static inline void rcu_seq_start(unsigned long *sp)
942e8c28c2SPaul E. McKenney {
952e8c28c2SPaul E. McKenney 	WRITE_ONCE(*sp, *sp + 1);
962e8c28c2SPaul E. McKenney 	smp_mb(); /* Ensure update-side operation after counter increment. */
97031aeee0SPaul E. McKenney 	WARN_ON_ONCE(rcu_seq_state(*sp) != 1);
982e8c28c2SPaul E. McKenney }
992e8c28c2SPaul E. McKenney 
1009a414201SPaul E. McKenney /* Compute the end-of-grace-period value for the specified sequence number. */
1019a414201SPaul E. McKenney static inline unsigned long rcu_seq_endval(unsigned long *sp)
1029a414201SPaul E. McKenney {
1039a414201SPaul E. McKenney 	return (*sp | RCU_SEQ_STATE_MASK) + 1;
1049a414201SPaul E. McKenney }
1059a414201SPaul E. McKenney 
1062e8c28c2SPaul E. McKenney /* Adjust sequence number for end of update-side operation. */
1072e8c28c2SPaul E. McKenney static inline void rcu_seq_end(unsigned long *sp)
1082e8c28c2SPaul E. McKenney {
1092e8c28c2SPaul E. McKenney 	smp_mb(); /* Ensure update-side operation before counter increment. */
110031aeee0SPaul E. McKenney 	WARN_ON_ONCE(!rcu_seq_state(*sp));
1119a414201SPaul E. McKenney 	WRITE_ONCE(*sp, rcu_seq_endval(sp));
1122e8c28c2SPaul E. McKenney }
1132e8c28c2SPaul E. McKenney 
1140d805a70SJoel Fernandes (Google) /*
1150d805a70SJoel Fernandes (Google)  * rcu_seq_snap - Take a snapshot of the update side's sequence number.
1160d805a70SJoel Fernandes (Google)  *
1170d805a70SJoel Fernandes (Google)  * This function returns the earliest value of the grace-period sequence number
1180d805a70SJoel Fernandes (Google)  * that will indicate that a full grace period has elapsed since the current
1190d805a70SJoel Fernandes (Google)  * time.  Once the grace-period sequence number has reached this value, it will
1200d805a70SJoel Fernandes (Google)  * be safe to invoke all callbacks that have been registered prior to the
1210d805a70SJoel Fernandes (Google)  * current time. This value is the current grace-period number plus two to the
1220d805a70SJoel Fernandes (Google)  * power of the number of low-order bits reserved for state, then rounded up to
1230d805a70SJoel Fernandes (Google)  * the next value in which the state bits are all zero.
1240d805a70SJoel Fernandes (Google)  */
1252e8c28c2SPaul E. McKenney static inline unsigned long rcu_seq_snap(unsigned long *sp)
1262e8c28c2SPaul E. McKenney {
1272e8c28c2SPaul E. McKenney 	unsigned long s;
1282e8c28c2SPaul E. McKenney 
129031aeee0SPaul E. McKenney 	s = (READ_ONCE(*sp) + 2 * RCU_SEQ_STATE_MASK + 1) & ~RCU_SEQ_STATE_MASK;
1302e8c28c2SPaul E. McKenney 	smp_mb(); /* Above access must not bleed into critical section. */
1312e8c28c2SPaul E. McKenney 	return s;
1322e8c28c2SPaul E. McKenney }
1332e8c28c2SPaul E. McKenney 
1348660b7d8SPaul E. McKenney /* Return the current value the update side's sequence number, no ordering. */
1358660b7d8SPaul E. McKenney static inline unsigned long rcu_seq_current(unsigned long *sp)
1368660b7d8SPaul E. McKenney {
1378660b7d8SPaul E. McKenney 	return READ_ONCE(*sp);
1388660b7d8SPaul E. McKenney }
1398660b7d8SPaul E. McKenney 
1402e8c28c2SPaul E. McKenney /*
1412e3e5e55SPaul E. McKenney  * Given a snapshot from rcu_seq_snap(), determine whether or not the
1422e3e5e55SPaul E. McKenney  * corresponding update-side operation has started.
1432e3e5e55SPaul E. McKenney  */
1442e3e5e55SPaul E. McKenney static inline bool rcu_seq_started(unsigned long *sp, unsigned long s)
1452e3e5e55SPaul E. McKenney {
1462e3e5e55SPaul E. McKenney 	return ULONG_CMP_LT((s - 1) & ~RCU_SEQ_STATE_MASK, READ_ONCE(*sp));
1472e3e5e55SPaul E. McKenney }
1482e3e5e55SPaul E. McKenney 
1492e3e5e55SPaul E. McKenney /*
1502e8c28c2SPaul E. McKenney  * Given a snapshot from rcu_seq_snap(), determine whether or not a
1512e8c28c2SPaul E. McKenney  * full update-side operation has occurred.
1522e8c28c2SPaul E. McKenney  */
1532e8c28c2SPaul E. McKenney static inline bool rcu_seq_done(unsigned long *sp, unsigned long s)
1542e8c28c2SPaul E. McKenney {
1552e8c28c2SPaul E. McKenney 	return ULONG_CMP_GE(READ_ONCE(*sp), s);
1562e8c28c2SPaul E. McKenney }
1572e8c28c2SPaul E. McKenney 
1584102adabSPaul E. McKenney /*
1592403e804SPaul E. McKenney  * Given a snapshot from rcu_seq_snap(), determine whether or not a
1602403e804SPaul E. McKenney  * full update-side operation has occurred, but do not allow the
1612403e804SPaul E. McKenney  * (ULONG_MAX / 2) safety-factor/guard-band.
1622403e804SPaul E. McKenney  */
1632403e804SPaul E. McKenney static inline bool rcu_seq_done_exact(unsigned long *sp, unsigned long s)
1642403e804SPaul E. McKenney {
1652403e804SPaul E. McKenney 	unsigned long cur_s = READ_ONCE(*sp);
1662403e804SPaul E. McKenney 
1672403e804SPaul E. McKenney 	return ULONG_CMP_GE(cur_s, s) || ULONG_CMP_LT(cur_s, s - (2 * RCU_SEQ_STATE_MASK + 1));
1682403e804SPaul E. McKenney }
1692403e804SPaul E. McKenney 
1702403e804SPaul E. McKenney /*
17167e14c1eSPaul E. McKenney  * Has a grace period completed since the time the old gp_seq was collected?
17267e14c1eSPaul E. McKenney  */
17367e14c1eSPaul E. McKenney static inline bool rcu_seq_completed_gp(unsigned long old, unsigned long new)
17467e14c1eSPaul E. McKenney {
17567e14c1eSPaul E. McKenney 	return ULONG_CMP_LT(old, new & ~RCU_SEQ_STATE_MASK);
17667e14c1eSPaul E. McKenney }
17767e14c1eSPaul E. McKenney 
17867e14c1eSPaul E. McKenney /*
17967e14c1eSPaul E. McKenney  * Has a grace period started since the time the old gp_seq was collected?
18067e14c1eSPaul E. McKenney  */
18167e14c1eSPaul E. McKenney static inline bool rcu_seq_new_gp(unsigned long old, unsigned long new)
18267e14c1eSPaul E. McKenney {
18367e14c1eSPaul E. McKenney 	return ULONG_CMP_LT((old + RCU_SEQ_STATE_MASK) & ~RCU_SEQ_STATE_MASK,
18467e14c1eSPaul E. McKenney 			    new);
18567e14c1eSPaul E. McKenney }
18667e14c1eSPaul E. McKenney 
18767e14c1eSPaul E. McKenney /*
188d7219312SPaul E. McKenney  * Roughly how many full grace periods have elapsed between the collection
189d7219312SPaul E. McKenney  * of the two specified grace periods?
190d7219312SPaul E. McKenney  */
191d7219312SPaul E. McKenney static inline unsigned long rcu_seq_diff(unsigned long new, unsigned long old)
192d7219312SPaul E. McKenney {
1932ee5aca5SPaul E. McKenney 	unsigned long rnd_diff;
1942ee5aca5SPaul E. McKenney 
1952ee5aca5SPaul E. McKenney 	if (old == new)
1962ee5aca5SPaul E. McKenney 		return 0;
1972ee5aca5SPaul E. McKenney 	/*
1982ee5aca5SPaul E. McKenney 	 * Compute the number of grace periods (still shifted up), plus
1992ee5aca5SPaul E. McKenney 	 * one if either of new and old is not an exact grace period.
2002ee5aca5SPaul E. McKenney 	 */
2012ee5aca5SPaul E. McKenney 	rnd_diff = (new & ~RCU_SEQ_STATE_MASK) -
2022ee5aca5SPaul E. McKenney 		   ((old + RCU_SEQ_STATE_MASK) & ~RCU_SEQ_STATE_MASK) +
2032ee5aca5SPaul E. McKenney 		   ((new & RCU_SEQ_STATE_MASK) || (old & RCU_SEQ_STATE_MASK));
2042ee5aca5SPaul E. McKenney 	if (ULONG_CMP_GE(RCU_SEQ_STATE_MASK, rnd_diff))
2052ee5aca5SPaul E. McKenney 		return 1; /* Definitely no grace period has elapsed. */
2062ee5aca5SPaul E. McKenney 	return ((rnd_diff - RCU_SEQ_STATE_MASK - 1) >> RCU_SEQ_CTR_SHIFT) + 2;
207d7219312SPaul E. McKenney }
208d7219312SPaul E. McKenney 
209d7219312SPaul E. McKenney /*
2104102adabSPaul E. McKenney  * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally
2117f87c036SPaul E. McKenney  * by call_rcu() and rcu callback execution, and are therefore not part
2127f87c036SPaul E. McKenney  * of the RCU API. These are in rcupdate.h because they are used by all
2137f87c036SPaul E. McKenney  * RCU implementations.
2144102adabSPaul E. McKenney  */
2154102adabSPaul E. McKenney 
2164102adabSPaul E. McKenney #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
2174102adabSPaul E. McKenney # define STATE_RCU_HEAD_READY	0
2184102adabSPaul E. McKenney # define STATE_RCU_HEAD_QUEUED	1
2194102adabSPaul E. McKenney 
220f9e62f31SStephen Boyd extern const struct debug_obj_descr rcuhead_debug_descr;
2214102adabSPaul E. McKenney 
2224102adabSPaul E. McKenney static inline int debug_rcu_head_queue(struct rcu_head *head)
2234102adabSPaul E. McKenney {
2244102adabSPaul E. McKenney 	int r1;
2254102adabSPaul E. McKenney 
2264102adabSPaul E. McKenney 	r1 = debug_object_activate(head, &rcuhead_debug_descr);
2274102adabSPaul E. McKenney 	debug_object_active_state(head, &rcuhead_debug_descr,
2284102adabSPaul E. McKenney 				  STATE_RCU_HEAD_READY,
2294102adabSPaul E. McKenney 				  STATE_RCU_HEAD_QUEUED);
2304102adabSPaul E. McKenney 	return r1;
2314102adabSPaul E. McKenney }
2324102adabSPaul E. McKenney 
2334102adabSPaul E. McKenney static inline void debug_rcu_head_unqueue(struct rcu_head *head)
2344102adabSPaul E. McKenney {
2354102adabSPaul E. McKenney 	debug_object_active_state(head, &rcuhead_debug_descr,
2364102adabSPaul E. McKenney 				  STATE_RCU_HEAD_QUEUED,
2374102adabSPaul E. McKenney 				  STATE_RCU_HEAD_READY);
2384102adabSPaul E. McKenney 	debug_object_deactivate(head, &rcuhead_debug_descr);
2394102adabSPaul E. McKenney }
2404102adabSPaul E. McKenney #else	/* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
2414102adabSPaul E. McKenney static inline int debug_rcu_head_queue(struct rcu_head *head)
2424102adabSPaul E. McKenney {
2434102adabSPaul E. McKenney 	return 0;
2444102adabSPaul E. McKenney }
2454102adabSPaul E. McKenney 
2464102adabSPaul E. McKenney static inline void debug_rcu_head_unqueue(struct rcu_head *head)
2474102adabSPaul E. McKenney {
2484102adabSPaul E. McKenney }
2494102adabSPaul E. McKenney #endif	/* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
2504102adabSPaul E. McKenney 
25158c53360SPaul E. McKenney extern int rcu_cpu_stall_suppress_at_boot;
25258c53360SPaul E. McKenney 
25358c53360SPaul E. McKenney static inline bool rcu_stall_is_suppressed_at_boot(void)
25458c53360SPaul E. McKenney {
25558c53360SPaul E. McKenney 	return rcu_cpu_stall_suppress_at_boot && !rcu_inkernel_boot_has_ended();
25658c53360SPaul E. McKenney }
25758c53360SPaul E. McKenney 
2584102adabSPaul E. McKenney #ifdef CONFIG_RCU_STALL_COMMON
2594102adabSPaul E. McKenney 
260cdc694b2SPaul E. McKenney extern int rcu_cpu_stall_ftrace_dump;
2614102adabSPaul E. McKenney extern int rcu_cpu_stall_suppress;
26210462d6fSPaul E. McKenney extern int rcu_cpu_stall_timeout;
26328b3ae42SUladzislau Rezki extern int rcu_exp_cpu_stall_timeout;
264be42f00bSZhen Lei extern int rcu_cpu_stall_cputime;
26592987fe8SPaul E. McKenney extern bool rcu_exp_stall_task_details __read_mostly;
2664102adabSPaul E. McKenney int rcu_jiffies_till_stall_check(void);
26728b3ae42SUladzislau Rezki int rcu_exp_jiffies_till_stall_check(void);
2684102adabSPaul E. McKenney 
26958c53360SPaul E. McKenney static inline bool rcu_stall_is_suppressed(void)
27058c53360SPaul E. McKenney {
27158c53360SPaul E. McKenney 	return rcu_stall_is_suppressed_at_boot() || rcu_cpu_stall_suppress;
27258c53360SPaul E. McKenney }
27358c53360SPaul E. McKenney 
274f22ce091SPaul E. McKenney #define rcu_ftrace_dump_stall_suppress() \
275f22ce091SPaul E. McKenney do { \
276f22ce091SPaul E. McKenney 	if (!rcu_cpu_stall_suppress) \
277f22ce091SPaul E. McKenney 		rcu_cpu_stall_suppress = 3; \
278f22ce091SPaul E. McKenney } while (0)
279f22ce091SPaul E. McKenney 
280f22ce091SPaul E. McKenney #define rcu_ftrace_dump_stall_unsuppress() \
281f22ce091SPaul E. McKenney do { \
282f22ce091SPaul E. McKenney 	if (rcu_cpu_stall_suppress == 3) \
283f22ce091SPaul E. McKenney 		rcu_cpu_stall_suppress = 0; \
284f22ce091SPaul E. McKenney } while (0)
285f22ce091SPaul E. McKenney 
286f22ce091SPaul E. McKenney #else /* #endif #ifdef CONFIG_RCU_STALL_COMMON */
28758c53360SPaul E. McKenney 
28858c53360SPaul E. McKenney static inline bool rcu_stall_is_suppressed(void)
28958c53360SPaul E. McKenney {
29058c53360SPaul E. McKenney 	return rcu_stall_is_suppressed_at_boot();
29158c53360SPaul E. McKenney }
292f22ce091SPaul E. McKenney #define rcu_ftrace_dump_stall_suppress()
293f22ce091SPaul E. McKenney #define rcu_ftrace_dump_stall_unsuppress()
2944102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_STALL_COMMON */
2954102adabSPaul E. McKenney 
2964102adabSPaul E. McKenney /*
2974102adabSPaul E. McKenney  * Strings used in tracepoints need to be exported via the
2984102adabSPaul E. McKenney  * tracing system such that tools like perf and trace-cmd can
2994102adabSPaul E. McKenney  * translate the string address pointers to actual text.
3004102adabSPaul E. McKenney  */
3014102adabSPaul E. McKenney #define TPS(x)  tracepoint_string(x)
3024102adabSPaul E. McKenney 
303b8989b76SPaul E. McKenney /*
304b8989b76SPaul E. McKenney  * Dump the ftrace buffer, but only one time per callsite per boot.
305b8989b76SPaul E. McKenney  */
306b8989b76SPaul E. McKenney #define rcu_ftrace_dump(oops_dump_mode) \
307b8989b76SPaul E. McKenney do { \
308b8989b76SPaul E. McKenney 	static atomic_t ___rfd_beenhere = ATOMIC_INIT(0); \
309b8989b76SPaul E. McKenney 	\
310b8989b76SPaul E. McKenney 	if (!atomic_read(&___rfd_beenhere) && \
31183b6ca1fSPaul E. McKenney 	    !atomic_xchg(&___rfd_beenhere, 1)) { \
31283b6ca1fSPaul E. McKenney 		tracing_off(); \
313f22ce091SPaul E. McKenney 		rcu_ftrace_dump_stall_suppress(); \
314b8989b76SPaul E. McKenney 		ftrace_dump(oops_dump_mode); \
315f22ce091SPaul E. McKenney 		rcu_ftrace_dump_stall_unsuppress(); \
31683b6ca1fSPaul E. McKenney 	} \
317b8989b76SPaul E. McKenney } while (0)
318b8989b76SPaul E. McKenney 
319aa23c6fbSPranith Kumar void rcu_early_boot_tests(void);
32052d7e48bSPaul E. McKenney void rcu_test_sync_prims(void);
321aa23c6fbSPranith Kumar 
3225f6130faSLai Jiangshan /*
3235f6130faSLai Jiangshan  * This function really isn't for public consumption, but RCU is special in
3245f6130faSLai Jiangshan  * that context switches can allow the state machine to make progress.
3255f6130faSLai Jiangshan  */
3265f6130faSLai Jiangshan extern void resched_cpu(int cpu);
3275f6130faSLai Jiangshan 
3280cd7e350SPaul E. McKenney #if !defined(CONFIG_TINY_RCU)
3292b34c43cSPaul E. McKenney 
3302b34c43cSPaul E. McKenney #include <linux/rcu_node_tree.h>
3312b34c43cSPaul E. McKenney 
3322b34c43cSPaul E. McKenney extern int rcu_num_lvls;
333e95d68d2SPaul E. McKenney extern int num_rcu_lvl[];
3342b34c43cSPaul E. McKenney extern int rcu_num_nodes;
3352b34c43cSPaul E. McKenney static bool rcu_fanout_exact;
3362b34c43cSPaul E. McKenney static int rcu_fanout_leaf;
3372b34c43cSPaul E. McKenney 
3382b34c43cSPaul E. McKenney /*
3392b34c43cSPaul E. McKenney  * Compute the per-level fanout, either using the exact fanout specified
3402b34c43cSPaul E. McKenney  * or balancing the tree, depending on the rcu_fanout_exact boot parameter.
3412b34c43cSPaul E. McKenney  */
3422b34c43cSPaul E. McKenney static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
3432b34c43cSPaul E. McKenney {
3442b34c43cSPaul E. McKenney 	int i;
3452b34c43cSPaul E. McKenney 
34636b5dae6SPaul E. McKenney 	for (i = 0; i < RCU_NUM_LVLS; i++)
34736b5dae6SPaul E. McKenney 		levelspread[i] = INT_MIN;
3482b34c43cSPaul E. McKenney 	if (rcu_fanout_exact) {
3492b34c43cSPaul E. McKenney 		levelspread[rcu_num_lvls - 1] = rcu_fanout_leaf;
3502b34c43cSPaul E. McKenney 		for (i = rcu_num_lvls - 2; i >= 0; i--)
3512b34c43cSPaul E. McKenney 			levelspread[i] = RCU_FANOUT;
3522b34c43cSPaul E. McKenney 	} else {
3532b34c43cSPaul E. McKenney 		int ccur;
3542b34c43cSPaul E. McKenney 		int cprv;
3552b34c43cSPaul E. McKenney 
3562b34c43cSPaul E. McKenney 		cprv = nr_cpu_ids;
3572b34c43cSPaul E. McKenney 		for (i = rcu_num_lvls - 1; i >= 0; i--) {
3582b34c43cSPaul E. McKenney 			ccur = levelcnt[i];
3592b34c43cSPaul E. McKenney 			levelspread[i] = (cprv + ccur - 1) / ccur;
3602b34c43cSPaul E. McKenney 			cprv = ccur;
3612b34c43cSPaul E. McKenney 		}
3622b34c43cSPaul E. McKenney 	}
3632b34c43cSPaul E. McKenney }
3642b34c43cSPaul E. McKenney 
365b5befe84SFrederic Weisbecker extern void rcu_init_geometry(void);
366b5befe84SFrederic Weisbecker 
3677f87c036SPaul E. McKenney /* Returns a pointer to the first leaf rcu_node structure. */
368aedf4ba9SPaul E. McKenney #define rcu_first_leaf_node() (rcu_state.level[rcu_num_lvls - 1])
3695b4c11d5SPaul E. McKenney 
3705b4c11d5SPaul E. McKenney /* Is this rcu_node a leaf? */
3715b4c11d5SPaul E. McKenney #define rcu_is_leaf_node(rnp) ((rnp)->level == rcu_num_lvls - 1)
3725b4c11d5SPaul E. McKenney 
3735257514dSPaul E. McKenney /* Is this rcu_node the last leaf? */
374aedf4ba9SPaul E. McKenney #define rcu_is_last_leaf_node(rnp) ((rnp) == &rcu_state.node[rcu_num_nodes - 1])
3755257514dSPaul E. McKenney 
376efbe451dSPaul E. McKenney /*
377aedf4ba9SPaul E. McKenney  * Do a full breadth-first scan of the {s,}rcu_node structures for the
3787f87c036SPaul E. McKenney  * specified state structure (for SRCU) or the only rcu_state structure
3797f87c036SPaul E. McKenney  * (for RCU).
380efbe451dSPaul E. McKenney  */
38195433f72SPaul E. McKenney #define _rcu_for_each_node_breadth_first(sp, rnp) \
382aedf4ba9SPaul E. McKenney 	for ((rnp) = &(sp)->node[0]; \
383aedf4ba9SPaul E. McKenney 	     (rnp) < &(sp)->node[rcu_num_nodes]; (rnp)++)
384aedf4ba9SPaul E. McKenney #define rcu_for_each_node_breadth_first(rnp) \
38595433f72SPaul E. McKenney 	_rcu_for_each_node_breadth_first(&rcu_state, rnp)
38695433f72SPaul E. McKenney #define srcu_for_each_node_breadth_first(ssp, rnp) \
38795433f72SPaul E. McKenney 	_rcu_for_each_node_breadth_first(ssp->srcu_sup, rnp)
388efbe451dSPaul E. McKenney 
389efbe451dSPaul E. McKenney /*
3907f87c036SPaul E. McKenney  * Scan the leaves of the rcu_node hierarchy for the rcu_state structure.
3917f87c036SPaul E. McKenney  * Note that if there is a singleton rcu_node tree with but one rcu_node
3927f87c036SPaul E. McKenney  * structure, this loop -will- visit the rcu_node structure.  It is still
3937f87c036SPaul E. McKenney  * a leaf node, even if it is also the root node.
394efbe451dSPaul E. McKenney  */
395aedf4ba9SPaul E. McKenney #define rcu_for_each_leaf_node(rnp) \
396aedf4ba9SPaul E. McKenney 	for ((rnp) = rcu_first_leaf_node(); \
397aedf4ba9SPaul E. McKenney 	     (rnp) < &rcu_state.node[rcu_num_nodes]; (rnp)++)
398efbe451dSPaul E. McKenney 
399efbe451dSPaul E. McKenney /*
400efbe451dSPaul E. McKenney  * Iterate over all possible CPUs in a leaf RCU node.
401efbe451dSPaul E. McKenney  */
402efbe451dSPaul E. McKenney #define for_each_leaf_node_possible_cpu(rnp, cpu) \
40382dd8419SPaul E. McKenney 	for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
40482dd8419SPaul E. McKenney 	     (cpu) = cpumask_next((rnp)->grplo - 1, cpu_possible_mask); \
40565963d24SPaul E. McKenney 	     (cpu) <= rnp->grphi; \
40665963d24SPaul E. McKenney 	     (cpu) = cpumask_next((cpu), cpu_possible_mask))
40765963d24SPaul E. McKenney 
40865963d24SPaul E. McKenney /*
40965963d24SPaul E. McKenney  * Iterate over all CPUs in a leaf RCU node's specified mask.
41065963d24SPaul E. McKenney  */
41165963d24SPaul E. McKenney #define rcu_find_next_bit(rnp, cpu, mask) \
41265963d24SPaul E. McKenney 	((rnp)->grplo + find_next_bit(&(mask), BITS_PER_LONG, (cpu)))
41365963d24SPaul E. McKenney #define for_each_leaf_node_cpu_mask(rnp, cpu, mask) \
41482dd8419SPaul E. McKenney 	for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
41582dd8419SPaul E. McKenney 	     (cpu) = rcu_find_next_bit((rnp), 0, (mask)); \
41665963d24SPaul E. McKenney 	     (cpu) <= rnp->grphi; \
41765963d24SPaul E. McKenney 	     (cpu) = rcu_find_next_bit((rnp), (cpu) + 1 - (rnp->grplo), (mask)))
418efbe451dSPaul E. McKenney 
4190cd7e350SPaul E. McKenney #endif /* !defined(CONFIG_TINY_RCU) */
4200cd7e350SPaul E. McKenney 
4210cd7e350SPaul E. McKenney #if !defined(CONFIG_TINY_RCU) || defined(CONFIG_TASKS_RCU_GENERIC)
4220cd7e350SPaul E. McKenney 
42383d40bd3SPaul E. McKenney /*
42483d40bd3SPaul E. McKenney  * Wrappers for the rcu_node::lock acquire and release.
42583d40bd3SPaul E. McKenney  *
42683d40bd3SPaul E. McKenney  * Because the rcu_nodes form a tree, the tree traversal locking will observe
42783d40bd3SPaul E. McKenney  * different lock values, this in turn means that an UNLOCK of one level
42883d40bd3SPaul E. McKenney  * followed by a LOCK of another level does not imply a full memory barrier;
42983d40bd3SPaul E. McKenney  * and most importantly transitivity is lost.
43083d40bd3SPaul E. McKenney  *
43183d40bd3SPaul E. McKenney  * In order to restore full ordering between tree levels, augment the regular
43283d40bd3SPaul E. McKenney  * lock acquire functions with smp_mb__after_unlock_lock().
43383d40bd3SPaul E. McKenney  *
43483d40bd3SPaul E. McKenney  * As ->lock of struct rcu_node is a __private field, therefore one should use
43583d40bd3SPaul E. McKenney  * these wrappers rather than directly call raw_spin_{lock,unlock}* on ->lock.
43683d40bd3SPaul E. McKenney  */
43783d40bd3SPaul E. McKenney #define raw_spin_lock_rcu_node(p)					\
43883d40bd3SPaul E. McKenney do {									\
43983d40bd3SPaul E. McKenney 	raw_spin_lock(&ACCESS_PRIVATE(p, lock));			\
44083d40bd3SPaul E. McKenney 	smp_mb__after_unlock_lock();					\
44183d40bd3SPaul E. McKenney } while (0)
44283d40bd3SPaul E. McKenney 
4437dffe017SPaul E. McKenney #define raw_spin_unlock_rcu_node(p)					\
4447dffe017SPaul E. McKenney do {									\
4457dffe017SPaul E. McKenney 	lockdep_assert_irqs_disabled();					\
4467dffe017SPaul E. McKenney 	raw_spin_unlock(&ACCESS_PRIVATE(p, lock));			\
4477dffe017SPaul E. McKenney } while (0)
44883d40bd3SPaul E. McKenney 
44983d40bd3SPaul E. McKenney #define raw_spin_lock_irq_rcu_node(p)					\
45083d40bd3SPaul E. McKenney do {									\
45183d40bd3SPaul E. McKenney 	raw_spin_lock_irq(&ACCESS_PRIVATE(p, lock));			\
45283d40bd3SPaul E. McKenney 	smp_mb__after_unlock_lock();					\
45383d40bd3SPaul E. McKenney } while (0)
45483d40bd3SPaul E. McKenney 
45583d40bd3SPaul E. McKenney #define raw_spin_unlock_irq_rcu_node(p)					\
4567dffe017SPaul E. McKenney do {									\
4577dffe017SPaul E. McKenney 	lockdep_assert_irqs_disabled();					\
4587dffe017SPaul E. McKenney 	raw_spin_unlock_irq(&ACCESS_PRIVATE(p, lock));			\
4597dffe017SPaul E. McKenney } while (0)
46083d40bd3SPaul E. McKenney 
4614e4bea74SPaul E. McKenney #define raw_spin_lock_irqsave_rcu_node(p, flags)			\
46283d40bd3SPaul E. McKenney do {									\
4634e4bea74SPaul E. McKenney 	raw_spin_lock_irqsave(&ACCESS_PRIVATE(p, lock), flags);	\
46483d40bd3SPaul E. McKenney 	smp_mb__after_unlock_lock();					\
46583d40bd3SPaul E. McKenney } while (0)
46683d40bd3SPaul E. McKenney 
4674e4bea74SPaul E. McKenney #define raw_spin_unlock_irqrestore_rcu_node(p, flags)			\
4687dffe017SPaul E. McKenney do {									\
4697dffe017SPaul E. McKenney 	lockdep_assert_irqs_disabled();					\
4707dffe017SPaul E. McKenney 	raw_spin_unlock_irqrestore(&ACCESS_PRIVATE(p, lock), flags);	\
4717dffe017SPaul E. McKenney } while (0)
47283d40bd3SPaul E. McKenney 
47383d40bd3SPaul E. McKenney #define raw_spin_trylock_rcu_node(p)					\
47483d40bd3SPaul E. McKenney ({									\
47583d40bd3SPaul E. McKenney 	bool ___locked = raw_spin_trylock(&ACCESS_PRIVATE(p, lock));	\
47683d40bd3SPaul E. McKenney 									\
47783d40bd3SPaul E. McKenney 	if (___locked)							\
47883d40bd3SPaul E. McKenney 		smp_mb__after_unlock_lock();				\
47983d40bd3SPaul E. McKenney 	___locked;							\
48083d40bd3SPaul E. McKenney })
48183d40bd3SPaul E. McKenney 
482a32e01eeSMatthew Wilcox #define raw_lockdep_assert_held_rcu_node(p)				\
483a32e01eeSMatthew Wilcox 	lockdep_assert_held(&ACCESS_PRIVATE(p, lock))
484a32e01eeSMatthew Wilcox 
4850cd7e350SPaul E. McKenney #endif // #if !defined(CONFIG_TINY_RCU) || defined(CONFIG_TASKS_RCU_GENERIC)
4862b34c43cSPaul E. McKenney 
48725c36329SPaul E. McKenney #ifdef CONFIG_TINY_RCU
48825c36329SPaul E. McKenney /* Tiny RCU doesn't expedite, as its purpose in life is instead to be tiny. */
4897414fac0SPaul E. McKenney static inline bool rcu_gp_is_normal(void) { return true; }
4907414fac0SPaul E. McKenney static inline bool rcu_gp_is_expedited(void) { return false; }
4916efdda8bSJoel Fernandes (Google) static inline bool rcu_async_should_hurry(void) { return false; }
4927414fac0SPaul E. McKenney static inline void rcu_expedite_gp(void) { }
4937414fac0SPaul E. McKenney static inline void rcu_unexpedite_gp(void) { }
4946efdda8bSJoel Fernandes (Google) static inline void rcu_async_hurry(void) { }
4956efdda8bSJoel Fernandes (Google) static inline void rcu_async_relax(void) { }
496bfbd767dSPaul E. McKenney static inline void rcu_request_urgent_qs_task(struct task_struct *t) { }
49725c36329SPaul E. McKenney #else /* #ifdef CONFIG_TINY_RCU */
49825c36329SPaul E. McKenney bool rcu_gp_is_normal(void);     /* Internal RCU use. */
49925c36329SPaul E. McKenney bool rcu_gp_is_expedited(void);  /* Internal RCU use. */
5006efdda8bSJoel Fernandes (Google) bool rcu_async_should_hurry(void);  /* Internal RCU use. */
50125c36329SPaul E. McKenney void rcu_expedite_gp(void);
50225c36329SPaul E. McKenney void rcu_unexpedite_gp(void);
5036efdda8bSJoel Fernandes (Google) void rcu_async_hurry(void);
5046efdda8bSJoel Fernandes (Google) void rcu_async_relax(void);
50525c36329SPaul E. McKenney void rcupdate_announce_bootup_oddness(void);
506474d0997SPaul E. McKenney #ifdef CONFIG_TASKS_RCU_GENERIC
507e21408ceSPaul E. McKenney void show_rcu_tasks_gp_kthreads(void);
508474d0997SPaul E. McKenney #else /* #ifdef CONFIG_TASKS_RCU_GENERIC */
509474d0997SPaul E. McKenney static inline void show_rcu_tasks_gp_kthreads(void) {}
510474d0997SPaul E. McKenney #endif /* #else #ifdef CONFIG_TASKS_RCU_GENERIC */
511bfbd767dSPaul E. McKenney void rcu_request_urgent_qs_task(struct task_struct *t);
51225c36329SPaul E. McKenney #endif /* #else #ifdef CONFIG_TINY_RCU */
51325c36329SPaul E. McKenney 
514*e0a34641SArnd Bergmann #ifdef CONFIG_TASKS_RCU
515*e0a34641SArnd Bergmann struct task_struct *get_rcu_tasks_gp_kthread(void);
516*e0a34641SArnd Bergmann #endif // # ifdef CONFIG_TASKS_RCU
517*e0a34641SArnd Bergmann 
518*e0a34641SArnd Bergmann #ifdef CONFIG_TASKS_RUDE_RCU
519*e0a34641SArnd Bergmann struct task_struct *get_rcu_tasks_rude_gp_kthread(void);
520*e0a34641SArnd Bergmann #endif // # ifdef CONFIG_TASKS_RUDE_RCU
521*e0a34641SArnd Bergmann 
52282118249SPaul E. McKenney #define RCU_SCHEDULER_INACTIVE	0
52382118249SPaul E. McKenney #define RCU_SCHEDULER_INIT	1
52482118249SPaul E. McKenney #define RCU_SCHEDULER_RUNNING	2
52582118249SPaul E. McKenney 
526cad7b389SPaul E. McKenney enum rcutorture_type {
527cad7b389SPaul E. McKenney 	RCU_FLAVOR,
528cad7b389SPaul E. McKenney 	RCU_TASKS_FLAVOR,
5293d6e43c7SPaul E. McKenney 	RCU_TASKS_RUDE_FLAVOR,
530c1a76c0bSPaul E. McKenney 	RCU_TASKS_TRACING_FLAVOR,
531c682db55SPaul E. McKenney 	RCU_TRIVIAL_FLAVOR,
532cad7b389SPaul E. McKenney 	SRCU_FLAVOR,
533cad7b389SPaul E. McKenney 	INVALID_RCU_FLAVOR
534cad7b389SPaul E. McKenney };
535cad7b389SPaul E. McKenney 
5363cb278e7SJoel Fernandes (Google) #if defined(CONFIG_RCU_LAZY)
5373cb278e7SJoel Fernandes (Google) unsigned long rcu_lazy_get_jiffies_till_flush(void);
5383cb278e7SJoel Fernandes (Google) void rcu_lazy_set_jiffies_till_flush(unsigned long j);
5393cb278e7SJoel Fernandes (Google) #else
5403cb278e7SJoel Fernandes (Google) static inline unsigned long rcu_lazy_get_jiffies_till_flush(void) { return 0; }
5413cb278e7SJoel Fernandes (Google) static inline void rcu_lazy_set_jiffies_till_flush(unsigned long j) { }
5423cb278e7SJoel Fernandes (Google) #endif
5433cb278e7SJoel Fernandes (Google) 
544b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU)
545cad7b389SPaul E. McKenney void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
546aebc8264SPaul E. McKenney 			    unsigned long *gp_seq);
547cad7b389SPaul E. McKenney void do_trace_rcu_torture_read(const char *rcutorturename,
548cad7b389SPaul E. McKenney 			       struct rcu_head *rhp,
549cad7b389SPaul E. McKenney 			       unsigned long secs,
550cad7b389SPaul E. McKenney 			       unsigned long c_old,
551cad7b389SPaul E. McKenney 			       unsigned long c);
55255b2dcf5SPaul E. McKenney void rcu_gp_set_torture_wait(int duration);
553cad7b389SPaul E. McKenney #else
554cad7b389SPaul E. McKenney static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
555aebc8264SPaul E. McKenney 					  int *flags, unsigned long *gp_seq)
556cad7b389SPaul E. McKenney {
557cad7b389SPaul E. McKenney 	*flags = 0;
558aebc8264SPaul E. McKenney 	*gp_seq = 0;
559cad7b389SPaul E. McKenney }
560cad7b389SPaul E. McKenney #ifdef CONFIG_RCU_TRACE
561cad7b389SPaul E. McKenney void do_trace_rcu_torture_read(const char *rcutorturename,
562cad7b389SPaul E. McKenney 			       struct rcu_head *rhp,
563cad7b389SPaul E. McKenney 			       unsigned long secs,
564cad7b389SPaul E. McKenney 			       unsigned long c_old,
565cad7b389SPaul E. McKenney 			       unsigned long c);
566cad7b389SPaul E. McKenney #else
567cad7b389SPaul E. McKenney #define do_trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
568cad7b389SPaul E. McKenney 	do { } while (0)
569cad7b389SPaul E. McKenney #endif
57055b2dcf5SPaul E. McKenney static inline void rcu_gp_set_torture_wait(int duration) { }
571cad7b389SPaul E. McKenney #endif
572cad7b389SPaul E. McKenney 
573c682db55SPaul E. McKenney #if IS_ENABLED(CONFIG_RCU_TORTURE_TEST) || IS_MODULE(CONFIG_RCU_TORTURE_TEST)
574c682db55SPaul E. McKenney long rcutorture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask);
575c682db55SPaul E. McKenney #endif
576c682db55SPaul E. McKenney 
577cad7b389SPaul E. McKenney #ifdef CONFIG_TINY_SRCU
578cad7b389SPaul E. McKenney 
579cad7b389SPaul E. McKenney static inline void srcutorture_get_gp_data(enum rcutorture_type test_type,
580cad7b389SPaul E. McKenney 					   struct srcu_struct *sp, int *flags,
581aebc8264SPaul E. McKenney 					   unsigned long *gp_seq)
582cad7b389SPaul E. McKenney {
583cad7b389SPaul E. McKenney 	if (test_type != SRCU_FLAVOR)
584cad7b389SPaul E. McKenney 		return;
585cad7b389SPaul E. McKenney 	*flags = 0;
586aebc8264SPaul E. McKenney 	*gp_seq = sp->srcu_idx;
587cad7b389SPaul E. McKenney }
588cad7b389SPaul E. McKenney 
589cad7b389SPaul E. McKenney #elif defined(CONFIG_TREE_SRCU)
590cad7b389SPaul E. McKenney 
591cad7b389SPaul E. McKenney void srcutorture_get_gp_data(enum rcutorture_type test_type,
592cad7b389SPaul E. McKenney 			     struct srcu_struct *sp, int *flags,
593aebc8264SPaul E. McKenney 			     unsigned long *gp_seq);
594cad7b389SPaul E. McKenney 
595cad7b389SPaul E. McKenney #endif
596cad7b389SPaul E. McKenney 
597e3c8d51eSPaul E. McKenney #ifdef CONFIG_TINY_RCU
5987d0c9c50SPaul E. McKenney static inline bool rcu_dynticks_zero_in_eqs(int cpu, int *vp) { return false; }
59917ef2fe9SPaul E. McKenney static inline unsigned long rcu_get_gp_seq(void) { return 0; }
6007414fac0SPaul E. McKenney static inline unsigned long rcu_exp_batches_completed(void) { return 0; }
6017414fac0SPaul E. McKenney static inline unsigned long
6027414fac0SPaul E. McKenney srcu_batches_completed(struct srcu_struct *sp) { return 0; }
6037414fac0SPaul E. McKenney static inline void rcu_force_quiescent_state(void) { }
6040260b92eSPaul E. McKenney static inline bool rcu_check_boost_fail(unsigned long gp_state, int *cpup) { return true; }
6057414fac0SPaul E. McKenney static inline void show_rcu_gp_kthreads(void) { }
6064babd855SJoel Fernandes (Google) static inline int rcu_get_gp_kthreads_prio(void) { return 0; }
607e0aff973SPaul E. McKenney static inline void rcu_fwd_progress_check(unsigned long j) { }
60899d6a2acSPaul E. McKenney static inline void rcu_gp_slow_register(atomic_t *rgssp) { }
60999d6a2acSPaul E. McKenney static inline void rcu_gp_slow_unregister(atomic_t *rgssp) { }
610e3c8d51eSPaul E. McKenney #else /* #ifdef CONFIG_TINY_RCU */
6117d0c9c50SPaul E. McKenney bool rcu_dynticks_zero_in_eqs(int cpu, int *vp);
61217ef2fe9SPaul E. McKenney unsigned long rcu_get_gp_seq(void);
613e3c8d51eSPaul E. McKenney unsigned long rcu_exp_batches_completed(void);
6145a0465e1SPaul E. McKenney unsigned long srcu_batches_completed(struct srcu_struct *sp);
6150260b92eSPaul E. McKenney bool rcu_check_boost_fail(unsigned long gp_state, int *cpup);
616e3c8d51eSPaul E. McKenney void show_rcu_gp_kthreads(void);
6174babd855SJoel Fernandes (Google) int rcu_get_gp_kthreads_prio(void);
618e0aff973SPaul E. McKenney void rcu_fwd_progress_check(unsigned long j);
619e3c8d51eSPaul E. McKenney void rcu_force_quiescent_state(void);
620ad7c946bSPaul E. McKenney extern struct workqueue_struct *rcu_gp_wq;
6219621fbeeSKalesh Singh #ifdef CONFIG_RCU_EXP_KTHREAD
6229621fbeeSKalesh Singh extern struct kthread_worker *rcu_exp_gp_kworker;
6239621fbeeSKalesh Singh extern struct kthread_worker *rcu_exp_par_gp_kworker;
6249621fbeeSKalesh Singh #else /* !CONFIG_RCU_EXP_KTHREAD */
62525f3d7efSPaul E. McKenney extern struct workqueue_struct *rcu_par_gp_wq;
6269621fbeeSKalesh Singh #endif /* CONFIG_RCU_EXP_KTHREAD */
62799d6a2acSPaul E. McKenney void rcu_gp_slow_register(atomic_t *rgssp);
62899d6a2acSPaul E. McKenney void rcu_gp_slow_unregister(atomic_t *rgssp);
629e3c8d51eSPaul E. McKenney #endif /* #else #ifdef CONFIG_TINY_RCU */
630e3c8d51eSPaul E. McKenney 
63144c65ff2SPaul E. McKenney #ifdef CONFIG_RCU_NOCB_CPU
6325ab7ab83SPaul E. McKenney void rcu_bind_current_to_nocb(void);
6333d54f798SPaul E. McKenney #else
6345ab7ab83SPaul E. McKenney static inline void rcu_bind_current_to_nocb(void) { }
6353d54f798SPaul E. McKenney #endif
6363d54f798SPaul E. McKenney 
63727c0f144SPaul E. McKenney #if !defined(CONFIG_TINY_RCU) && defined(CONFIG_TASKS_RCU)
63827c0f144SPaul E. McKenney void show_rcu_tasks_classic_gp_kthread(void);
63927c0f144SPaul E. McKenney #else
64027c0f144SPaul E. McKenney static inline void show_rcu_tasks_classic_gp_kthread(void) {}
64127c0f144SPaul E. McKenney #endif
64227c0f144SPaul E. McKenney #if !defined(CONFIG_TINY_RCU) && defined(CONFIG_TASKS_RUDE_RCU)
64327c0f144SPaul E. McKenney void show_rcu_tasks_rude_gp_kthread(void);
64427c0f144SPaul E. McKenney #else
64527c0f144SPaul E. McKenney static inline void show_rcu_tasks_rude_gp_kthread(void) {}
64627c0f144SPaul E. McKenney #endif
64727c0f144SPaul E. McKenney #if !defined(CONFIG_TINY_RCU) && defined(CONFIG_TASKS_TRACE_RCU)
64827c0f144SPaul E. McKenney void show_rcu_tasks_trace_gp_kthread(void);
64927c0f144SPaul E. McKenney #else
65027c0f144SPaul E. McKenney static inline void show_rcu_tasks_trace_gp_kthread(void) {}
65127c0f144SPaul E. McKenney #endif
65227c0f144SPaul E. McKenney 
653401b0de3SPaul E. McKenney #ifdef CONFIG_TINY_RCU
654401b0de3SPaul E. McKenney static inline bool rcu_cpu_beenfullyonline(int cpu) { return true; }
655401b0de3SPaul E. McKenney #else
656401b0de3SPaul E. McKenney bool rcu_cpu_beenfullyonline(int cpu);
657401b0de3SPaul E. McKenney #endif
658401b0de3SPaul E. McKenney 
6594102adabSPaul E. McKenney #endif /* __LINUX_RCU_H */
660