tree.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Read-Copy Update mechanism for mutual exclusion (tree-based version)
  4. * Internal non-public definitions.
  5. *
  6. * Copyright IBM Corporation, 2008
  7. *
  8. * Author: Ingo Molnar <[email protected]>
  9. * Paul E. McKenney <[email protected]>
  10. */
  11. #include <linux/cache.h>
  12. #include <linux/kthread.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/rtmutex.h>
  15. #include <linux/threads.h>
  16. #include <linux/cpumask.h>
  17. #include <linux/seqlock.h>
  18. #include <linux/swait.h>
  19. #include <linux/rcu_node_tree.h>
  20. #include "rcu_segcblist.h"
  21. /* Communicate arguments to a workqueue handler. */
  22. struct rcu_exp_work {
  23. unsigned long rew_s;
  24. #ifdef CONFIG_RCU_EXP_KTHREAD
  25. struct kthread_work rew_work;
  26. #else
  27. struct work_struct rew_work;
  28. #endif /* CONFIG_RCU_EXP_KTHREAD */
  29. };
  30. /* RCU's kthread states for tracing. */
  31. #define RCU_KTHREAD_STOPPED 0
  32. #define RCU_KTHREAD_RUNNING 1
  33. #define RCU_KTHREAD_WAITING 2
  34. #define RCU_KTHREAD_OFFCPU 3
  35. #define RCU_KTHREAD_YIELDING 4
  36. #define RCU_KTHREAD_MAX 4
  37. /*
  38. * Definition for node within the RCU grace-period-detection hierarchy.
  39. */
  40. struct rcu_node {
  41. raw_spinlock_t __private lock; /* Root rcu_node's lock protects */
  42. /* some rcu_state fields as well as */
  43. /* following. */
  44. unsigned long gp_seq; /* Track rsp->gp_seq. */
  45. unsigned long gp_seq_needed; /* Track furthest future GP request. */
  46. unsigned long completedqs; /* All QSes done for this node. */
  47. unsigned long qsmask; /* CPUs or groups that need to switch in */
  48. /* order for current grace period to proceed.*/
  49. /* In leaf rcu_node, each bit corresponds to */
  50. /* an rcu_data structure, otherwise, each */
  51. /* bit corresponds to a child rcu_node */
  52. /* structure. */
  53. unsigned long rcu_gp_init_mask; /* Mask of offline CPUs at GP init. */
  54. unsigned long qsmaskinit;
  55. /* Per-GP initial value for qsmask. */
  56. /* Initialized from ->qsmaskinitnext at the */
  57. /* beginning of each grace period. */
  58. unsigned long qsmaskinitnext;
  59. unsigned long expmask; /* CPUs or groups that need to check in */
  60. /* to allow the current expedited GP */
  61. /* to complete. */
  62. unsigned long expmaskinit;
  63. /* Per-GP initial values for expmask. */
  64. /* Initialized from ->expmaskinitnext at the */
  65. /* beginning of each expedited GP. */
  66. unsigned long expmaskinitnext;
  67. /* Online CPUs for next expedited GP. */
  68. /* Any CPU that has ever been online will */
  69. /* have its bit set. */
  70. unsigned long cbovldmask;
  71. /* CPUs experiencing callback overload. */
  72. unsigned long ffmask; /* Fully functional CPUs. */
  73. unsigned long grpmask; /* Mask to apply to parent qsmask. */
  74. /* Only one bit will be set in this mask. */
  75. int grplo; /* lowest-numbered CPU here. */
  76. int grphi; /* highest-numbered CPU here. */
  77. u8 grpnum; /* group number for next level up. */
  78. u8 level; /* root is at level 0. */
  79. bool wait_blkd_tasks;/* Necessary to wait for blocked tasks to */
  80. /* exit RCU read-side critical sections */
  81. /* before propagating offline up the */
  82. /* rcu_node tree? */
  83. struct rcu_node *parent;
  84. struct list_head blkd_tasks;
  85. /* Tasks blocked in RCU read-side critical */
  86. /* section. Tasks are placed at the head */
  87. /* of this list and age towards the tail. */
  88. struct list_head *gp_tasks;
  89. /* Pointer to the first task blocking the */
  90. /* current grace period, or NULL if there */
  91. /* is no such task. */
  92. struct list_head *exp_tasks;
  93. /* Pointer to the first task blocking the */
  94. /* current expedited grace period, or NULL */
  95. /* if there is no such task. If there */
  96. /* is no current expedited grace period, */
  97. /* then there can cannot be any such task. */
  98. struct list_head *boost_tasks;
  99. /* Pointer to first task that needs to be */
  100. /* priority boosted, or NULL if no priority */
  101. /* boosting is needed for this rcu_node */
  102. /* structure. If there are no tasks */
  103. /* queued on this rcu_node structure that */
  104. /* are blocking the current grace period, */
  105. /* there can be no such task. */
  106. struct rt_mutex boost_mtx;
  107. /* Used only for the priority-boosting */
  108. /* side effect, not as a lock. */
  109. unsigned long boost_time;
  110. /* When to start boosting (jiffies). */
  111. struct mutex boost_kthread_mutex;
  112. /* Exclusion for thread spawning and affinity */
  113. /* manipulation. */
  114. struct task_struct *boost_kthread_task;
  115. /* kthread that takes care of priority */
  116. /* boosting for this rcu_node structure. */
  117. unsigned int boost_kthread_status;
  118. /* State of boost_kthread_task for tracing. */
  119. unsigned long n_boosts; /* Number of boosts for this rcu_node structure. */
  120. #ifdef CONFIG_RCU_NOCB_CPU
  121. struct swait_queue_head nocb_gp_wq[2];
  122. /* Place for rcu_nocb_kthread() to wait GP. */
  123. #endif /* #ifdef CONFIG_RCU_NOCB_CPU */
  124. raw_spinlock_t fqslock ____cacheline_internodealigned_in_smp;
  125. spinlock_t exp_lock ____cacheline_internodealigned_in_smp;
  126. unsigned long exp_seq_rq;
  127. wait_queue_head_t exp_wq[4];
  128. struct rcu_exp_work rew;
  129. bool exp_need_flush; /* Need to flush workitem? */
  130. raw_spinlock_t exp_poll_lock;
  131. /* Lock and data for polled expedited grace periods. */
  132. unsigned long exp_seq_poll_rq;
  133. struct work_struct exp_poll_wq;
  134. } ____cacheline_internodealigned_in_smp;
  135. /*
  136. * Bitmasks in an rcu_node cover the interval [grplo, grphi] of CPU IDs, and
  137. * are indexed relative to this interval rather than the global CPU ID space.
  138. * This generates the bit for a CPU in node-local masks.
  139. */
  140. #define leaf_node_cpu_bit(rnp, cpu) (BIT((cpu) - (rnp)->grplo))
  141. /*
  142. * Union to allow "aggregate OR" operation on the need for a quiescent
  143. * state by the normal and expedited grace periods.
  144. */
  145. union rcu_noqs {
  146. struct {
  147. u8 norm;
  148. u8 exp;
  149. } b; /* Bits. */
  150. u16 s; /* Set of bits, aggregate OR here. */
  151. };
  152. /* Per-CPU data for read-copy update. */
  153. struct rcu_data {
  154. /* 1) quiescent-state and grace-period handling : */
  155. unsigned long gp_seq; /* Track rsp->gp_seq counter. */
  156. unsigned long gp_seq_needed; /* Track furthest future GP request. */
  157. union rcu_noqs cpu_no_qs; /* No QSes yet for this CPU. */
  158. bool core_needs_qs; /* Core waits for quiescent state. */
  159. bool beenonline; /* CPU online at least once. */
  160. bool gpwrap; /* Possible ->gp_seq wrap. */
  161. bool cpu_started; /* RCU watching this onlining CPU. */
  162. struct rcu_node *mynode; /* This CPU's leaf of hierarchy */
  163. unsigned long grpmask; /* Mask to apply to leaf qsmask. */
  164. unsigned long ticks_this_gp; /* The number of scheduling-clock */
  165. /* ticks this CPU has handled */
  166. /* during and after the last grace */
  167. /* period it is aware of. */
  168. struct irq_work defer_qs_iw; /* Obtain later scheduler attention. */
  169. bool defer_qs_iw_pending; /* Scheduler attention pending? */
  170. struct work_struct strict_work; /* Schedule readers for strict GPs. */
  171. /* 2) batch handling */
  172. struct rcu_segcblist cblist; /* Segmented callback list, with */
  173. /* different callbacks waiting for */
  174. /* different grace periods. */
  175. long qlen_last_fqs_check;
  176. /* qlen at last check for QS forcing */
  177. unsigned long n_cbs_invoked; /* # callbacks invoked since boot. */
  178. unsigned long n_force_qs_snap;
  179. /* did other CPU force QS recently? */
  180. long blimit; /* Upper limit on a processed batch */
  181. /* 3) dynticks interface. */
  182. int dynticks_snap; /* Per-GP tracking for dynticks. */
  183. bool rcu_need_heavy_qs; /* GP old, so heavy quiescent state! */
  184. bool rcu_urgent_qs; /* GP old need light quiescent state. */
  185. bool rcu_forced_tick; /* Forced tick to provide QS. */
  186. bool rcu_forced_tick_exp; /* ... provide QS to expedited GP. */
  187. /* 4) rcu_barrier(), OOM callbacks, and expediting. */
  188. unsigned long barrier_seq_snap; /* Snap of rcu_state.barrier_sequence. */
  189. struct rcu_head barrier_head;
  190. int exp_dynticks_snap; /* Double-check need for IPI. */
  191. /* 5) Callback offloading. */
  192. #ifdef CONFIG_RCU_NOCB_CPU
  193. struct swait_queue_head nocb_cb_wq; /* For nocb kthreads to sleep on. */
  194. struct swait_queue_head nocb_state_wq; /* For offloading state changes */
  195. struct task_struct *nocb_gp_kthread;
  196. raw_spinlock_t nocb_lock; /* Guard following pair of fields. */
  197. atomic_t nocb_lock_contended; /* Contention experienced. */
  198. int nocb_defer_wakeup; /* Defer wakeup of nocb_kthread. */
  199. struct timer_list nocb_timer; /* Enforce finite deferral. */
  200. unsigned long nocb_gp_adv_time; /* Last call_rcu() CB adv (jiffies). */
  201. struct mutex nocb_gp_kthread_mutex; /* Exclusion for nocb gp kthread */
  202. /* spawning */
  203. /* The following fields are used by call_rcu, hence own cacheline. */
  204. raw_spinlock_t nocb_bypass_lock ____cacheline_internodealigned_in_smp;
  205. struct rcu_cblist nocb_bypass; /* Lock-contention-bypass CB list. */
  206. unsigned long nocb_bypass_first; /* Time (jiffies) of first enqueue. */
  207. unsigned long nocb_nobypass_last; /* Last ->cblist enqueue (jiffies). */
  208. int nocb_nobypass_count; /* # ->cblist enqueues at ^^^ time. */
  209. /* The following fields are used by GP kthread, hence own cacheline. */
  210. raw_spinlock_t nocb_gp_lock ____cacheline_internodealigned_in_smp;
  211. u8 nocb_gp_sleep; /* Is the nocb GP thread asleep? */
  212. u8 nocb_gp_bypass; /* Found a bypass on last scan? */
  213. u8 nocb_gp_gp; /* GP to wait for on last scan? */
  214. unsigned long nocb_gp_seq; /* If so, ->gp_seq to wait for. */
  215. unsigned long nocb_gp_loops; /* # passes through wait code. */
  216. struct swait_queue_head nocb_gp_wq; /* For nocb kthreads to sleep on. */
  217. bool nocb_cb_sleep; /* Is the nocb CB thread asleep? */
  218. struct task_struct *nocb_cb_kthread;
  219. struct list_head nocb_head_rdp; /*
  220. * Head of rcu_data list in wakeup chain,
  221. * if rdp_gp.
  222. */
  223. struct list_head nocb_entry_rdp; /* rcu_data node in wakeup chain. */
  224. struct rcu_data *nocb_toggling_rdp; /* rdp queued for (de-)offloading */
  225. /* The following fields are used by CB kthread, hence new cacheline. */
  226. struct rcu_data *nocb_gp_rdp ____cacheline_internodealigned_in_smp;
  227. /* GP rdp takes GP-end wakeups. */
  228. #endif /* #ifdef CONFIG_RCU_NOCB_CPU */
  229. /* 6) RCU priority boosting. */
  230. struct task_struct *rcu_cpu_kthread_task;
  231. /* rcuc per-CPU kthread or NULL. */
  232. unsigned int rcu_cpu_kthread_status;
  233. char rcu_cpu_has_work;
  234. unsigned long rcuc_activity;
  235. /* 7) Diagnostic data, including RCU CPU stall warnings. */
  236. unsigned int softirq_snap; /* Snapshot of softirq activity. */
  237. /* ->rcu_iw* fields protected by leaf rcu_node ->lock. */
  238. struct irq_work rcu_iw; /* Check for non-irq activity. */
  239. bool rcu_iw_pending; /* Is ->rcu_iw pending? */
  240. unsigned long rcu_iw_gp_seq; /* ->gp_seq associated with ->rcu_iw. */
  241. unsigned long rcu_ofl_gp_seq; /* ->gp_seq at last offline. */
  242. short rcu_ofl_gp_flags; /* ->gp_flags at last offline. */
  243. unsigned long rcu_onl_gp_seq; /* ->gp_seq at last online. */
  244. short rcu_onl_gp_flags; /* ->gp_flags at last online. */
  245. unsigned long last_fqs_resched; /* Time of last rcu_resched(). */
  246. unsigned long last_sched_clock; /* Jiffies of last rcu_sched_clock_irq(). */
  247. long lazy_len; /* Length of buffered lazy callbacks. */
  248. int cpu;
  249. };
  250. /* Values for nocb_defer_wakeup field in struct rcu_data. */
  251. #define RCU_NOCB_WAKE_NOT 0
  252. #define RCU_NOCB_WAKE_BYPASS 1
  253. #define RCU_NOCB_WAKE_LAZY 2
  254. #define RCU_NOCB_WAKE 3
  255. #define RCU_NOCB_WAKE_FORCE 4
  256. #define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500))
  257. /* For jiffies_till_first_fqs and */
  258. /* and jiffies_till_next_fqs. */
  259. #define RCU_JIFFIES_FQS_DIV 256 /* Very large systems need more */
  260. /* delay between bouts of */
  261. /* quiescent-state forcing. */
  262. #define RCU_STALL_RAT_DELAY 2 /* Allow other CPUs time to take */
  263. /* at least one scheduling clock */
  264. /* irq before ratting on them. */
  265. #define rcu_wait(cond) \
  266. do { \
  267. for (;;) { \
  268. set_current_state(TASK_INTERRUPTIBLE); \
  269. if (cond) \
  270. break; \
  271. schedule(); \
  272. } \
  273. __set_current_state(TASK_RUNNING); \
  274. } while (0)
  275. /*
  276. * RCU global state, including node hierarchy. This hierarchy is
  277. * represented in "heap" form in a dense array. The root (first level)
  278. * of the hierarchy is in ->node[0] (referenced by ->level[0]), the second
  279. * level in ->node[1] through ->node[m] (->node[1] referenced by ->level[1]),
  280. * and the third level in ->node[m+1] and following (->node[m+1] referenced
  281. * by ->level[2]). The number of levels is determined by the number of
  282. * CPUs and by CONFIG_RCU_FANOUT. Small systems will have a "hierarchy"
  283. * consisting of a single rcu_node.
  284. */
  285. struct rcu_state {
  286. struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */
  287. struct rcu_node *level[RCU_NUM_LVLS + 1];
  288. /* Hierarchy levels (+1 to */
  289. /* shut bogus gcc warning) */
  290. int ncpus; /* # CPUs seen so far. */
  291. int n_online_cpus; /* # CPUs online for RCU. */
  292. /* The following fields are guarded by the root rcu_node's lock. */
  293. unsigned long gp_seq ____cacheline_internodealigned_in_smp;
  294. /* Grace-period sequence #. */
  295. unsigned long gp_max; /* Maximum GP duration in */
  296. /* jiffies. */
  297. struct task_struct *gp_kthread; /* Task for grace periods. */
  298. struct swait_queue_head gp_wq; /* Where GP task waits. */
  299. short gp_flags; /* Commands for GP task. */
  300. short gp_state; /* GP kthread sleep state. */
  301. unsigned long gp_wake_time; /* Last GP kthread wake. */
  302. unsigned long gp_wake_seq; /* ->gp_seq at ^^^. */
  303. unsigned long gp_seq_polled; /* GP seq for polled API. */
  304. unsigned long gp_seq_polled_snap; /* ->gp_seq_polled at normal GP start. */
  305. unsigned long gp_seq_polled_exp_snap; /* ->gp_seq_polled at expedited GP start. */
  306. /* End of fields guarded by root rcu_node's lock. */
  307. struct mutex barrier_mutex; /* Guards barrier fields. */
  308. atomic_t barrier_cpu_count; /* # CPUs waiting on. */
  309. struct completion barrier_completion; /* Wake at barrier end. */
  310. unsigned long barrier_sequence; /* ++ at start and end of */
  311. /* rcu_barrier(). */
  312. /* End of fields guarded by barrier_mutex. */
  313. raw_spinlock_t barrier_lock; /* Protects ->barrier_seq_snap. */
  314. struct mutex exp_mutex; /* Serialize expedited GP. */
  315. struct mutex exp_wake_mutex; /* Serialize wakeup. */
  316. unsigned long expedited_sequence; /* Take a ticket. */
  317. atomic_t expedited_need_qs; /* # CPUs left to check in. */
  318. struct swait_queue_head expedited_wq; /* Wait for check-ins. */
  319. int ncpus_snap; /* # CPUs seen last time. */
  320. u8 cbovld; /* Callback overload now? */
  321. u8 cbovldnext; /* ^ ^ next time? */
  322. unsigned long jiffies_force_qs; /* Time at which to invoke */
  323. /* force_quiescent_state(). */
  324. unsigned long jiffies_kick_kthreads; /* Time at which to kick */
  325. /* kthreads, if configured. */
  326. unsigned long n_force_qs; /* Number of calls to */
  327. /* force_quiescent_state(). */
  328. unsigned long gp_start; /* Time at which GP started, */
  329. /* but in jiffies. */
  330. unsigned long gp_end; /* Time last GP ended, again */
  331. /* in jiffies. */
  332. unsigned long gp_activity; /* Time of last GP kthread */
  333. /* activity in jiffies. */
  334. unsigned long gp_req_activity; /* Time of last GP request */
  335. /* in jiffies. */
  336. unsigned long jiffies_stall; /* Time at which to check */
  337. /* for CPU stalls. */
  338. int nr_fqs_jiffies_stall; /* Number of fqs loops after
  339. * which read jiffies and set
  340. * jiffies_stall. Stall
  341. * warnings disabled if !0. */
  342. unsigned long jiffies_resched; /* Time at which to resched */
  343. /* a reluctant CPU. */
  344. unsigned long n_force_qs_gpstart; /* Snapshot of n_force_qs at */
  345. /* GP start. */
  346. const char *name; /* Name of structure. */
  347. char abbr; /* Abbreviated name. */
  348. arch_spinlock_t ofl_lock ____cacheline_internodealigned_in_smp;
  349. /* Synchronize offline with */
  350. /* GP pre-initialization. */
  351. int nocb_is_setup; /* nocb is setup from boot */
  352. };
  353. /* Values for rcu_state structure's gp_flags field. */
  354. #define RCU_GP_FLAG_INIT 0x1 /* Need grace-period initialization. */
  355. #define RCU_GP_FLAG_FQS 0x2 /* Need grace-period quiescent-state forcing. */
  356. #define RCU_GP_FLAG_OVLD 0x4 /* Experiencing callback overload. */
  357. /* Values for rcu_state structure's gp_state field. */
  358. #define RCU_GP_IDLE 0 /* Initial state and no GP in progress. */
  359. #define RCU_GP_WAIT_GPS 1 /* Wait for grace-period start. */
  360. #define RCU_GP_DONE_GPS 2 /* Wait done for grace-period start. */
  361. #define RCU_GP_ONOFF 3 /* Grace-period initialization hotplug. */
  362. #define RCU_GP_INIT 4 /* Grace-period initialization. */
  363. #define RCU_GP_WAIT_FQS 5 /* Wait for force-quiescent-state time. */
  364. #define RCU_GP_DOING_FQS 6 /* Wait done for force-quiescent-state time. */
  365. #define RCU_GP_CLEANUP 7 /* Grace-period cleanup started. */
  366. #define RCU_GP_CLEANED 8 /* Grace-period cleanup complete. */
  367. /*
  368. * In order to export the rcu_state name to the tracing tools, it
  369. * needs to be added in the __tracepoint_string section.
  370. * This requires defining a separate variable tp_<sname>_varname
  371. * that points to the string being used, and this will allow
  372. * the tracing userspace tools to be able to decipher the string
  373. * address to the matching string.
  374. */
  375. #ifdef CONFIG_PREEMPT_RCU
  376. #define RCU_ABBR 'p'
  377. #define RCU_NAME_RAW "rcu_preempt"
  378. #else /* #ifdef CONFIG_PREEMPT_RCU */
  379. #define RCU_ABBR 's'
  380. #define RCU_NAME_RAW "rcu_sched"
  381. #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
  382. #ifndef CONFIG_TRACING
  383. #define RCU_NAME RCU_NAME_RAW
  384. #else /* #ifdef CONFIG_TRACING */
  385. static char rcu_name[] = RCU_NAME_RAW;
  386. static const char *tp_rcu_varname __used __tracepoint_string = rcu_name;
  387. #define RCU_NAME rcu_name
  388. #endif /* #else #ifdef CONFIG_TRACING */
  389. /* Forward declarations for tree_plugin.h */
  390. static void rcu_bootup_announce(void);
  391. static void rcu_qs(void);
  392. static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp);
  393. #ifdef CONFIG_HOTPLUG_CPU
  394. static bool rcu_preempt_has_tasks(struct rcu_node *rnp);
  395. #endif /* #ifdef CONFIG_HOTPLUG_CPU */
  396. static int rcu_print_task_exp_stall(struct rcu_node *rnp);
  397. static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp);
  398. static void rcu_flavor_sched_clock_irq(int user);
  399. static void dump_blkd_tasks(struct rcu_node *rnp, int ncheck);
  400. static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
  401. static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
  402. static bool rcu_is_callbacks_kthread(struct rcu_data *rdp);
  403. static void rcu_cpu_kthread_setup(unsigned int cpu);
  404. static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp);
  405. static bool rcu_preempt_has_tasks(struct rcu_node *rnp);
  406. static bool rcu_preempt_need_deferred_qs(struct task_struct *t);
  407. static void zero_cpu_stall_ticks(struct rcu_data *rdp);
  408. static struct swait_queue_head *rcu_nocb_gp_get(struct rcu_node *rnp);
  409. static void rcu_nocb_gp_cleanup(struct swait_queue_head *sq);
  410. static void rcu_init_one_nocb(struct rcu_node *rnp);
  411. static bool wake_nocb_gp(struct rcu_data *rdp, bool force);
  412. static bool rcu_nocb_flush_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
  413. unsigned long j, bool lazy);
  414. static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp,
  415. bool *was_alldone, unsigned long flags,
  416. bool lazy);
  417. static void __call_rcu_nocb_wake(struct rcu_data *rdp, bool was_empty,
  418. unsigned long flags);
  419. static int rcu_nocb_need_deferred_wakeup(struct rcu_data *rdp, int level);
  420. static bool do_nocb_deferred_wakeup(struct rcu_data *rdp);
  421. static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp);
  422. static void rcu_spawn_cpu_nocb_kthread(int cpu);
  423. static void show_rcu_nocb_state(struct rcu_data *rdp);
  424. static void rcu_nocb_lock(struct rcu_data *rdp);
  425. static void rcu_nocb_unlock(struct rcu_data *rdp);
  426. static void rcu_nocb_unlock_irqrestore(struct rcu_data *rdp,
  427. unsigned long flags);
  428. static void rcu_lockdep_assert_cblist_protected(struct rcu_data *rdp);
  429. #ifdef CONFIG_RCU_NOCB_CPU
  430. static void __init rcu_organize_nocb_kthreads(void);
  431. /*
  432. * Disable IRQs before checking offloaded state so that local
  433. * locking is safe against concurrent de-offloading.
  434. */
  435. #define rcu_nocb_lock_irqsave(rdp, flags) \
  436. do { \
  437. local_irq_save(flags); \
  438. if (rcu_segcblist_is_offloaded(&(rdp)->cblist)) \
  439. raw_spin_lock(&(rdp)->nocb_lock); \
  440. } while (0)
  441. #else /* #ifdef CONFIG_RCU_NOCB_CPU */
  442. #define rcu_nocb_lock_irqsave(rdp, flags) local_irq_save(flags)
  443. #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */
  444. static void rcu_bind_gp_kthread(void);
  445. static bool rcu_nohz_full_cpu(void);
  446. /* Forward declarations for tree_stall.h */
  447. static void record_gp_stall_check_time(void);
  448. static void rcu_iw_handler(struct irq_work *iwp);
  449. static void check_cpu_stall(struct rcu_data *rdp);
  450. static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp,
  451. const unsigned long gpssdelay);
  452. /* Forward declarations for tree_exp.h. */
  453. static void sync_rcu_do_polled_gp(struct work_struct *wp);