rcutree_plugin.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. /*
  2. * Read-Copy Update mechanism for mutual exclusion (tree-based version)
  3. * Internal non-public definitions that provide either classic
  4. * or preemptable semantics.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. *
  20. * Copyright Red Hat, 2009
  21. * Copyright IBM Corporation, 2009
  22. *
  23. * Author: Ingo Molnar <mingo@elte.hu>
  24. * Paul E. McKenney <paulmck@linux.vnet.ibm.com>
  25. */
  26. #ifdef CONFIG_TREE_PREEMPT_RCU
  27. struct rcu_state rcu_preempt_state = RCU_STATE_INITIALIZER(rcu_preempt_state);
  28. DEFINE_PER_CPU(struct rcu_data, rcu_preempt_data);
  29. /*
  30. * Tell them what RCU they are running.
  31. */
  32. static void __init rcu_bootup_announce(void)
  33. {
  34. printk(KERN_INFO
  35. "Experimental preemptable hierarchical RCU implementation.\n");
  36. }
  37. /*
  38. * Return the number of RCU-preempt batches processed thus far
  39. * for debug and statistics.
  40. */
  41. long rcu_batches_completed_preempt(void)
  42. {
  43. return rcu_preempt_state.completed;
  44. }
  45. EXPORT_SYMBOL_GPL(rcu_batches_completed_preempt);
  46. /*
  47. * Return the number of RCU batches processed thus far for debug & stats.
  48. */
  49. long rcu_batches_completed(void)
  50. {
  51. return rcu_batches_completed_preempt();
  52. }
  53. EXPORT_SYMBOL_GPL(rcu_batches_completed);
  54. /*
  55. * Record a preemptable-RCU quiescent state for the specified CPU. Note
  56. * that this just means that the task currently running on the CPU is
  57. * not in a quiescent state. There might be any number of tasks blocked
  58. * while in an RCU read-side critical section.
  59. */
  60. static void rcu_preempt_qs(int cpu)
  61. {
  62. struct rcu_data *rdp = &per_cpu(rcu_preempt_data, cpu);
  63. rdp->passed_quiesc_completed = rdp->gpnum - 1;
  64. barrier();
  65. rdp->passed_quiesc = 1;
  66. }
  67. /*
  68. * We have entered the scheduler, and the current task might soon be
  69. * context-switched away from. If this task is in an RCU read-side
  70. * critical section, we will no longer be able to rely on the CPU to
  71. * record that fact, so we enqueue the task on the appropriate entry
  72. * of the blocked_tasks[] array. The task will dequeue itself when
  73. * it exits the outermost enclosing RCU read-side critical section.
  74. * Therefore, the current grace period cannot be permitted to complete
  75. * until the blocked_tasks[] entry indexed by the low-order bit of
  76. * rnp->gpnum empties.
  77. *
  78. * Caller must disable preemption.
  79. */
  80. static void rcu_preempt_note_context_switch(int cpu)
  81. {
  82. struct task_struct *t = current;
  83. unsigned long flags;
  84. int phase;
  85. struct rcu_data *rdp;
  86. struct rcu_node *rnp;
  87. if (t->rcu_read_lock_nesting &&
  88. (t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) {
  89. /* Possibly blocking in an RCU read-side critical section. */
  90. rdp = rcu_preempt_state.rda[cpu];
  91. rnp = rdp->mynode;
  92. spin_lock_irqsave(&rnp->lock, flags);
  93. t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED;
  94. t->rcu_blocked_node = rnp;
  95. /*
  96. * If this CPU has already checked in, then this task
  97. * will hold up the next grace period rather than the
  98. * current grace period. Queue the task accordingly.
  99. * If the task is queued for the current grace period
  100. * (i.e., this CPU has not yet passed through a quiescent
  101. * state for the current grace period), then as long
  102. * as that task remains queued, the current grace period
  103. * cannot end.
  104. *
  105. * But first, note that the current CPU must still be
  106. * on line!
  107. */
  108. WARN_ON_ONCE((rdp->grpmask & rnp->qsmaskinit) == 0);
  109. WARN_ON_ONCE(!list_empty(&t->rcu_node_entry));
  110. phase = (rnp->gpnum + !(rnp->qsmask & rdp->grpmask)) & 0x1;
  111. list_add(&t->rcu_node_entry, &rnp->blocked_tasks[phase]);
  112. spin_unlock_irqrestore(&rnp->lock, flags);
  113. }
  114. /*
  115. * Either we were not in an RCU read-side critical section to
  116. * begin with, or we have now recorded that critical section
  117. * globally. Either way, we can now note a quiescent state
  118. * for this CPU. Again, if we were in an RCU read-side critical
  119. * section, and if that critical section was blocking the current
  120. * grace period, then the fact that the task has been enqueued
  121. * means that we continue to block the current grace period.
  122. */
  123. rcu_preempt_qs(cpu);
  124. local_irq_save(flags);
  125. t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
  126. local_irq_restore(flags);
  127. }
  128. /*
  129. * Tree-preemptable RCU implementation for rcu_read_lock().
  130. * Just increment ->rcu_read_lock_nesting, shared state will be updated
  131. * if we block.
  132. */
  133. void __rcu_read_lock(void)
  134. {
  135. ACCESS_ONCE(current->rcu_read_lock_nesting)++;
  136. barrier(); /* needed if we ever invoke rcu_read_lock in rcutree.c */
  137. }
  138. EXPORT_SYMBOL_GPL(__rcu_read_lock);
  139. /*
  140. * Check for preempted RCU readers blocking the current grace period
  141. * for the specified rcu_node structure. If the caller needs a reliable
  142. * answer, it must hold the rcu_node's ->lock.
  143. */
  144. static int rcu_preempted_readers(struct rcu_node *rnp)
  145. {
  146. return !list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1]);
  147. }
  148. /*
  149. * Record a quiescent state for all tasks that were previously queued
  150. * on the specified rcu_node structure and that were blocking the current
  151. * RCU grace period. The caller must hold the specified rnp->lock with
  152. * irqs disabled, and this lock is released upon return, but irqs remain
  153. * disabled.
  154. */
  155. static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags)
  156. __releases(rnp->lock)
  157. {
  158. unsigned long mask;
  159. struct rcu_node *rnp_p;
  160. if (rnp->qsmask != 0 || rcu_preempted_readers(rnp)) {
  161. spin_unlock_irqrestore(&rnp->lock, flags);
  162. return; /* Still need more quiescent states! */
  163. }
  164. rnp_p = rnp->parent;
  165. if (rnp_p == NULL) {
  166. /*
  167. * Either there is only one rcu_node in the tree,
  168. * or tasks were kicked up to root rcu_node due to
  169. * CPUs going offline.
  170. */
  171. rcu_report_qs_rsp(&rcu_preempt_state, flags);
  172. return;
  173. }
  174. /* Report up the rest of the hierarchy. */
  175. mask = rnp->grpmask;
  176. spin_unlock(&rnp->lock); /* irqs remain disabled. */
  177. spin_lock(&rnp_p->lock); /* irqs already disabled. */
  178. rcu_report_qs_rnp(mask, &rcu_preempt_state, rnp_p, flags);
  179. }
  180. /*
  181. * Handle special cases during rcu_read_unlock(), such as needing to
  182. * notify RCU core processing or task having blocked during the RCU
  183. * read-side critical section.
  184. */
  185. static void rcu_read_unlock_special(struct task_struct *t)
  186. {
  187. int empty;
  188. unsigned long flags;
  189. struct rcu_node *rnp;
  190. int special;
  191. /* NMI handlers cannot block and cannot safely manipulate state. */
  192. if (in_nmi())
  193. return;
  194. local_irq_save(flags);
  195. /*
  196. * If RCU core is waiting for this CPU to exit critical section,
  197. * let it know that we have done so.
  198. */
  199. special = t->rcu_read_unlock_special;
  200. if (special & RCU_READ_UNLOCK_NEED_QS) {
  201. t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
  202. rcu_preempt_qs(smp_processor_id());
  203. }
  204. /* Hardware IRQ handlers cannot block. */
  205. if (in_irq()) {
  206. local_irq_restore(flags);
  207. return;
  208. }
  209. /* Clean up if blocked during RCU read-side critical section. */
  210. if (special & RCU_READ_UNLOCK_BLOCKED) {
  211. t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_BLOCKED;
  212. /*
  213. * Remove this task from the list it blocked on. The
  214. * task can migrate while we acquire the lock, but at
  215. * most one time. So at most two passes through loop.
  216. */
  217. for (;;) {
  218. rnp = t->rcu_blocked_node;
  219. spin_lock(&rnp->lock); /* irqs already disabled. */
  220. if (rnp == t->rcu_blocked_node)
  221. break;
  222. spin_unlock(&rnp->lock); /* irqs remain disabled. */
  223. }
  224. empty = !rcu_preempted_readers(rnp);
  225. list_del_init(&t->rcu_node_entry);
  226. t->rcu_blocked_node = NULL;
  227. /*
  228. * If this was the last task on the current list, and if
  229. * we aren't waiting on any CPUs, report the quiescent state.
  230. * Note that rcu_report_unblock_qs_rnp() releases rnp->lock.
  231. */
  232. if (empty)
  233. spin_unlock_irqrestore(&rnp->lock, flags);
  234. else
  235. rcu_report_unblock_qs_rnp(rnp, flags);
  236. } else {
  237. local_irq_restore(flags);
  238. }
  239. }
  240. /*
  241. * Tree-preemptable RCU implementation for rcu_read_unlock().
  242. * Decrement ->rcu_read_lock_nesting. If the result is zero (outermost
  243. * rcu_read_unlock()) and ->rcu_read_unlock_special is non-zero, then
  244. * invoke rcu_read_unlock_special() to clean up after a context switch
  245. * in an RCU read-side critical section and other special cases.
  246. */
  247. void __rcu_read_unlock(void)
  248. {
  249. struct task_struct *t = current;
  250. barrier(); /* needed if we ever invoke rcu_read_unlock in rcutree.c */
  251. if (--ACCESS_ONCE(t->rcu_read_lock_nesting) == 0 &&
  252. unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
  253. rcu_read_unlock_special(t);
  254. }
  255. EXPORT_SYMBOL_GPL(__rcu_read_unlock);
  256. #ifdef CONFIG_RCU_CPU_STALL_DETECTOR
  257. /*
  258. * Scan the current list of tasks blocked within RCU read-side critical
  259. * sections, printing out the tid of each.
  260. */
  261. static void rcu_print_task_stall(struct rcu_node *rnp)
  262. {
  263. unsigned long flags;
  264. struct list_head *lp;
  265. int phase;
  266. struct task_struct *t;
  267. if (rcu_preempted_readers(rnp)) {
  268. spin_lock_irqsave(&rnp->lock, flags);
  269. phase = rnp->gpnum & 0x1;
  270. lp = &rnp->blocked_tasks[phase];
  271. list_for_each_entry(t, lp, rcu_node_entry)
  272. printk(" P%d", t->pid);
  273. spin_unlock_irqrestore(&rnp->lock, flags);
  274. }
  275. }
  276. #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
  277. /*
  278. * Check that the list of blocked tasks for the newly completed grace
  279. * period is in fact empty. It is a serious bug to complete a grace
  280. * period that still has RCU readers blocked! This function must be
  281. * invoked -before- updating this rnp's ->gpnum, and the rnp's ->lock
  282. * must be held by the caller.
  283. */
  284. static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp)
  285. {
  286. WARN_ON_ONCE(rcu_preempted_readers(rnp));
  287. WARN_ON_ONCE(rnp->qsmask);
  288. }
  289. #ifdef CONFIG_HOTPLUG_CPU
  290. /*
  291. * Handle tasklist migration for case in which all CPUs covered by the
  292. * specified rcu_node have gone offline. Move them up to the root
  293. * rcu_node. The reason for not just moving them to the immediate
  294. * parent is to remove the need for rcu_read_unlock_special() to
  295. * make more than two attempts to acquire the target rcu_node's lock.
  296. * Returns true if there were tasks blocking the current RCU grace
  297. * period.
  298. *
  299. * Returns 1 if there was previously a task blocking the current grace
  300. * period on the specified rcu_node structure.
  301. *
  302. * The caller must hold rnp->lock with irqs disabled.
  303. */
  304. static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
  305. struct rcu_node *rnp,
  306. struct rcu_data *rdp)
  307. {
  308. int i;
  309. struct list_head *lp;
  310. struct list_head *lp_root;
  311. int retval;
  312. struct rcu_node *rnp_root = rcu_get_root(rsp);
  313. struct task_struct *tp;
  314. if (rnp == rnp_root) {
  315. WARN_ONCE(1, "Last CPU thought to be offlined?");
  316. return 0; /* Shouldn't happen: at least one CPU online. */
  317. }
  318. WARN_ON_ONCE(rnp != rdp->mynode &&
  319. (!list_empty(&rnp->blocked_tasks[0]) ||
  320. !list_empty(&rnp->blocked_tasks[1])));
  321. /*
  322. * Move tasks up to root rcu_node. Rely on the fact that the
  323. * root rcu_node can be at most one ahead of the rest of the
  324. * rcu_nodes in terms of gp_num value. This fact allows us to
  325. * move the blocked_tasks[] array directly, element by element.
  326. */
  327. retval = rcu_preempted_readers(rnp);
  328. for (i = 0; i < 2; i++) {
  329. lp = &rnp->blocked_tasks[i];
  330. lp_root = &rnp_root->blocked_tasks[i];
  331. while (!list_empty(lp)) {
  332. tp = list_entry(lp->next, typeof(*tp), rcu_node_entry);
  333. spin_lock(&rnp_root->lock); /* irqs already disabled */
  334. list_del(&tp->rcu_node_entry);
  335. tp->rcu_blocked_node = rnp_root;
  336. list_add(&tp->rcu_node_entry, lp_root);
  337. spin_unlock(&rnp_root->lock); /* irqs remain disabled */
  338. }
  339. }
  340. return retval;
  341. }
  342. /*
  343. * Do CPU-offline processing for preemptable RCU.
  344. */
  345. static void rcu_preempt_offline_cpu(int cpu)
  346. {
  347. __rcu_offline_cpu(cpu, &rcu_preempt_state);
  348. }
  349. #endif /* #ifdef CONFIG_HOTPLUG_CPU */
  350. /*
  351. * Check for a quiescent state from the current CPU. When a task blocks,
  352. * the task is recorded in the corresponding CPU's rcu_node structure,
  353. * which is checked elsewhere.
  354. *
  355. * Caller must disable hard irqs.
  356. */
  357. static void rcu_preempt_check_callbacks(int cpu)
  358. {
  359. struct task_struct *t = current;
  360. if (t->rcu_read_lock_nesting == 0) {
  361. t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
  362. rcu_preempt_qs(cpu);
  363. return;
  364. }
  365. if (per_cpu(rcu_preempt_data, cpu).qs_pending)
  366. t->rcu_read_unlock_special |= RCU_READ_UNLOCK_NEED_QS;
  367. }
  368. /*
  369. * Process callbacks for preemptable RCU.
  370. */
  371. static void rcu_preempt_process_callbacks(void)
  372. {
  373. __rcu_process_callbacks(&rcu_preempt_state,
  374. &__get_cpu_var(rcu_preempt_data));
  375. }
  376. /*
  377. * Queue a preemptable-RCU callback for invocation after a grace period.
  378. */
  379. void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
  380. {
  381. __call_rcu(head, func, &rcu_preempt_state);
  382. }
  383. EXPORT_SYMBOL_GPL(call_rcu);
  384. /**
  385. * synchronize_rcu - wait until a grace period has elapsed.
  386. *
  387. * Control will return to the caller some time after a full grace
  388. * period has elapsed, in other words after all currently executing RCU
  389. * read-side critical sections have completed. RCU read-side critical
  390. * sections are delimited by rcu_read_lock() and rcu_read_unlock(),
  391. * and may be nested.
  392. */
  393. void synchronize_rcu(void)
  394. {
  395. struct rcu_synchronize rcu;
  396. if (!rcu_scheduler_active)
  397. return;
  398. init_completion(&rcu.completion);
  399. /* Will wake me after RCU finished. */
  400. call_rcu(&rcu.head, wakeme_after_rcu);
  401. /* Wait for it. */
  402. wait_for_completion(&rcu.completion);
  403. }
  404. EXPORT_SYMBOL_GPL(synchronize_rcu);
  405. /*
  406. * Wait for an rcu-preempt grace period. We are supposed to expedite the
  407. * grace period, but this is the crude slow compatability hack, so just
  408. * invoke synchronize_rcu().
  409. */
  410. void synchronize_rcu_expedited(void)
  411. {
  412. synchronize_rcu();
  413. }
  414. EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
  415. /*
  416. * Check to see if there is any immediate preemptable-RCU-related work
  417. * to be done.
  418. */
  419. static int rcu_preempt_pending(int cpu)
  420. {
  421. return __rcu_pending(&rcu_preempt_state,
  422. &per_cpu(rcu_preempt_data, cpu));
  423. }
  424. /*
  425. * Does preemptable RCU need the CPU to stay out of dynticks mode?
  426. */
  427. static int rcu_preempt_needs_cpu(int cpu)
  428. {
  429. return !!per_cpu(rcu_preempt_data, cpu).nxtlist;
  430. }
  431. /**
  432. * rcu_barrier - Wait until all in-flight call_rcu() callbacks complete.
  433. */
  434. void rcu_barrier(void)
  435. {
  436. _rcu_barrier(&rcu_preempt_state, call_rcu);
  437. }
  438. EXPORT_SYMBOL_GPL(rcu_barrier);
  439. /*
  440. * Initialize preemptable RCU's per-CPU data.
  441. */
  442. static void __cpuinit rcu_preempt_init_percpu_data(int cpu)
  443. {
  444. rcu_init_percpu_data(cpu, &rcu_preempt_state, 1);
  445. }
  446. /*
  447. * Move preemptable RCU's callbacks to ->orphan_cbs_list.
  448. */
  449. static void rcu_preempt_send_cbs_to_orphanage(void)
  450. {
  451. rcu_send_cbs_to_orphanage(&rcu_preempt_state);
  452. }
  453. /*
  454. * Initialize preemptable RCU's state structures.
  455. */
  456. static void __init __rcu_init_preempt(void)
  457. {
  458. RCU_INIT_FLAVOR(&rcu_preempt_state, rcu_preempt_data);
  459. }
  460. /*
  461. * Check for a task exiting while in a preemptable-RCU read-side
  462. * critical section, clean up if so. No need to issue warnings,
  463. * as debug_check_no_locks_held() already does this if lockdep
  464. * is enabled.
  465. */
  466. void exit_rcu(void)
  467. {
  468. struct task_struct *t = current;
  469. if (t->rcu_read_lock_nesting == 0)
  470. return;
  471. t->rcu_read_lock_nesting = 1;
  472. rcu_read_unlock();
  473. }
  474. #else /* #ifdef CONFIG_TREE_PREEMPT_RCU */
  475. /*
  476. * Tell them what RCU they are running.
  477. */
  478. static void __init rcu_bootup_announce(void)
  479. {
  480. printk(KERN_INFO "Hierarchical RCU implementation.\n");
  481. }
  482. /*
  483. * Return the number of RCU batches processed thus far for debug & stats.
  484. */
  485. long rcu_batches_completed(void)
  486. {
  487. return rcu_batches_completed_sched();
  488. }
  489. EXPORT_SYMBOL_GPL(rcu_batches_completed);
  490. /*
  491. * Because preemptable RCU does not exist, we never have to check for
  492. * CPUs being in quiescent states.
  493. */
  494. static void rcu_preempt_note_context_switch(int cpu)
  495. {
  496. }
  497. /*
  498. * Because preemptable RCU does not exist, there are never any preempted
  499. * RCU readers.
  500. */
  501. static int rcu_preempted_readers(struct rcu_node *rnp)
  502. {
  503. return 0;
  504. }
  505. #ifdef CONFIG_HOTPLUG_CPU
  506. /* Because preemptible RCU does not exist, no quieting of tasks. */
  507. static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags)
  508. {
  509. spin_unlock_irqrestore(&rnp->lock, flags);
  510. }
  511. #endif /* #ifdef CONFIG_HOTPLUG_CPU */
  512. #ifdef CONFIG_RCU_CPU_STALL_DETECTOR
  513. /*
  514. * Because preemptable RCU does not exist, we never have to check for
  515. * tasks blocked within RCU read-side critical sections.
  516. */
  517. static void rcu_print_task_stall(struct rcu_node *rnp)
  518. {
  519. }
  520. #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
  521. /*
  522. * Because there is no preemptable RCU, there can be no readers blocked,
  523. * so there is no need to check for blocked tasks. So check only for
  524. * bogus qsmask values.
  525. */
  526. static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp)
  527. {
  528. WARN_ON_ONCE(rnp->qsmask);
  529. }
  530. #ifdef CONFIG_HOTPLUG_CPU
  531. /*
  532. * Because preemptable RCU does not exist, it never needs to migrate
  533. * tasks that were blocked within RCU read-side critical sections, and
  534. * such non-existent tasks cannot possibly have been blocking the current
  535. * grace period.
  536. */
  537. static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
  538. struct rcu_node *rnp,
  539. struct rcu_data *rdp)
  540. {
  541. return 0;
  542. }
  543. /*
  544. * Because preemptable RCU does not exist, it never needs CPU-offline
  545. * processing.
  546. */
  547. static void rcu_preempt_offline_cpu(int cpu)
  548. {
  549. }
  550. #endif /* #ifdef CONFIG_HOTPLUG_CPU */
  551. /*
  552. * Because preemptable RCU does not exist, it never has any callbacks
  553. * to check.
  554. */
  555. static void rcu_preempt_check_callbacks(int cpu)
  556. {
  557. }
  558. /*
  559. * Because preemptable RCU does not exist, it never has any callbacks
  560. * to process.
  561. */
  562. static void rcu_preempt_process_callbacks(void)
  563. {
  564. }
  565. /*
  566. * In classic RCU, call_rcu() is just call_rcu_sched().
  567. */
  568. void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
  569. {
  570. call_rcu_sched(head, func);
  571. }
  572. EXPORT_SYMBOL_GPL(call_rcu);
  573. /*
  574. * Wait for an rcu-preempt grace period, but make it happen quickly.
  575. * But because preemptable RCU does not exist, map to rcu-sched.
  576. */
  577. void synchronize_rcu_expedited(void)
  578. {
  579. synchronize_sched_expedited();
  580. }
  581. EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
  582. /*
  583. * Because preemptable RCU does not exist, it never has any work to do.
  584. */
  585. static int rcu_preempt_pending(int cpu)
  586. {
  587. return 0;
  588. }
  589. /*
  590. * Because preemptable RCU does not exist, it never needs any CPU.
  591. */
  592. static int rcu_preempt_needs_cpu(int cpu)
  593. {
  594. return 0;
  595. }
  596. /*
  597. * Because preemptable RCU does not exist, rcu_barrier() is just
  598. * another name for rcu_barrier_sched().
  599. */
  600. void rcu_barrier(void)
  601. {
  602. rcu_barrier_sched();
  603. }
  604. EXPORT_SYMBOL_GPL(rcu_barrier);
  605. /*
  606. * Because preemptable RCU does not exist, there is no per-CPU
  607. * data to initialize.
  608. */
  609. static void __cpuinit rcu_preempt_init_percpu_data(int cpu)
  610. {
  611. }
  612. /*
  613. * Because there is no preemptable RCU, there are no callbacks to move.
  614. */
  615. static void rcu_preempt_send_cbs_to_orphanage(void)
  616. {
  617. }
  618. /*
  619. * Because preemptable RCU does not exist, it need not be initialized.
  620. */
  621. static void __init __rcu_init_preempt(void)
  622. {
  623. }
  624. #endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */