rcu.h 21 KB

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