History

Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (24 commits) rcu: remove all rcu head initializations, except on_stack initializations rcu head introduce rcu head init on stack Debugobjects transition check rcu: fix build bug in RCU_FAST_NO_HZ builds rcu: RCU_FAST_NO_HZ must check RCU dyntick state rcu: make SRCU usable in modules rcu: improve the RCU CPU-stall warning documentation rcu: reduce the number of spurious RCU_SOFTIRQ invocations rcu: permit discontiguous cpu_possible_mask CPU numbering rcu: improve RCU CPU stall-warning messages rcu: print boot-time console messages if RCU configs out of ordinary rcu: disable CPU stall warnings upon panic rcu: enable CPU_STALL_VERBOSE by default rcu: slim down rcutiny by removing rcu_scheduler_active and friends rcu: refactor RCU's context-switch handling rcu: rename rcutiny rcu_ctrlblk to rcu_sched_ctrlblk rcu: shrink rcutiny by making synchronize_rcu_bh() be inline rcu: fix now-bogus rcu_scheduler_active comments. rcu: Fix bogus CONFIG_PROVE_LOCKING in comments to reflect reality. rcu: ignore offline CPUs in last non-dyntick-idle CPU check ...

Linus Torvalds committed 16 years ago

Commit f262af32 parents 1014cfe 72d5a9f21 files · +470 −143Browse files

Showing the changes to kernel (11 of 21 files). Show all

Unified · Split

11 files
  1. kernel/lockdep.c +3 −0
  2. kernel/rcupdate.c +0 −19
  3. kernel/rcutiny.c +22 −13
  4. kernel/rcutiny_plugin.h +39 −0
  5. kernel/rcutorture.c +2 −0
  6. kernel/rcutree.c +96 −35
  7. kernel/rcutree.h +2 −0
  8. kernel/rcutree_plugin.h +61 −8
  9. kernel/rcutree_trace.c +3 −1
  10. kernel/sched.c +1 −1
  11. kernel/softirq.c +1 −1
