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

Unified · Split

21 files
  1. Documentation/RCU/stallwarn.txt +71 −23
  2. Documentation/RCU/trace.txt +19 −16
  3. include/linux/debugobjects.h +11 −0
  4. include/linux/init_task.h +0 −1
  5. include/linux/rcupdate.h +32 −18
  6. include/linux/rcutiny.h +28 −1
  7. include/linux/rcutree.h +6 −0
  8. include/linux/srcu.h +4 −2
  9. kernel/lockdep.c +3 −0
  10. kernel/rcupdate.c +0 −19
  11. kernel/rcutiny.c +22 −13
  12. kernel/rcutiny_plugin.h +39 −0
  13. kernel/rcutorture.c +2 −0
  14. kernel/rcutree.c +96 −35
  15. kernel/rcutree.h +2 −0
  16. kernel/rcutree_plugin.h +61 −8
  17. kernel/rcutree_trace.c +3 −1
  18. kernel/sched.c +1 −1
  19. kernel/softirq.c +1 −1
  20. lib/Kconfig.debug +13 −1
  21. lib/debugobjects.c +56 −3
Documentation/RCU/stallwarn.txt+71−23
@@ -3,35 +3,79 @@ Using RCU's CPU Stall Detector · 2 unmodified lines
33 The CONFIG_RCU_CPU_STALL_DETECTOR kernel config parameter enables
44 RCU's CPU stall detector, which detects conditions that unduly delay
55 RCU grace periods. The stall detector's idea of what constitutes
6−"unduly delayed" is controlled by a pair of C preprocessor macros:
6+"unduly delayed" is controlled by a set of C preprocessor macros:
77
88 RCU_SECONDS_TILL_STALL_CHECK
99
1010 This macro defines the period of time that RCU will wait from
1111 the beginning of a grace period until it issues an RCU CPU
12− stall warning. It is normally ten seconds.
12+ stall warning. This time period is normally ten seconds.
1313
1414 RCU_SECONDS_TILL_STALL_RECHECK
1515
1616 This macro defines the period of time that RCU will wait after
17− issuing a stall warning until it issues another stall warning.
18− It is normally set to thirty seconds.
17+ issuing a stall warning until it issues another stall warning
18+ for the same stall. This time period is normally set to thirty
19+ seconds.
1920
2021 RCU_STALL_RAT_DELAY
2122
22− The CPU stall detector tries to make the offending CPU rat on itself,
23− as this often gives better-quality stack traces. However, if
24− the offending CPU does not detect its own stall in the number
25− of jiffies specified by RCU_STALL_RAT_DELAY, then other CPUs will
26− complain. This is normally set to two jiffies.
23+ The CPU stall detector tries to make the offending CPU print its
24+ own warnings, as this often gives better-quality stack traces.
25+ However, if the offending CPU does not detect its own stall in
26+ the number of jiffies specified by RCU_STALL_RAT_DELAY, then
27+ some other CPU will complain. This delay is normally set to
28+ two jiffies.
2729
28−The following problems can result in an RCU CPU stall warning:
30+When a CPU detects that it is stalling, it will print a message similar
31+to the following:
32+
33+INFO: rcu_sched_state detected stall on CPU 5 (t=2500 jiffies)
34+
35+This message indicates that CPU 5 detected that it was causing a stall,
36+and that the stall was affecting RCU-sched. This message will normally be
37+followed by a stack dump of the offending CPU. On TREE_RCU kernel builds,
38+RCU and RCU-sched are implemented by the same underlying mechanism,
39+while on TREE_PREEMPT_RCU kernel builds, RCU is instead implemented
40+by rcu_preempt_state.
41+
42+On the other hand, if the offending CPU fails to print out a stall-warning
43+message quickly enough, some other CPU will print a message similar to
44+the following:
45+
46+INFO: rcu_bh_state detected stalls on CPUs/tasks: { 3 5 } (detected by 2, 2502 jiffies)
47+
48+This message indicates that CPU 2 detected that CPUs 3 and 5 were both
49+causing stalls, and that the stall was affecting RCU-bh. This message
50+will normally be followed by stack dumps for each CPU. Please note that
51+TREE_PREEMPT_RCU builds can be stalled by tasks as well as by CPUs,
52+and that the tasks will be indicated by PID, for example, "P3421".
53+It is even possible for a rcu_preempt_state stall to be caused by both
54+CPUs -and- tasks, in which case the offending CPUs and tasks will all
55+be called out in the list.
56+
57+Finally, if the grace period ends just as the stall warning starts
58+printing, there will be a spurious stall-warning message:
59+
60+INFO: rcu_bh_state detected stalls on CPUs/tasks: { } (detected by 4, 2502 jiffies)
61+
62+This is rare, but does happen from time to time in real life.
63+
64+So your kernel printed an RCU CPU stall warning. The next question is
65+"What caused it?" The following problems can result in RCU CPU stall
66+warnings:
2967
3068 o A CPU looping in an RCU read-side critical section.
3169
32−o A CPU looping with interrupts disabled.
70+o A CPU looping with interrupts disabled. This condition can
71+ result in RCU-sched and RCU-bh stalls.
3372
34−o A CPU looping with preemption disabled.
73+o A CPU looping with preemption disabled. This condition can
74+ result in RCU-sched stalls and, if ksoftirqd is in use, RCU-bh
75+ stalls.
76+
77+o A CPU looping with bottom halves disabled. This condition can
78+ result in RCU-sched and RCU-bh stalls.
3579
3680 o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the kernel
3781 without invoking schedule().
@@ -39,20 +83,24 @@ o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the kernel · 1 unmodified line
3983 o A bug in the RCU implementation.
4084
4185 o A hardware failure. This is quite unlikely, but has occurred
42− at least once in a former life. A CPU failed in a running system,
86+ at least once in real life. A CPU failed in a running system,
4387 becoming unresponsive, but not causing an immediate crash.
4488 This resulted in a series of RCU CPU stall warnings, eventually
4589 leading the realization that the CPU had failed.
4690
47−The RCU, RCU-sched, and RCU-bh implementations have CPU stall warning.
48−SRCU does not do so directly, but its calls to synchronize_sched() will
49−result in RCU-sched detecting any CPU stalls that might be occurring.
50−
51−To diagnose the cause of the stall, inspect the stack traces. The offending
52−function will usually be near the top of the stack. If you have a series
53−of stall warnings from a single extended stall, comparing the stack traces
54−can often help determine where the stall is occurring, which will usually
55−be in the function nearest the top of the stack that stays the same from
56−trace to trace.
91+The RCU, RCU-sched, and RCU-bh implementations have CPU stall
92+warning. SRCU does not have its own CPU stall warnings, but its
93+calls to synchronize_sched() will result in RCU-sched detecting
94+RCU-sched-related CPU stalls. Please note that RCU only detects
95+CPU stalls when there is a grace period in progress. No grace period,
96+no CPU stall warnings.
97+
98+To diagnose the cause of the stall, inspect the stack traces.
99+The offending function will usually be near the top of the stack.
100+If you have a series of stall warnings from a single extended stall,
101+comparing the stack traces can often help determine where the stall
102+is occurring, which will usually be in the function nearest the top of
103+that portion of the stack which remains the same from trace to trace.
104+If you can reliably trigger the stall, ftrace can be quite helpful.
57105
58106 RCU bugs can often be debugged with the help of CONFIG_RCU_TRACE.
Documentation/RCU/trace.txt+19−16
@@ -256,23 +256,23 @@ o Each element of the form "1/1 0:127 ^0" represents one struct · 255 unmodified lines
256256 The output of "cat rcu/rcu_pending" looks as follows:
257257
258258 rcu_sched:
259− 0 np=255892 qsp=53936 cbr=0 cng=14417 gpc=10033 gps=24320 nf=6445 nn=146741
260− 1 np=261224 qsp=54638 cbr=0 cng=25723 gpc=16310 gps=2849 nf=5912 nn=155792
261− 2 np=237496 qsp=49664 cbr=0 cng=2762 gpc=45478 gps=1762 nf=1201 nn=136629
262− 3 np=236249 qsp=48766 cbr=0 cng=286 gpc=48049 gps=1218 nf=207 nn=137723
263− 4 np=221310 qsp=46850 cbr=0 cng=26 gpc=43161 gps=4634 nf=3529 nn=123110
264− 5 np=237332 qsp=48449 cbr=0 cng=54 gpc=47920 gps=3252 nf=201 nn=137456
265− 6 np=219995 qsp=46718 cbr=0 cng=50 gpc=42098 gps=6093 nf=4202 nn=120834
266− 7 np=249893 qsp=49390 cbr=0 cng=72 gpc=38400 gps=17102 nf=41 nn=144888
259+ 0 np=255892 qsp=53936 rpq=85 cbr=0 cng=14417 gpc=10033 gps=24320 nf=6445 nn=146741
260+ 1 np=261224 qsp=54638 rpq=33 cbr=0 cng=25723 gpc=16310 gps=2849 nf=5912 nn=155792
261+ 2 np=237496 qsp=49664 rpq=23 cbr=0 cng=2762 gpc=45478 gps=1762 nf=1201 nn=136629
262+ 3 np=236249 qsp=48766 rpq=98 cbr=0 cng=286 gpc=48049 gps=1218 nf=207 nn=137723
263+ 4 np=221310 qsp=46850 rpq=7 cbr=0 cng=26 gpc=43161 gps=4634 nf=3529 nn=123110
264+ 5 np=237332 qsp=48449 rpq=9 cbr=0 cng=54 gpc=47920 gps=3252 nf=201 nn=137456
265+ 6 np=219995 qsp=46718 rpq=12 cbr=0 cng=50 gpc=42098 gps=6093 nf=4202 nn=120834
266+ 7 np=249893 qsp=49390 rpq=42 cbr=0 cng=72 gpc=38400 gps=17102 nf=41 nn=144888
267267 rcu_bh:
268− 0 np=146741 qsp=1419 cbr=0 cng=6 gpc=0 gps=0 nf=2 nn=145314
269− 1 np=155792 qsp=12597 cbr=0 cng=0 gpc=4 gps=8 nf=3 nn=143180
270− 2 np=136629 qsp=18680 cbr=0 cng=0 gpc=7 gps=6 nf=0 nn=117936
271− 3 np=137723 qsp=2843 cbr=0 cng=0 gpc=10 gps=7 nf=0 nn=134863
272− 4 np=123110 qsp=12433 cbr=0 cng=0 gpc=4 gps=2 nf=0 nn=110671
273− 5 np=137456 qsp=4210 cbr=0 cng=0 gpc=6 gps=5 nf=0 nn=133235
274− 6 np=120834 qsp=9902 cbr=0 cng=0 gpc=6 gps=3 nf=2 nn=110921
275− 7 np=144888 qsp=26336 cbr=0 cng=0 gpc=8 gps=2 nf=0 nn=118542
268+ 0 np=146741 qsp=1419 rpq=6 cbr=0 cng=6 gpc=0 gps=0 nf=2 nn=145314
269+ 1 np=155792 qsp=12597 rpq=3 cbr=0 cng=0 gpc=4 gps=8 nf=3 nn=143180
270+ 2 np=136629 qsp=18680 rpq=1 cbr=0 cng=0 gpc=7 gps=6 nf=0 nn=117936
271+ 3 np=137723 qsp=2843 rpq=0 cbr=0 cng=0 gpc=10 gps=7 nf=0 nn=134863
272+ 4 np=123110 qsp=12433 rpq=0 cbr=0 cng=0 gpc=4 gps=2 nf=0 nn=110671
273+ 5 np=137456 qsp=4210 rpq=1 cbr=0 cng=0 gpc=6 gps=5 nf=0 nn=133235
274+ 6 np=120834 qsp=9902 rpq=2 cbr=0 cng=0 gpc=6 gps=3 nf=2 nn=110921
275+ 7 np=144888 qsp=26336 rpq=0 cbr=0 cng=0 gpc=8 gps=2 nf=0 nn=118542
276276
277277 As always, this is once again split into "rcu_sched" and "rcu_bh"
278278 portions, with CONFIG_TREE_PREEMPT_RCU kernels having an additional
@@ -284,6 +284,9 @@ o "np" is the number of times that __rcu_pending() has been invoked · 5 unmodified lines
284284 o "qsp" is the number of times that the RCU was waiting for a
285285 quiescent state from this CPU.
286286
287+o "rpq" is the number of times that the CPU had passed through
288+ a quiescent state, but not yet reported it to RCU.
289+
287290 o "cbr" is the number of times that this CPU had RCU callbacks
288291 that had passed through a grace period, and were thus ready
289292 to be invoked.
include/linux/debugobjects.h+11−0
@@ -20,12 +20,14 @@ struct debug_obj_descr; · 19 unmodified lines
2020 * struct debug_obj - representaion of an tracked object
2121 * @node: hlist node to link the object into the tracker list
2222 * @state: tracked object state
23+ * @astate: current active state
2324 * @object: pointer to the real object
2425 * @descr: pointer to an object type specific debug description structure
2526 */
2627 struct debug_obj {
2728 struct hlist_node node;
2829 enum debug_obj_state state;
30+ unsigned int astate;
2931 void *object;
3032 struct debug_obj_descr *descr;
3133 };
@@ -60,6 +62,15 @@ extern void debug_object_deactivate(void *addr, struct debug_obj_descr *descr); · 28 unmodified lines
6062 extern void debug_object_destroy (void *addr, struct debug_obj_descr *descr);
6163 extern void debug_object_free (void *addr, struct debug_obj_descr *descr);
6264
65+/*
66+ * Active state:
67+ * - Set at 0 upon initialization.
68+ * - Must return to 0 before deactivation.
69+ */
70+extern void
71+debug_object_active_state(void *addr, struct debug_obj_descr *descr,
72+ unsigned int expect, unsigned int next);
73+
6374 extern void debug_objects_early_init(void);
6475 extern void debug_objects_mem_init(void);
6576 #else
include/linux/init_task.h+0−1
@@ -49,7 +49,6 @@ extern struct group_info init_groups; · 48 unmodified lines
4949 { .first = &init_task.pids[PIDTYPE_PGID].node }, \
5050 { .first = &init_task.pids[PIDTYPE_SID].node }, \
5151 }, \
52− .rcu = RCU_HEAD_INIT, \
5352 .level = 0, \
5453 .numbers = { { \
5554 .nr = 0, \
include/linux/rcupdate.h+32−18
@@ -56,8 +56,6 @@ struct rcu_head { · 55 unmodified lines
5656 };
5757
5858 /* Exported common interfaces */
59−extern void synchronize_rcu_bh(void);
60−extern void synchronize_sched(void);
6159 extern void rcu_barrier(void);
6260 extern void rcu_barrier_bh(void);
6361 extern void rcu_barrier_sched(void);
@@ -66,8 +64,6 @@ extern int sched_expedited_torture_stats(char *page); · 2 unmodified lines
6664
6765 /* Internal to kernel */
6866 extern void rcu_init(void);
69−extern int rcu_scheduler_active;
70−extern void rcu_scheduler_starting(void);
7167
7268 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
7369 #include <linux/rcutree.h>
@@ -83,6 +79,14 @@ extern void rcu_scheduler_starting(void); · 9 unmodified lines
8379 (ptr)->next = NULL; (ptr)->func = NULL; \
8480 } while (0)
8581
82+static inline void init_rcu_head_on_stack(struct rcu_head *head)
83+{
84+}
85+
86+static inline void destroy_rcu_head_on_stack(struct rcu_head *head)
87+{
88+}
89+
8690 #ifdef CONFIG_DEBUG_LOCK_ALLOC
8791
8892 extern struct lockdep_map rcu_lock_map;
@@ -106,12 +110,13 @@ extern int debug_lockdep_rcu_enabled(void); · 17 unmodified lines
106110 /**
107111 * rcu_read_lock_held - might we be in RCU read-side critical section?
108112 *
109− * If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in
110− * an RCU read-side critical section. In absence of CONFIG_PROVE_LOCKING,
113+ * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an RCU
114+ * read-side critical section. In absence of CONFIG_DEBUG_LOCK_ALLOC,
111115 * this assumes we are in an RCU read-side critical section unless it can
112116 * prove otherwise.
113117 *
114− * Check rcu_scheduler_active to prevent false positives during boot.
118+ * Check debug_lockdep_rcu_enabled() to prevent false positives during boot
119+ * and while lockdep is disabled.
115120 */
116121 static inline int rcu_read_lock_held(void)
117122 {
@@ -129,13 +134,15 @@ extern int rcu_read_lock_bh_held(void); · 11 unmodified lines
129134 /**
130135 * rcu_read_lock_sched_held - might we be in RCU-sched read-side critical section?
131136 *
132− * If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in an
133− * RCU-sched read-side critical section. In absence of CONFIG_PROVE_LOCKING,
134− * this assumes we are in an RCU-sched read-side critical section unless it
135− * can prove otherwise. Note that disabling of preemption (including
136− * disabling irqs) counts as an RCU-sched read-side critical section.
137+ * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an
138+ * RCU-sched read-side critical section. In absence of
139+ * CONFIG_DEBUG_LOCK_ALLOC, this assumes we are in an RCU-sched read-side
140+ * critical section unless it can prove otherwise. Note that disabling
141+ * of preemption (including disabling irqs) counts as an RCU-sched
142+ * read-side critical section.
137143 *
138− * Check rcu_scheduler_active to prevent false positives during boot.
144+ * Check debug_lockdep_rcu_enabled() to prevent false positives during boot
145+ * and while lockdep is disabled.
139146 */
140147 #ifdef CONFIG_PREEMPT
141148 static inline int rcu_read_lock_sched_held(void)
@@ -177,7 +184,7 @@ static inline int rcu_read_lock_bh_held(void) · 35 unmodified lines
177184 #ifdef CONFIG_PREEMPT
178185 static inline int rcu_read_lock_sched_held(void)
179186 {
180− return !rcu_scheduler_active || preempt_count() != 0 || irqs_disabled();
187+ return preempt_count() != 0 || irqs_disabled();
181188 }
182189 #else /* #ifdef CONFIG_PREEMPT */
183190 static inline int rcu_read_lock_sched_held(void)
@@ -192,6 +199,15 @@ static inline int rcu_read_lock_sched_held(void) · 8 unmodified lines
192199
193200 extern int rcu_my_thread_group_empty(void);
194201
202+#define __do_rcu_dereference_check(c) \
203+ do { \
204+ static bool __warned; \
205+ if (debug_lockdep_rcu_enabled() && !__warned && !(c)) { \
206+ __warned = true; \
207+ lockdep_rcu_dereference(__FILE__, __LINE__); \
208+ } \
209+ } while (0)
210+
195211 /**
196212 * rcu_dereference_check - rcu_dereference with debug checking
197213 * @p: The pointer to read, prior to dereferencing
@@ -221,8 +237,7 @@ extern int rcu_my_thread_group_empty(void); · 23 unmodified lines
221237 */
222238 #define rcu_dereference_check(p, c) \
223239 ({ \
224− if (debug_lockdep_rcu_enabled() && !(c)) \
225− lockdep_rcu_dereference(__FILE__, __LINE__); \
240+ __do_rcu_dereference_check(c); \
226241 rcu_dereference_raw(p); \
227242 })
228243
@@ -239,8 +254,7 @@ extern int rcu_my_thread_group_empty(void); · 10 unmodified lines
239254 */
240255 #define rcu_dereference_protected(p, c) \
241256 ({ \
242− if (debug_lockdep_rcu_enabled() && !(c)) \
243− lockdep_rcu_dereference(__FILE__, __LINE__); \
257+ __do_rcu_dereference_check(c); \
244258 (p); \
245259 })
246260
include/linux/rcutiny.h+28−1
@@ -29,6 +29,10 @@ · 28 unmodified lines
2929
3030 void rcu_sched_qs(int cpu);
3131 void rcu_bh_qs(int cpu);
32+static inline void rcu_note_context_switch(int cpu)
33+{
34+ rcu_sched_qs(cpu);
35+}
3236
3337 #define __rcu_read_lock() preempt_disable()
3438 #define __rcu_read_unlock() preempt_enable()
@@ -74,7 +78,17 @@ static inline void rcu_sched_force_quiescent_state(void) · 39 unmodified lines
7478 {
7579 }
7680
77−#define synchronize_rcu synchronize_sched
81+extern void synchronize_sched(void);
82+
83+static inline void synchronize_rcu(void)
84+{
85+ synchronize_sched();
86+}
87+
88+static inline void synchronize_rcu_bh(void)
89+{
90+ synchronize_sched();
91+}
7892
7993 static inline void synchronize_rcu_expedited(void)
8094 {
@@ -114,4 +128,17 @@ static inline int rcu_preempt_depth(void) · 33 unmodified lines
114128 return 0;
115129 }
116130
131+#ifdef CONFIG_DEBUG_LOCK_ALLOC
132+
133+extern int rcu_scheduler_active __read_mostly;
134+extern void rcu_scheduler_starting(void);
135+
136+#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
137+
138+static inline void rcu_scheduler_starting(void)
139+{
140+}
141+
142+#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
143+
117144 #endif /* __LINUX_RCUTINY_H */
include/linux/rcutree.h+6−0
@@ -34,6 +34,7 @@ struct notifier_block; · 33 unmodified lines
3434
3535 extern void rcu_sched_qs(int cpu);
3636 extern void rcu_bh_qs(int cpu);
37+extern void rcu_note_context_switch(int cpu);
3738 extern int rcu_needs_cpu(int cpu);
3839 extern int rcu_expedited_torture_stats(char *page);
3940
@@ -86,6 +87,8 @@ static inline void __rcu_read_unlock_bh(void) · 46 unmodified lines
8687
8788 extern void call_rcu_sched(struct rcu_head *head,
8889 void (*func)(struct rcu_head *rcu));
90+extern void synchronize_rcu_bh(void);
91+extern void synchronize_sched(void);
8992 extern void synchronize_rcu_expedited(void);
9093
9194 static inline void synchronize_rcu_bh_expedited(void)
@@ -120,4 +123,7 @@ static inline int rcu_blocking_is_gp(void) · 28 unmodified lines
120123 return num_online_cpus() == 1;
121124 }
122125
126+extern void rcu_scheduler_starting(void);
127+extern int rcu_scheduler_active __read_mostly;
128+
123129 #endif /* __LINUX_RCUTREE_H */
include/linux/srcu.h+4−2
@@ -27,6 +27,8 @@ · 26 unmodified lines
2727 #ifndef _LINUX_SRCU_H
2828 #define _LINUX_SRCU_H
2929
30+#include <linux/mutex.h>
31+
3032 struct srcu_struct_array {
3133 int c[2];
3234 };
@@ -84,8 +86,8 @@ long srcu_batches_completed(struct srcu_struct *sp); · 51 unmodified lines
8486 /**
8587 * srcu_read_lock_held - might we be in SRCU read-side critical section?
8688 *
87− * If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in
88− * an SRCU read-side critical section. In absence of CONFIG_PROVE_LOCKING,
89+ * If CONFIG_DEBUG_LOCK_ALLOC is selected, returns nonzero iff in an SRCU
90+ * read-side critical section. In absence of CONFIG_DEBUG_LOCK_ALLOC,
8991 * this assumes we are in an SRCU read-side critical section unless it can
9092 * prove otherwise.
9193 */
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);
lib/Kconfig.debug+13−1
@@ -512,6 +512,18 @@ config PROVE_RCU · 511 unmodified lines
512512
513513 Say N if you are unsure.
514514
515+config PROVE_RCU_REPEATEDLY
516+ bool "RCU debugging: don't disable PROVE_RCU on first splat"
517+ depends on PROVE_RCU
518+ default n
519+ help
520+ By itself, PROVE_RCU will disable checking upon issuing the
521+ first warning (or "splat"). This feature prevents such
522+ disabling, allowing multiple RCU-lockdep warnings to be printed
523+ on a single reboot.
524+
525+ Say N if you are unsure.
526+
515527 config LOCKDEP
516528 bool
517529 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
@@ -793,7 +805,7 @@ config RCU_CPU_STALL_DETECTOR · 275 unmodified lines
793805 config RCU_CPU_STALL_VERBOSE
794806 bool "Print additional per-task information for RCU_CPU_STALL_DETECTOR"
795807 depends on RCU_CPU_STALL_DETECTOR && TREE_PREEMPT_RCU
796− default n
808+ default y
797809 help
798810 This option causes RCU to printk detailed per-task information
799811 for any tasks that are stalling the current RCU grace period.
lib/debugobjects.c+56−3
@@ -141,6 +141,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr) · 140 unmodified lines
141141 obj->object = addr;
142142 obj->descr = descr;
143143 obj->state = ODEBUG_STATE_NONE;
144+ obj->astate = 0;
144145 hlist_del(&obj->node);
145146
146147 hlist_add_head(&obj->node, &b->list);
@@ -252,8 +253,10 @@ static void debug_print_object(struct debug_obj *obj, char *msg) · 105 unmodified lines
252253
253254 if (limit < 5 && obj->descr != descr_test) {
254255 limit++;
255− WARN(1, KERN_ERR "ODEBUG: %s %s object type: %s\n", msg,
256− obj_states[obj->state], obj->descr->name);
256+ WARN(1, KERN_ERR "ODEBUG: %s %s (active state %u) "
257+ "object type: %s\n",
258+ msg, obj_states[obj->state], obj->astate,
259+ obj->descr->name);
257260 }
258261 debug_objects_warnings++;
259262 }
@@ -447,7 +450,10 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr) · 187 unmodified lines
447450 case ODEBUG_STATE_INIT:
448451 case ODEBUG_STATE_INACTIVE:
449452 case ODEBUG_STATE_ACTIVE:
450− obj->state = ODEBUG_STATE_INACTIVE;
453+ if (!obj->astate)
454+ obj->state = ODEBUG_STATE_INACTIVE;
455+ else
456+ debug_print_object(obj, "deactivate");
451457 break;
452458
453459 case ODEBUG_STATE_DESTROYED:
@@ -553,6 +559,53 @@ out_unlock: · 99 unmodified lines
553559 raw_spin_unlock_irqrestore(&db->lock, flags);
554560 }
555561
562+/**
563+ * debug_object_active_state - debug checks object usage state machine
564+ * @addr: address of the object
565+ * @descr: pointer to an object specific debug description structure
566+ * @expect: expected state
567+ * @next: state to move to if expected state is found
568+ */
569+void
570+debug_object_active_state(void *addr, struct debug_obj_descr *descr,
571+ unsigned int expect, unsigned int next)
572+{
573+ struct debug_bucket *db;
574+ struct debug_obj *obj;
575+ unsigned long flags;
576+
577+ if (!debug_objects_enabled)
578+ return;
579+
580+ db = get_bucket((unsigned long) addr);
581+
582+ raw_spin_lock_irqsave(&db->lock, flags);
583+
584+ obj = lookup_object(addr, db);
585+ if (obj) {
586+ switch (obj->state) {
587+ case ODEBUG_STATE_ACTIVE:
588+ if (obj->astate == expect)
589+ obj->astate = next;
590+ else
591+ debug_print_object(obj, "active_state");
592+ break;
593+
594+ default:
595+ debug_print_object(obj, "active_state");
596+ break;
597+ }
598+ } else {
599+ struct debug_obj o = { .object = addr,
600+ .state = ODEBUG_STATE_NOTAVAILABLE,
601+ .descr = descr };
602+
603+ debug_print_object(&o, "active_state");
604+ }
605+
606+ raw_spin_unlock_irqrestore(&db->lock, flags);
607+}
608+
556609 #ifdef CONFIG_DEBUG_OBJECTS_FREE
557610 static void __debug_check_no_obj_freed(const void *address, unsigned long size)
558611 {