Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0+ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Read-Copy Update definitions shared among RCU implementations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright IBM Corporation, 2011
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Author: Paul E. McKenney <paulmck@linux.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef __LINUX_RCU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define __LINUX_RCU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <trace/events/rcu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* Offset to allow distinguishing irq vs. task-based idle entry/exit. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define DYNTICK_IRQ_NONIDLE	((LONG_MAX / 2) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * Grace-period counter management.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define RCU_SEQ_CTR_SHIFT	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define RCU_SEQ_STATE_MASK	((1 << RCU_SEQ_CTR_SHIFT) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * Return the counter portion of a sequence number previously returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * by rcu_seq_snap() or rcu_seq_current().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static inline unsigned long rcu_seq_ctr(unsigned long s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	return s >> RCU_SEQ_CTR_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * Return the state portion of a sequence number previously returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * by rcu_seq_snap() or rcu_seq_current().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static inline int rcu_seq_state(unsigned long s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	return s & RCU_SEQ_STATE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * Set the state portion of the pointed-to sequence number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * The caller is responsible for preventing conflicting updates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) static inline void rcu_seq_set_state(unsigned long *sp, int newstate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	WARN_ON_ONCE(newstate & ~RCU_SEQ_STATE_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	WRITE_ONCE(*sp, (*sp & ~RCU_SEQ_STATE_MASK) + newstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) /* Adjust sequence number for start of update-side operation. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static inline void rcu_seq_start(unsigned long *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	WRITE_ONCE(*sp, *sp + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	smp_mb(); /* Ensure update-side operation after counter increment. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	WARN_ON_ONCE(rcu_seq_state(*sp) != 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* Compute the end-of-grace-period value for the specified sequence number. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static inline unsigned long rcu_seq_endval(unsigned long *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	return (*sp | RCU_SEQ_STATE_MASK) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /* Adjust sequence number for end of update-side operation. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static inline void rcu_seq_end(unsigned long *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	smp_mb(); /* Ensure update-side operation before counter increment. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	WARN_ON_ONCE(!rcu_seq_state(*sp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	WRITE_ONCE(*sp, rcu_seq_endval(sp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * rcu_seq_snap - Take a snapshot of the update side's sequence number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * This function returns the earliest value of the grace-period sequence number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * that will indicate that a full grace period has elapsed since the current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * time.  Once the grace-period sequence number has reached this value, it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * be safe to invoke all callbacks that have been registered prior to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * current time. This value is the current grace-period number plus two to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * power of the number of low-order bits reserved for state, then rounded up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * the next value in which the state bits are all zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static inline unsigned long rcu_seq_snap(unsigned long *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	unsigned long s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	s = (READ_ONCE(*sp) + 2 * RCU_SEQ_STATE_MASK + 1) & ~RCU_SEQ_STATE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	smp_mb(); /* Above access must not bleed into critical section. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	return s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /* Return the current value the update side's sequence number, no ordering. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static inline unsigned long rcu_seq_current(unsigned long *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return READ_ONCE(*sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * Given a snapshot from rcu_seq_snap(), determine whether or not the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * corresponding update-side operation has started.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static inline bool rcu_seq_started(unsigned long *sp, unsigned long s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	return ULONG_CMP_LT((s - 1) & ~RCU_SEQ_STATE_MASK, READ_ONCE(*sp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * Given a snapshot from rcu_seq_snap(), determine whether or not a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * full update-side operation has occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static inline bool rcu_seq_done(unsigned long *sp, unsigned long s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	return ULONG_CMP_GE(READ_ONCE(*sp), s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * Has a grace period completed since the time the old gp_seq was collected?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static inline bool rcu_seq_completed_gp(unsigned long old, unsigned long new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	return ULONG_CMP_LT(old, new & ~RCU_SEQ_STATE_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * Has a grace period started since the time the old gp_seq was collected?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static inline bool rcu_seq_new_gp(unsigned long old, unsigned long new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	return ULONG_CMP_LT((old + RCU_SEQ_STATE_MASK) & ~RCU_SEQ_STATE_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			    new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  * Roughly how many full grace periods have elapsed between the collection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  * of the two specified grace periods?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static inline unsigned long rcu_seq_diff(unsigned long new, unsigned long old)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	unsigned long rnd_diff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	if (old == new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	 * Compute the number of grace periods (still shifted up), plus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	 * one if either of new and old is not an exact grace period.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	rnd_diff = (new & ~RCU_SEQ_STATE_MASK) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		   ((old + RCU_SEQ_STATE_MASK) & ~RCU_SEQ_STATE_MASK) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		   ((new & RCU_SEQ_STATE_MASK) || (old & RCU_SEQ_STATE_MASK));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (ULONG_CMP_GE(RCU_SEQ_STATE_MASK, rnd_diff))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		return 1; /* Definitely no grace period has elapsed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return ((rnd_diff - RCU_SEQ_STATE_MASK - 1) >> RCU_SEQ_CTR_SHIFT) + 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * by call_rcu() and rcu callback execution, and are therefore not part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * of the RCU API. These are in rcupdate.h because they are used by all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * RCU implementations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) # define STATE_RCU_HEAD_READY	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) # define STATE_RCU_HEAD_QUEUED	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) extern const struct debug_obj_descr rcuhead_debug_descr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static inline int debug_rcu_head_queue(struct rcu_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	int r1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	r1 = debug_object_activate(head, &rcuhead_debug_descr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	debug_object_active_state(head, &rcuhead_debug_descr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 				  STATE_RCU_HEAD_READY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 				  STATE_RCU_HEAD_QUEUED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	return r1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static inline void debug_rcu_head_unqueue(struct rcu_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	debug_object_active_state(head, &rcuhead_debug_descr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				  STATE_RCU_HEAD_QUEUED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				  STATE_RCU_HEAD_READY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	debug_object_deactivate(head, &rcuhead_debug_descr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #else	/* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static inline int debug_rcu_head_queue(struct rcu_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static inline void debug_rcu_head_unqueue(struct rcu_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #endif	/* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) extern int rcu_cpu_stall_suppress_at_boot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static inline bool rcu_stall_is_suppressed_at_boot(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	return rcu_cpu_stall_suppress_at_boot && !rcu_inkernel_boot_has_ended();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #ifdef CONFIG_RCU_STALL_COMMON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) extern int rcu_cpu_stall_ftrace_dump;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) extern int rcu_cpu_stall_suppress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) extern int rcu_cpu_stall_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) int rcu_jiffies_till_stall_check(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static inline bool rcu_stall_is_suppressed(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	return rcu_stall_is_suppressed_at_boot() || rcu_cpu_stall_suppress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #define rcu_ftrace_dump_stall_suppress() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (!rcu_cpu_stall_suppress) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		rcu_cpu_stall_suppress = 3; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #define rcu_ftrace_dump_stall_unsuppress() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (rcu_cpu_stall_suppress == 3) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		rcu_cpu_stall_suppress = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #else /* #endif #ifdef CONFIG_RCU_STALL_COMMON */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static inline bool rcu_stall_is_suppressed(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	return rcu_stall_is_suppressed_at_boot();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #define rcu_ftrace_dump_stall_suppress()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #define rcu_ftrace_dump_stall_unsuppress()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #endif /* #ifdef CONFIG_RCU_STALL_COMMON */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * Strings used in tracepoints need to be exported via the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * tracing system such that tools like perf and trace-cmd can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  * translate the string address pointers to actual text.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define TPS(x)  tracepoint_string(x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  * Dump the ftrace buffer, but only one time per callsite per boot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) #define rcu_ftrace_dump(oops_dump_mode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	static atomic_t ___rfd_beenhere = ATOMIC_INIT(0); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	if (!atomic_read(&___rfd_beenhere) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	    !atomic_xchg(&___rfd_beenhere, 1)) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		tracing_off(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		rcu_ftrace_dump_stall_suppress(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		ftrace_dump(oops_dump_mode); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		rcu_ftrace_dump_stall_unsuppress(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) void rcu_early_boot_tests(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) void rcu_test_sync_prims(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * This function really isn't for public consumption, but RCU is special in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  * that context switches can allow the state machine to make progress.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) extern void resched_cpu(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) #if defined(CONFIG_SRCU) || !defined(CONFIG_TINY_RCU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #include <linux/rcu_node_tree.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) extern int rcu_num_lvls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) extern int num_rcu_lvl[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) extern int rcu_num_nodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static bool rcu_fanout_exact;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) static int rcu_fanout_leaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  * Compute the per-level fanout, either using the exact fanout specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  * or balancing the tree, depending on the rcu_fanout_exact boot parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	for (i = 0; i < RCU_NUM_LVLS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		levelspread[i] = INT_MIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (rcu_fanout_exact) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		levelspread[rcu_num_lvls - 1] = rcu_fanout_leaf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		for (i = rcu_num_lvls - 2; i >= 0; i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			levelspread[i] = RCU_FANOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		int ccur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		int cprv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		cprv = nr_cpu_ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		for (i = rcu_num_lvls - 1; i >= 0; i--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			ccur = levelcnt[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			levelspread[i] = (cprv + ccur - 1) / ccur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			cprv = ccur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) extern void rcu_init_geometry(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /* Returns a pointer to the first leaf rcu_node structure. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) #define rcu_first_leaf_node() (rcu_state.level[rcu_num_lvls - 1])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) /* Is this rcu_node a leaf? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #define rcu_is_leaf_node(rnp) ((rnp)->level == rcu_num_lvls - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) /* Is this rcu_node the last leaf? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #define rcu_is_last_leaf_node(rnp) ((rnp) == &rcu_state.node[rcu_num_nodes - 1])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  * Do a full breadth-first scan of the {s,}rcu_node structures for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  * specified state structure (for SRCU) or the only rcu_state structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)  * (for RCU).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) #define srcu_for_each_node_breadth_first(sp, rnp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	for ((rnp) = &(sp)->node[0]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	     (rnp) < &(sp)->node[rcu_num_nodes]; (rnp)++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #define rcu_for_each_node_breadth_first(rnp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	srcu_for_each_node_breadth_first(&rcu_state, rnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  * Scan the leaves of the rcu_node hierarchy for the rcu_state structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  * Note that if there is a singleton rcu_node tree with but one rcu_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  * structure, this loop -will- visit the rcu_node structure.  It is still
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)  * a leaf node, even if it is also the root node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) #define rcu_for_each_leaf_node(rnp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	for ((rnp) = rcu_first_leaf_node(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	     (rnp) < &rcu_state.node[rcu_num_nodes]; (rnp)++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  * Iterate over all possible CPUs in a leaf RCU node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) #define for_each_leaf_node_possible_cpu(rnp, cpu) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	     (cpu) = cpumask_next((rnp)->grplo - 1, cpu_possible_mask); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	     (cpu) <= rnp->grphi; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	     (cpu) = cpumask_next((cpu), cpu_possible_mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  * Iterate over all CPUs in a leaf RCU node's specified mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) #define rcu_find_next_bit(rnp, cpu, mask) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	((rnp)->grplo + find_next_bit(&(mask), BITS_PER_LONG, (cpu)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) #define for_each_leaf_node_cpu_mask(rnp, cpu, mask) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	for (WARN_ON_ONCE(!rcu_is_leaf_node(rnp)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	     (cpu) = rcu_find_next_bit((rnp), 0, (mask)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	     (cpu) <= rnp->grphi; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	     (cpu) = rcu_find_next_bit((rnp), (cpu) + 1 - (rnp->grplo), (mask)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  * Wrappers for the rcu_node::lock acquire and release.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)  * Because the rcu_nodes form a tree, the tree traversal locking will observe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)  * different lock values, this in turn means that an UNLOCK of one level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)  * followed by a LOCK of another level does not imply a full memory barrier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)  * and most importantly transitivity is lost.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  * In order to restore full ordering between tree levels, augment the regular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  * lock acquire functions with smp_mb__after_unlock_lock().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  * As ->lock of struct rcu_node is a __private field, therefore one should use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  * these wrappers rather than directly call raw_spin_{lock,unlock}* on ->lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) #define raw_spin_lock_rcu_node(p)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	raw_spin_lock(&ACCESS_PRIVATE(p, lock));			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	smp_mb__after_unlock_lock();					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) #define raw_spin_unlock_rcu_node(p) raw_spin_unlock(&ACCESS_PRIVATE(p, lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) #define raw_spin_lock_irq_rcu_node(p)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	raw_spin_lock_irq(&ACCESS_PRIVATE(p, lock));			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	smp_mb__after_unlock_lock();					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #define raw_spin_unlock_irq_rcu_node(p)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	raw_spin_unlock_irq(&ACCESS_PRIVATE(p, lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) #define raw_spin_lock_irqsave_rcu_node(p, flags)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	raw_spin_lock_irqsave(&ACCESS_PRIVATE(p, lock), flags);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	smp_mb__after_unlock_lock();					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) #define raw_spin_unlock_irqrestore_rcu_node(p, flags)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	raw_spin_unlock_irqrestore(&ACCESS_PRIVATE(p, lock), flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) #define raw_spin_trylock_rcu_node(p)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) ({									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	bool ___locked = raw_spin_trylock(&ACCESS_PRIVATE(p, lock));	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	if (___locked)							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		smp_mb__after_unlock_lock();				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	___locked;							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) #define raw_lockdep_assert_held_rcu_node(p)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	lockdep_assert_held(&ACCESS_PRIVATE(p, lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) #endif /* #if defined(CONFIG_SRCU) || !defined(CONFIG_TINY_RCU) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) #ifdef CONFIG_SRCU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) void srcu_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) #else /* #ifdef CONFIG_SRCU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) static inline void srcu_init(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) #endif /* #else #ifdef CONFIG_SRCU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) #ifdef CONFIG_TINY_RCU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) /* Tiny RCU doesn't expedite, as its purpose in life is instead to be tiny. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) static inline bool rcu_gp_is_normal(void) { return true; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) static inline bool rcu_gp_is_expedited(void) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) static inline void rcu_expedite_gp(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static inline void rcu_unexpedite_gp(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) static inline void rcu_request_urgent_qs_task(struct task_struct *t) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) #else /* #ifdef CONFIG_TINY_RCU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) bool rcu_gp_is_normal(void);     /* Internal RCU use. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) bool rcu_gp_is_expedited(void);  /* Internal RCU use. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) void rcu_expedite_gp(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) void rcu_unexpedite_gp(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) void rcupdate_announce_bootup_oddness(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) void show_rcu_tasks_gp_kthreads(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) void rcu_request_urgent_qs_task(struct task_struct *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) #endif /* #else #ifdef CONFIG_TINY_RCU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) #define RCU_SCHEDULER_INACTIVE	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) #define RCU_SCHEDULER_INIT	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) #define RCU_SCHEDULER_RUNNING	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) enum rcutorture_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	RCU_FLAVOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	RCU_TASKS_FLAVOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	RCU_TASKS_RUDE_FLAVOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	RCU_TASKS_TRACING_FLAVOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	RCU_TRIVIAL_FLAVOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	SRCU_FLAVOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	INVALID_RCU_FLAVOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) #if defined(CONFIG_TREE_RCU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 			    unsigned long *gp_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) void do_trace_rcu_torture_read(const char *rcutorturename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 			       struct rcu_head *rhp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 			       unsigned long secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 			       unsigned long c_old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 			       unsigned long c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) void rcu_gp_set_torture_wait(int duration);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) static inline void rcutorture_get_gp_data(enum rcutorture_type test_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 					  int *flags, unsigned long *gp_seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	*flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	*gp_seq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) #ifdef CONFIG_RCU_TRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) void do_trace_rcu_torture_read(const char *rcutorturename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 			       struct rcu_head *rhp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			       unsigned long secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 			       unsigned long c_old,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 			       unsigned long c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) #define do_trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	do { } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) static inline void rcu_gp_set_torture_wait(int duration) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) #if IS_ENABLED(CONFIG_RCU_TORTURE_TEST) || IS_MODULE(CONFIG_RCU_TORTURE_TEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) long rcutorture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) #ifdef CONFIG_TINY_SRCU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static inline void srcutorture_get_gp_data(enum rcutorture_type test_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 					   struct srcu_struct *sp, int *flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 					   unsigned long *gp_seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	if (test_type != SRCU_FLAVOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	*flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	*gp_seq = sp->srcu_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) #elif defined(CONFIG_TREE_SRCU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) void srcutorture_get_gp_data(enum rcutorture_type test_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 			     struct srcu_struct *sp, int *flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 			     unsigned long *gp_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) #ifdef CONFIG_TINY_RCU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) static inline bool rcu_dynticks_zero_in_eqs(int cpu, int *vp) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) static inline unsigned long rcu_get_gp_seq(void) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) static inline unsigned long rcu_exp_batches_completed(void) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) static inline unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) srcu_batches_completed(struct srcu_struct *sp) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) static inline void rcu_force_quiescent_state(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) static inline void show_rcu_gp_kthreads(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) static inline int rcu_get_gp_kthreads_prio(void) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) static inline void rcu_fwd_progress_check(unsigned long j) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) #else /* #ifdef CONFIG_TINY_RCU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) bool rcu_dynticks_zero_in_eqs(int cpu, int *vp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) unsigned long rcu_get_gp_seq(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) unsigned long rcu_exp_batches_completed(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) unsigned long srcu_batches_completed(struct srcu_struct *sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) void show_rcu_gp_kthreads(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) int rcu_get_gp_kthreads_prio(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) void rcu_fwd_progress_check(unsigned long j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) void rcu_force_quiescent_state(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) extern struct workqueue_struct *rcu_gp_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) extern struct workqueue_struct *rcu_par_gp_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) #endif /* #else #ifdef CONFIG_TINY_RCU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) #ifdef CONFIG_RCU_NOCB_CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) bool rcu_is_nocb_cpu(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) void rcu_bind_current_to_nocb(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) static inline bool rcu_is_nocb_cpu(int cpu) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) static inline void rcu_bind_current_to_nocb(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) #endif /* __LINUX_RCU_H */