kernel/lockdep.c+3−0
@@ -3806,8 +3806,11 @@ void lockdep_rcu_dereference(const char *file, const int line) · 3805 unmodified lines
38063806 {
38073807 struct task_struct *curr = current;
38083808
3809+#ifndef CONFIG_PROVE_RCU_REPEATEDLY
38093810 if (!debug_locks_off())
38103811 return;
3812+#endif /* #ifdef CONFIG_PROVE_RCU_REPEATEDLY */
3813+ /* Note: the following can be executed concurrently, so be careful. */
38113814 printk("\n===================================================\n");
38123815 printk( "[ INFO: suspicious rcu_dereference_check() usage. ]\n");
38133816 printk( "---------------------------------------------------\n");
kernel/rcupdate.c+0−19
@@ -44,7 +44,6 @@ · 43 unmodified lines
4444 #include <linux/cpu.h>
4545 #include <linux/mutex.h>
4646 #include <linux/module.h>
47−#include <linux/kernel_stat.h>
4847 #include <linux/hardirq.h>
4948
5049 #ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -64,9 +63,6 @@ struct lockdep_map rcu_sched_lock_map = · 13 unmodified lines
6463 EXPORT_SYMBOL_GPL(rcu_sched_lock_map);
6564 #endif
6665
67−int rcu_scheduler_active __read_mostly;
68−EXPORT_SYMBOL_GPL(rcu_scheduler_active);
69−
7066 #ifdef CONFIG_DEBUG_LOCK_ALLOC
7167
7268 int debug_lockdep_rcu_enabled(void)
@@ -96,21 +92,6 @@ EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held); · 23 unmodified lines
9692
9793 #endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
9894
99−/*
100− * This function is invoked towards the end of the scheduler's initialization
101− * process. Before this is called, the idle task might contain
102− * RCU read-side critical sections (during which time, this idle
103− * task is booting the system). After this function is called, the
104− * idle tasks are prohibited from containing RCU read-side critical
105− * sections.
106− */
107−void rcu_scheduler_starting(void)
108−{
109− WARN_ON(num_online_cpus() != 1);
110− WARN_ON(nr_context_switches() > 0);
111− rcu_scheduler_active = 1;
112−}
113−
11495 /*
11596 * Awaken the corresponding synchronize_rcu() instance now that a
11697 * grace period has elapsed.
kernel/rcutiny.c+22−13
@@ -44,9 +44,9 @@ struct rcu_ctrlblk { · 43 unmodified lines
4444 };
4545
4646 /* Definition for rcupdate control block. */
47−static struct rcu_ctrlblk rcu_ctrlblk = {
48− .donetail = &rcu_ctrlblk.rcucblist,
49− .curtail = &rcu_ctrlblk.rcucblist,
47+static struct rcu_ctrlblk rcu_sched_ctrlblk = {
48+ .donetail = &rcu_sched_ctrlblk.rcucblist,
49+ .curtail = &rcu_sched_ctrlblk.rcucblist,
5050 };
5151
5252 static struct rcu_ctrlblk rcu_bh_ctrlblk = {
@@ -54,6 +54,11 @@ static struct rcu_ctrlblk rcu_bh_ctrlblk = { · 1 unmodified line
5454 .curtail = &rcu_bh_ctrlblk.rcucblist,
5555 };
5656
57+#ifdef CONFIG_DEBUG_LOCK_ALLOC
58+int rcu_scheduler_active __read_mostly;
59+EXPORT_SYMBOL_GPL(rcu_scheduler_active);
60+#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
61+
5762 #ifdef CONFIG_NO_HZ
5863
5964 static long rcu_dynticks_nesting = 1;
@@ -108,7 +113,8 @@ static int rcu_qsctr_help(struct rcu_ctrlblk *rcp) · 48 unmodified lines
108113 */
109114 void rcu_sched_qs(int cpu)
110115 {
111− if (rcu_qsctr_help(&rcu_ctrlblk) + rcu_qsctr_help(&rcu_bh_ctrlblk))
116+ if (rcu_qsctr_help(&rcu_sched_ctrlblk) +
117+ rcu_qsctr_help(&rcu_bh_ctrlblk))
112118 raise_softirq(RCU_SOFTIRQ);
113119 }
114120
@@ -173,7 +179,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp) · 58 unmodified lines
173179 */
174180 static void rcu_process_callbacks(struct softirq_action *unused)
175181 {
176− __rcu_process_callbacks(&rcu_ctrlblk);
182+ __rcu_process_callbacks(&rcu_sched_ctrlblk);
177183 __rcu_process_callbacks(&rcu_bh_ctrlblk);
178184 }
179185
@@ -187,7 +193,8 @@ static void rcu_process_callbacks(struct softirq_action *unused) · 7 unmodified lines
187193 *
188194 * Cool, huh? (Due to Josh Triplett.)
189195 *
190− * But we want to make this a static inline later.
196+ * But we want to make this a static inline later. The cond_resched()
197+ * currently makes this problematic.
191198 */
192199 void synchronize_sched(void)
193200 {
@@ -195,12 +202,6 @@ void synchronize_sched(void) · 1 unmodified line
195202 }
196203 EXPORT_SYMBOL_GPL(synchronize_sched);
197204
198−void synchronize_rcu_bh(void)
199−{
200− synchronize_sched();
201−}
202−EXPORT_SYMBOL_GPL(synchronize_rcu_bh);
203−
204205 /*
205206 * Helper function for call_rcu() and call_rcu_bh().
206207 */
@@ -226,7 +227,7 @@ static void __call_rcu(struct rcu_head *head, · 19 unmodified lines
226227 */
227228 void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
228229 {
229− __call_rcu(head, func, &rcu_ctrlblk);
230+ __call_rcu(head, func, &rcu_sched_ctrlblk);
230231 }
231232 EXPORT_SYMBOL_GPL(call_rcu);
232233
@@ -244,11 +245,13 @@ void rcu_barrier(void) · 11 unmodified lines
244245 {
245246 struct rcu_synchronize rcu;
246247
248+ init_rcu_head_on_stack(&rcu.head);
247249 init_completion(&rcu.completion);
248250 /* Will wake me after RCU finished. */
249251 call_rcu(&rcu.head, wakeme_after_rcu);
250252 /* Wait for it. */
251253 wait_for_completion(&rcu.completion);
254+ destroy_rcu_head_on_stack(&rcu.head);
252255 }
253256 EXPORT_SYMBOL_GPL(rcu_barrier);
254257
@@ -256,11 +259,13 @@ void rcu_barrier_bh(void) · 1 unmodified line
256259 {
257260 struct rcu_synchronize rcu;
258261
262+ init_rcu_head_on_stack(&rcu.head);
259263 init_completion(&rcu.completion);
260264 /* Will wake me after RCU finished. */
261265 call_rcu_bh(&rcu.head, wakeme_after_rcu);
262266 /* Wait for it. */
263267 wait_for_completion(&rcu.completion);
268+ destroy_rcu_head_on_stack(&rcu.head);
264269 }
265270 EXPORT_SYMBOL_GPL(rcu_barrier_bh);
266271
@@ -268,11 +273,13 @@ void rcu_barrier_sched(void) · 1 unmodified line
268273 {
269274 struct rcu_synchronize rcu;
270275
276+ init_rcu_head_on_stack(&rcu.head);
271277 init_completion(&rcu.completion);
272278 /* Will wake me after RCU finished. */
273279 call_rcu_sched(&rcu.head, wakeme_after_rcu);
274280 /* Wait for it. */
275281 wait_for_completion(&rcu.completion);
282+ destroy_rcu_head_on_stack(&rcu.head);
276283 }
277284 EXPORT_SYMBOL_GPL(rcu_barrier_sched);
278285
@@ -280,3 +287,5 @@ void __init rcu_init(void) · 1 unmodified line
280287 {
281288 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
282289 }
290+
291+#include "rcutiny_plugin.h"
kernel/rcutiny_plugin.h+39−0
@@ -0,0 +1,39 @@
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 IBM Corporation, 2009
21+ *
22+ * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
23+ */
24+
25+#ifdef CONFIG_DEBUG_LOCK_ALLOC
26+
27+#include <linux/kernel_stat.h>
28+
29+/*
30+ * During boot, we forgive RCU lockdep issues. After this function is
31+ * invoked, we start taking RCU lockdep issues seriously.
32+ */
33+void rcu_scheduler_starting(void)
34+{
35+ WARN_ON(nr_context_switches() > 0);
36+ rcu_scheduler_active = 1;
37+}
38+
39+#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
kernel/rcutorture.c+2−0
@@ -464,9 +464,11 @@ static void rcu_bh_torture_synchronize(void) · 463 unmodified lines
464464 {
465465 struct rcu_bh_torture_synchronize rcu;
466466
467+ init_rcu_head_on_stack(&rcu.head);
467468 init_completion(&rcu.completion);
468469 call_rcu_bh(&rcu.head, rcu_bh_torture_wakeme_after_cb);
469470 wait_for_completion(&rcu.completion);
471+ destroy_rcu_head_on_stack(&rcu.head);
470472 }
471473
472474 static struct rcu_torture_ops rcu_bh_ops = {
kernel/rcutree.c+96−35
@@ -46,6 +46,7 @@ · 45 unmodified lines
4646 #include <linux/cpu.h>
4747 #include <linux/mutex.h>
4848 #include <linux/time.h>
49+#include <linux/kernel_stat.h>
4950
5051 #include "rcutree.h"
5152
@@ -53,8 +54,8 @@ · 1 unmodified line
5354
5455 static struct lock_class_key rcu_node_class[NUM_RCU_LVLS];
5556
56−#define RCU_STATE_INITIALIZER(name) { \
57− .level = { &name.node[0] }, \
57+#define RCU_STATE_INITIALIZER(structname) { \
58+ .level = { &structname.node[0] }, \
5859 .levelcnt = { \
5960 NUM_RCU_LVL_0, /* root of hierarchy. */ \
6061 NUM_RCU_LVL_1, \
@@ -65,13 +66,14 @@ static struct lock_class_key rcu_node_class[NUM_RCU_LVLS]; · 4 unmodified lines
6566 .signaled = RCU_GP_IDLE, \
6667 .gpnum = -300, \
6768 .completed = -300, \
68− .onofflock = __RAW_SPIN_LOCK_UNLOCKED(&name.onofflock), \
69+ .onofflock = __RAW_SPIN_LOCK_UNLOCKED(&structname.onofflock), \
6970 .orphan_cbs_list = NULL, \
70− .orphan_cbs_tail = &name.orphan_cbs_list, \
71+ .orphan_cbs_tail = &structname.orphan_cbs_list, \
7172 .orphan_qlen = 0, \
72− .fqslock = __RAW_SPIN_LOCK_UNLOCKED(&name.fqslock), \
73+ .fqslock = __RAW_SPIN_LOCK_UNLOCKED(&structname.fqslock), \
7374 .n_force_qs = 0, \
7475 .n_force_qs_ngp = 0, \
76+ .name = #structname, \
7577 }
7678
7779 struct rcu_state rcu_sched_state = RCU_STATE_INITIALIZER(rcu_sched_state);
@@ -80,6 +82,9 @@ DEFINE_PER_CPU(struct rcu_data, rcu_sched_data); · 2 unmodified lines
8082 struct rcu_state rcu_bh_state = RCU_STATE_INITIALIZER(rcu_bh_state);
8183 DEFINE_PER_CPU(struct rcu_data, rcu_bh_data);
8284
85+int rcu_scheduler_active __read_mostly;
86+EXPORT_SYMBOL_GPL(rcu_scheduler_active);
87+
8388 /*
8489 * Return true if an RCU grace period is in progress. The ACCESS_ONCE()s
8590 * permit this function to be invoked without holding the root rcu_node
@@ -97,25 +102,32 @@ static int rcu_gp_in_progress(struct rcu_state *rsp) · 11 unmodified lines
97102 */
98103 void rcu_sched_qs(int cpu)
99104 {
100− struct rcu_data *rdp;
105+ struct rcu_data *rdp = &per_cpu(rcu_sched_data, cpu);
101106
102− rdp = &per_cpu(rcu_sched_data, cpu);
103107 rdp->passed_quiesc_completed = rdp->gpnum - 1;
104108 barrier();
105109 rdp->passed_quiesc = 1;
106− rcu_preempt_note_context_switch(cpu);
107110 }
108111
109112 void rcu_bh_qs(int cpu)
110113 {
111− struct rcu_data *rdp;
114+ struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
112115
113− rdp = &per_cpu(rcu_bh_data, cpu);
114116 rdp->passed_quiesc_completed = rdp->gpnum - 1;
115117 barrier();
116118 rdp->passed_quiesc = 1;
117119 }
118120
121+/*
122+ * Note a context switch. This is a quiescent state for RCU-sched,
123+ * and requires special handling for preemptible RCU.
124+ */
125+void rcu_note_context_switch(int cpu)
126+{
127+ rcu_sched_qs(cpu);
128+ rcu_preempt_note_context_switch(cpu);
129+}
130+
119131 #ifdef CONFIG_NO_HZ
120132 DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = {
121133 .dynticks_nesting = 1,
@@ -438,6 +450,8 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) · 316 unmodified lines
438450
439451 #ifdef CONFIG_RCU_CPU_STALL_DETECTOR
440452
453+int rcu_cpu_stall_panicking __read_mostly;
454+
441455 static void record_gp_stall_check_time(struct rcu_state *rsp)
442456 {
443457 rsp->gp_start = jiffies;
@@ -470,7 +484,8 @@ static void print_other_cpu_stall(struct rcu_state *rsp) · 26 unmodified lines
470484
471485 /* OK, time to rat on our buddy... */
472486
473− printk(KERN_ERR "INFO: RCU detected CPU stalls:");
487+ printk(KERN_ERR "INFO: %s detected stalls on CPUs/tasks: {",
488+ rsp->name);
474489 rcu_for_each_leaf_node(rsp, rnp) {
475490 raw_spin_lock_irqsave(&rnp->lock, flags);
476491 rcu_print_task_stall(rnp);
@@ -481,7 +496,7 @@ static void print_other_cpu_stall(struct rcu_state *rsp) · 4 unmodified lines
481496 if (rnp->qsmask & (1UL << cpu))
482497 printk(" %d", rnp->grplo + cpu);
483498 }
484− printk(" (detected by %d, t=%ld jiffies)\n",
499+ printk("} (detected by %d, t=%ld jiffies)\n",
485500 smp_processor_id(), (long)(jiffies - rsp->gp_start));
486501 trigger_all_cpu_backtrace();
487502
@@ -497,8 +512,8 @@ static void print_cpu_stall(struct rcu_state *rsp) · 9 unmodified lines
497512 unsigned long flags;
498513 struct rcu_node *rnp = rcu_get_root(rsp);
499514
500− printk(KERN_ERR "INFO: RCU detected CPU %d stall (t=%lu jiffies)\n",
501− smp_processor_id(), jiffies - rsp->gp_start);
515+ printk(KERN_ERR "INFO: %s detected stall on CPU %d (t=%lu jiffies)\n",
516+ rsp->name, smp_processor_id(), jiffies - rsp->gp_start);
502517 trigger_all_cpu_backtrace();
503518
504519 raw_spin_lock_irqsave(&rnp->lock, flags);
@@ -515,6 +530,8 @@ static void check_cpu_stall(struct rcu_state *rsp, struct rcu_data *rdp) · 10 unmodified lines
515530 long delta;
516531 struct rcu_node *rnp;
517532
533+ if (rcu_cpu_stall_panicking)
534+ return;
518535 delta = jiffies - rsp->jiffies_stall;
519536 rnp = rdp->mynode;
520537 if ((rnp->qsmask & rdp->grpmask) && delta >= 0) {
@@ -529,6 +546,21 @@ static void check_cpu_stall(struct rcu_state *rsp, struct rcu_data *rdp) · 8 unmodified lines
529546 }
530547 }
531548
549+static int rcu_panic(struct notifier_block *this, unsigned long ev, void *ptr)
550+{
551+ rcu_cpu_stall_panicking = 1;
552+ return NOTIFY_DONE;
553+}
554+
555+static struct notifier_block rcu_panic_block = {
556+ .notifier_call = rcu_panic,
557+};
558+
559+static void __init check_cpu_stall_init(void)
560+{
561+ atomic_notifier_chain_register(&panic_notifier_list, &rcu_panic_block);
562+}
563+
532564 #else /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
533565
534566 static void record_gp_stall_check_time(struct rcu_state *rsp)
@@ -539,6 +571,10 @@ static void check_cpu_stall(struct rcu_state *rsp, struct rcu_data *rdp) · 4 unmodified lines
539571 {
540572 }
541573
574+static void __init check_cpu_stall_init(void)
575+{
576+}
577+
542578 #endif /* #else #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
543579
544580 /*
@@ -1125,8 +1161,6 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) · 580 unmodified lines
11251161 */
11261162 void rcu_check_callbacks(int cpu, int user)
11271163 {
1128− if (!rcu_pending(cpu))
1129− return; /* if nothing for RCU to do. */
11301164 if (user ||
11311165 (idle_cpu(cpu) && rcu_scheduler_active &&
11321166 !in_softirq() && hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
@@ -1158,7 +1192,8 @@ void rcu_check_callbacks(int cpu, int user) · 25 unmodified lines
11581192 rcu_bh_qs(cpu);
11591193 }
11601194 rcu_preempt_check_callbacks(cpu);
1161− raise_softirq(RCU_SOFTIRQ);
1195+ if (rcu_pending(cpu))
1196+ raise_softirq(RCU_SOFTIRQ);
11621197 }
11631198
11641199 #ifdef CONFIG_SMP
@@ -1236,11 +1271,11 @@ static void force_quiescent_state(struct rcu_state *rsp, int relaxed) · 71 unmodified lines
12361271 break; /* grace period idle or initializing, ignore. */
12371272
12381273 case RCU_SAVE_DYNTICK:
1239−
1240− raw_spin_unlock(&rnp->lock); /* irqs remain disabled */
12411274 if (RCU_SIGNAL_INIT != RCU_SAVE_DYNTICK)
12421275 break; /* So gcc recognizes the dead code. */
12431276
1277+ raw_spin_unlock(&rnp->lock); /* irqs remain disabled */
1278+
12441279 /* Record dyntick-idle state. */
12451280 force_qs_rnp(rsp, dyntick_save_progress_counter);
12461281 raw_spin_lock(&rnp->lock); /* irqs already disabled */
@@ -1449,11 +1484,13 @@ void synchronize_sched(void) · 202 unmodified lines
14491484 if (rcu_blocking_is_gp())
14501485 return;
14511486
1487+ init_rcu_head_on_stack(&rcu.head);
14521488 init_completion(&rcu.completion);
14531489 /* Will wake me after RCU finished. */
14541490 call_rcu_sched(&rcu.head, wakeme_after_rcu);
14551491 /* Wait for it. */
14561492 wait_for_completion(&rcu.completion);
1493+ destroy_rcu_head_on_stack(&rcu.head);
14571494 }
14581495 EXPORT_SYMBOL_GPL(synchronize_sched);
14591496
@@ -1473,11 +1510,13 @@ void synchronize_rcu_bh(void) · 13 unmodified lines
14731510 if (rcu_blocking_is_gp())
14741511 return;
14751512
1513+ init_rcu_head_on_stack(&rcu.head);
14761514 init_completion(&rcu.completion);
14771515 /* Will wake me after RCU finished. */
14781516 call_rcu_bh(&rcu.head, wakeme_after_rcu);
14791517 /* Wait for it. */
14801518 wait_for_completion(&rcu.completion);
1519+ destroy_rcu_head_on_stack(&rcu.head);
14811520 }
14821521 EXPORT_SYMBOL_GPL(synchronize_rcu_bh);
14831522
@@ -1498,8 +1537,20 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp) · 14 unmodified lines
14981537 check_cpu_stall(rsp, rdp);
14991538
15001539 /* Is the RCU core waiting for a quiescent state from this CPU? */
1501− if (rdp->qs_pending) {
1540+ if (rdp->qs_pending && !rdp->passed_quiesc) {
1541+
1542+ /*
1543+ * If force_quiescent_state() coming soon and this CPU
1544+ * needs a quiescent state, and this is either RCU-sched
1545+ * or RCU-bh, force a local reschedule.
1546+ */
15021547 rdp->n_rp_qs_pending++;
1548+ if (!rdp->preemptable &&
1549+ ULONG_CMP_LT(ACCESS_ONCE(rsp->jiffies_force_qs) - 1,
1550+ jiffies))
1551+ set_need_resched();
1552+ } else if (rdp->qs_pending && rdp->passed_quiesc) {
1553+ rdp->n_rp_report_qs++;
15031554 return 1;
15041555 }
15051556
@@ -1766,6 +1817,21 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self, · 260 unmodified lines
17661817 return NOTIFY_OK;
17671818 }
17681819
1820+/*
1821+ * This function is invoked towards the end of the scheduler's initialization
1822+ * process. Before this is called, the idle task might contain
1823+ * RCU read-side critical sections (during which time, this idle
1824+ * task is booting the system). After this function is called, the
1825+ * idle tasks are prohibited from containing RCU read-side critical
1826+ * sections. This function also enables RCU lockdep checking.
1827+ */
1828+void rcu_scheduler_starting(void)
1829+{
1830+ WARN_ON(num_online_cpus() != 1);
1831+ WARN_ON(nr_context_switches() > 0);
1832+ rcu_scheduler_active = 1;
1833+}
1834+
17691835 /*
17701836 * Compute the per-level fanout, either using the exact fanout specified
17711837 * or balancing the tree, depending on CONFIG_RCU_FANOUT_EXACT.
@@ -1849,6 +1915,14 @@ static void __init rcu_init_one(struct rcu_state *rsp) · 77 unmodified lines
18491915 INIT_LIST_HEAD(&rnp->blocked_tasks[3]);
18501916 }
18511917 }
1918+
1919+ rnp = rsp->level[NUM_RCU_LVLS - 1];
1920+ for_each_possible_cpu(i) {
1921+ while (i > rnp->grphi)
1922+ rnp++;
1923+ rsp->rda[i]->mynode = rnp;
1924+ rcu_boot_init_percpu_data(i, rsp);
1925+ }
18521926 }
18531927
18541928 /*
@@ -1859,19 +1933,11 @@ static void __init rcu_init_one(struct rcu_state *rsp) · 4 unmodified lines
18591933 #define RCU_INIT_FLAVOR(rsp, rcu_data) \
18601934 do { \
18611935 int i; \
1862− int j; \
1863− struct rcu_node *rnp; \
18641936 \
1865− rcu_init_one(rsp); \
1866− rnp = (rsp)->level[NUM_RCU_LVLS - 1]; \
1867− j = 0; \
18681937 for_each_possible_cpu(i) { \
1869− if (i > rnp[j].grphi) \
1870− j++; \
1871− per_cpu(rcu_data, i).mynode = &rnp[j]; \
18721938 (rsp)->rda[i] = &per_cpu(rcu_data, i); \
1873− rcu_boot_init_percpu_data(i, rsp); \
18741939 } \
1940+ rcu_init_one(rsp); \
18751941 } while (0)
18761942
18771943 void __init rcu_init(void)
@@ -1879,12 +1945,6 @@ void __init rcu_init(void) · 1 unmodified line
18791945 int cpu;
18801946
18811947 rcu_bootup_announce();
1882−#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
1883− printk(KERN_INFO "RCU-based detection of stalled CPUs is enabled.\n");
1884−#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
1885−#if NUM_RCU_LVL_4 != 0
1886− printk(KERN_INFO "Experimental four-level hierarchy is enabled.\n");
1887−#endif /* #if NUM_RCU_LVL_4 != 0 */
18881948 RCU_INIT_FLAVOR(&rcu_sched_state, rcu_sched_data);
18891949 RCU_INIT_FLAVOR(&rcu_bh_state, rcu_bh_data);
18901950 __rcu_init_preempt();
@@ -1898,6 +1958,7 @@ void __init rcu_init(void) · 7 unmodified lines
18981958 cpu_notifier(rcu_cpu_notify, 0);
18991959 for_each_online_cpu(cpu)
19001960 rcu_cpu_notify(NULL, CPU_UP_PREPARE, (void *)(long)cpu);
1961+ check_cpu_stall_init();
19011962 }
19021963
19031964 #include "rcutree_plugin.h"
kernel/rcutree.h+2−0
@@ -223,6 +223,7 @@ struct rcu_data { · 222 unmodified lines
223223 /* 5) __rcu_pending() statistics. */
224224 unsigned long n_rcu_pending; /* rcu_pending() calls since boot. */
225225 unsigned long n_rp_qs_pending;
226+ unsigned long n_rp_report_qs;
226227 unsigned long n_rp_cb_ready;
227228 unsigned long n_rp_cpu_needs_gp;
228229 unsigned long n_rp_gp_completed;
@@ -326,6 +327,7 @@ struct rcu_state { · 97 unmodified lines
326327 unsigned long jiffies_stall; /* Time at which to check */
327328 /* for CPU stalls. */
328329 #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
330+ char *name; /* Name of structure. */
329331 };
330332
331333 /* Return values for rcu_preempt_offline_tasks(). */
kernel/rcutree_plugin.h+61−8
@@ -26,6 +26,45 @@ · 25 unmodified lines
2626
2727 #include <linux/delay.h>
2828
29+/*
30+ * Check the RCU kernel configuration parameters and print informative
31+ * messages about anything out of the ordinary. If you like #ifdef, you
32+ * will love this function.
33+ */
34+static void __init rcu_bootup_announce_oddness(void)
35+{
36+#ifdef CONFIG_RCU_TRACE
37+ printk(KERN_INFO "\tRCU debugfs-based tracing is enabled.\n");
38+#endif
39+#if (defined(CONFIG_64BIT) && CONFIG_RCU_FANOUT != 64) || (!defined(CONFIG_64BIT) && CONFIG_RCU_FANOUT != 32)
40+ printk(KERN_INFO "\tCONFIG_RCU_FANOUT set to non-default value of %d\n",
41+ CONFIG_RCU_FANOUT);
42+#endif
43+#ifdef CONFIG_RCU_FANOUT_EXACT
44+ printk(KERN_INFO "\tHierarchical RCU autobalancing is disabled.\n");
45+#endif
46+#ifdef CONFIG_RCU_FAST_NO_HZ
47+ printk(KERN_INFO
48+ "\tRCU dyntick-idle grace-period acceleration is enabled.\n");
49+#endif
50+#ifdef CONFIG_PROVE_RCU
51+ printk(KERN_INFO "\tRCU lockdep checking is enabled.\n");
52+#endif
53+#ifdef CONFIG_RCU_TORTURE_TEST_RUNNABLE
54+ printk(KERN_INFO "\tRCU torture testing starts during boot.\n");
55+#endif
56+#ifndef CONFIG_RCU_CPU_STALL_DETECTOR
57+ printk(KERN_INFO
58+ "\tRCU-based detection of stalled CPUs is disabled.\n");
59+#endif
60+#ifndef CONFIG_RCU_CPU_STALL_VERBOSE
61+ printk(KERN_INFO "\tVerbose stalled-CPUs detection is disabled.\n");
62+#endif
63+#if NUM_RCU_LVL_4 != 0
64+ printk(KERN_INFO "\tExperimental four-level hierarchy is enabled.\n");
65+#endif
66+}
67+
2968 #ifdef CONFIG_TREE_PREEMPT_RCU
3069
3170 struct rcu_state rcu_preempt_state = RCU_STATE_INITIALIZER(rcu_preempt_state);
@@ -38,8 +77,8 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp); · 6 unmodified lines
3877 */
3978 static void __init rcu_bootup_announce(void)
4079 {
41− printk(KERN_INFO
42− "Experimental preemptable hierarchical RCU implementation.\n");
80+ printk(KERN_INFO "Preemptable hierarchical RCU implementation.\n");
81+ rcu_bootup_announce_oddness();
4382 }
4483
4584 /*
@@ -75,13 +114,19 @@ EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); · 29 unmodified lines
75114 * that this just means that the task currently running on the CPU is
76115 * not in a quiescent state. There might be any number of tasks blocked
77116 * while in an RCU read-side critical section.
117+ *
118+ * Unlike the other rcu_*_qs() functions, callers to this function
119+ * must disable irqs in order to protect the assignment to
120+ * ->rcu_read_unlock_special.
78121 */
79122 static void rcu_preempt_qs(int cpu)
80123 {
81124 struct rcu_data *rdp = &per_cpu(rcu_preempt_data, cpu);
125+
82126 rdp->passed_quiesc_completed = rdp->gpnum - 1;
83127 barrier();
84128 rdp->passed_quiesc = 1;
129+ current->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
85130 }
86131
87132 /*
@@ -144,9 +189,8 @@ static void rcu_preempt_note_context_switch(int cpu) · 56 unmodified lines
144189 * grace period, then the fact that the task has been enqueued
145190 * means that we continue to block the current grace period.
146191 */
147− rcu_preempt_qs(cpu);
148192 local_irq_save(flags);
149− t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
193+ rcu_preempt_qs(cpu);
150194 local_irq_restore(flags);
151195 }
152196
@@ -236,7 +280,6 @@ static void rcu_read_unlock_special(struct task_struct *t) · 83 unmodified lines
236280 */
237281 special = t->rcu_read_unlock_special;
238282 if (special & RCU_READ_UNLOCK_NEED_QS) {
239− t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
240283 rcu_preempt_qs(smp_processor_id());
241284 }
242285
@@ -473,7 +516,6 @@ static void rcu_preempt_check_callbacks(int cpu) · 230 unmodified lines
473516 struct task_struct *t = current;
474517
475518 if (t->rcu_read_lock_nesting == 0) {
476− t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS;
477519 rcu_preempt_qs(cpu);
478520 return;
479521 }
@@ -515,11 +557,13 @@ void synchronize_rcu(void) · 35 unmodified lines
515557 if (!rcu_scheduler_active)
516558 return;
517559
560+ init_rcu_head_on_stack(&rcu.head);
518561 init_completion(&rcu.completion);
519562 /* Will wake me after RCU finished. */
520563 call_rcu(&rcu.head, wakeme_after_rcu);
521564 /* Wait for it. */
522565 wait_for_completion(&rcu.completion);
566+ destroy_rcu_head_on_stack(&rcu.head);
523567 }
524568 EXPORT_SYMBOL_GPL(synchronize_rcu);
525569
@@ -754,6 +798,7 @@ void exit_rcu(void) · 228 unmodified lines
754798 static void __init rcu_bootup_announce(void)
755799 {
756800 printk(KERN_INFO "Hierarchical RCU implementation.\n");
801+ rcu_bootup_announce_oddness();
757802 }
758803
759804 /*
@@ -1008,6 +1053,8 @@ static DEFINE_PER_CPU(unsigned long, rcu_dyntick_holdoff); · 248 unmodified lines
10081053 int rcu_needs_cpu(int cpu)
10091054 {
10101055 int c = 0;
1056+ int snap;
1057+ int snap_nmi;
10111058 int thatcpu;
10121059
10131060 /* Check for being in the holdoff period. */
@@ -1015,12 +1062,18 @@ int rcu_needs_cpu(int cpu) · 1 unmodified line
10151062 return rcu_needs_cpu_quick_check(cpu);
10161063
10171064 /* Don't bother unless we are the last non-dyntick-idle CPU. */
1018− for_each_cpu_not(thatcpu, nohz_cpu_mask)
1019− if (thatcpu != cpu) {
1065+ for_each_online_cpu(thatcpu) {
1066+ if (thatcpu == cpu)
1067+ continue;
1068+ snap = per_cpu(rcu_dynticks, thatcpu).dynticks;
1069+ snap_nmi = per_cpu(rcu_dynticks, thatcpu).dynticks_nmi;
1070+ smp_mb(); /* Order sampling of snap with end of grace period. */
1071+ if (((snap & 0x1) != 0) || ((snap_nmi & 0x1) != 0)) {
10201072 per_cpu(rcu_dyntick_drain, cpu) = 0;
10211073 per_cpu(rcu_dyntick_holdoff, cpu) = jiffies - 1;
10221074 return rcu_needs_cpu_quick_check(cpu);
10231075 }
1076+ }
10241077
10251078 /* Check and update the rcu_dyntick_drain sequencing. */
10261079 if (per_cpu(rcu_dyntick_drain, cpu) <= 0) {
kernel/rcutree_trace.c+3−1
@@ -241,11 +241,13 @@ static const struct file_operations rcugp_fops = { · 240 unmodified lines
241241 static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp)
242242 {
243243 seq_printf(m, "%3d%cnp=%ld "
244− "qsp=%ld cbr=%ld cng=%ld gpc=%ld gps=%ld nf=%ld nn=%ld\n",
244+ "qsp=%ld rpq=%ld cbr=%ld cng=%ld "
245+ "gpc=%ld gps=%ld nf=%ld nn=%ld\n",
245246 rdp->cpu,
246247 cpu_is_offline(rdp->cpu) ? '!' : ' ',
247248 rdp->n_rcu_pending,
248249 rdp->n_rp_qs_pending,
250+ rdp->n_rp_report_qs,
249251 rdp->n_rp_cb_ready,
250252 rdp->n_rp_cpu_needs_gp,
251253 rdp->n_rp_gp_completed,
kernel/sched.c+1−1
@@ -3706,7 +3706,7 @@ need_resched: · 3705 unmodified lines
37063706 preempt_disable();
37073707 cpu = smp_processor_id();
37083708 rq = cpu_rq(cpu);
3709− rcu_sched_qs(cpu);
3709+ rcu_note_context_switch(cpu);
37103710 prev = rq->curr;
37113711 switch_count = &prev->nivcsw;
37123712
kernel/softirq.c+1−1
@@ -716,7 +716,7 @@ static int run_ksoftirqd(void * __bind_cpu) · 715 unmodified lines
716716 preempt_enable_no_resched();
717717 cond_resched();
718718 preempt_disable();
719− rcu_sched_qs((long)__bind_cpu);
719+ rcu_note_context_switch((long)__bind_cpu);
720720 }
721721 preempt_enable();
722722 set_current_state(TASK_INTERRUPTIBLE);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t