aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/rcupdate.h
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2010-04-17 08:48:42 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2010-06-14 19:37:26 -0400
commit551d55a944b143ef26fbd482d1c463199d6f65cf (patch)
tree6911d3f8e8719ba5ca43c83acdf87cbc8276d7d1 /include/linux/rcupdate.h
parent875352c94224c88f5aa28cb77206f993bd31b7a2 (diff)
tree/tiny rcu: Add debug RCU head objects
Helps finding racy users of call_rcu(), which results in hangs because list entries are overwritten and/or skipped. Changelog since v4: - Bissectability is now OK - Now generate a WARN_ON_ONCE() for non-initialized rcu_head passed to call_rcu(). Statically initialized objects are detected with object_is_static(). - Rename rcu_head_init_on_stack to init_rcu_head_on_stack. - Remove init_rcu_head() completely. Changelog since v3: - Include comments from Lai Jiangshan This new patch version is based on the debugobjects with the newly introduced "active state" tracker. Non-initialized entries are all considered as "statically initialized". An activation fixup (triggered by call_rcu()) takes care of performing the debug object initialization without issuing any warning. Since we cannot increase the size of struct rcu_head, I don't see much room to put an identifier for statically initialized rcu_head structures. So for now, we have to live without "activation without explicit init" detection. But the main purpose of this debug option is to detect double-activations (double call_rcu() use of a rcu_head before the callback is executed), which is correctly addressed here. This also detects potential internal RCU callback corruption, which would cause the callbacks to be executed twice. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> CC: David S. Miller <davem@davemloft.net> CC: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> CC: akpm@linux-foundation.org CC: mingo@elte.hu CC: laijs@cn.fujitsu.com CC: dipankar@in.ibm.com CC: josh@joshtriplett.org CC: dvhltc@us.ibm.com CC: niv@us.ibm.com CC: tglx@linutronix.de CC: peterz@infradead.org CC: rostedt@goodmis.org CC: Valdis.Kletnieks@vt.edu CC: dhowells@redhat.com CC: eric.dumazet@gmail.com CC: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Diffstat (limited to 'include/linux/rcupdate.h')
-rw-r--r--include/linux/rcupdate.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index b653b4aaa8a..2b7fc506e47 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -40,6 +40,7 @@
40#include <linux/seqlock.h> 40#include <linux/seqlock.h>
41#include <linux/lockdep.h> 41#include <linux/lockdep.h>
42#include <linux/completion.h> 42#include <linux/completion.h>
43#include <linux/debugobjects.h>
43 44
44#ifdef CONFIG_RCU_TORTURE_TEST 45#ifdef CONFIG_RCU_TORTURE_TEST
45extern int rcutorture_runnable; /* for sysctl */ 46extern int rcutorture_runnable; /* for sysctl */
@@ -79,6 +80,16 @@ extern void rcu_init(void);
79 (ptr)->next = NULL; (ptr)->func = NULL; \ 80 (ptr)->next = NULL; (ptr)->func = NULL; \
80} while (0) 81} while (0)
81 82
83/*
84 * init_rcu_head_on_stack()/destroy_rcu_head_on_stack() are needed for dynamic
85 * initialization and destruction of rcu_head on the stack. rcu_head structures
86 * allocated dynamically in the heap or defined statically don't need any
87 * initialization.
88 */
89#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
90extern void init_rcu_head_on_stack(struct rcu_head *head);
91extern void destroy_rcu_head_on_stack(struct rcu_head *head);
92#else /* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
82static inline void init_rcu_head_on_stack(struct rcu_head *head) 93static inline void init_rcu_head_on_stack(struct rcu_head *head)
83{ 94{
84} 95}
@@ -86,6 +97,7 @@ static inline void init_rcu_head_on_stack(struct rcu_head *head)
86static inline void destroy_rcu_head_on_stack(struct rcu_head *head) 97static inline void destroy_rcu_head_on_stack(struct rcu_head *head)
87{ 98{
88} 99}
100#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
89 101
90#ifdef CONFIG_DEBUG_LOCK_ALLOC 102#ifdef CONFIG_DEBUG_LOCK_ALLOC
91 103
@@ -517,4 +529,41 @@ extern void call_rcu(struct rcu_head *head,
517extern void call_rcu_bh(struct rcu_head *head, 529extern void call_rcu_bh(struct rcu_head *head,
518 void (*func)(struct rcu_head *head)); 530 void (*func)(struct rcu_head *head));
519 531
532/*
533 * debug_rcu_head_queue()/debug_rcu_head_unqueue() are used internally
534 * by call_rcu() and rcu callback execution, and are therefore not part of the
535 * RCU API. Leaving in rcupdate.h because they are used by all RCU flavors.
536 */
537
538#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
539# define STATE_RCU_HEAD_READY 0
540# define STATE_RCU_HEAD_QUEUED 1
541
542extern struct debug_obj_descr rcuhead_debug_descr;
543
544static inline void debug_rcu_head_queue(struct rcu_head *head)
545{
546 debug_object_activate(head, &rcuhead_debug_descr);
547 debug_object_active_state(head, &rcuhead_debug_descr,
548 STATE_RCU_HEAD_READY,
549 STATE_RCU_HEAD_QUEUED);
550}
551
552static inline void debug_rcu_head_unqueue(struct rcu_head *head)
553{
554 debug_object_active_state(head, &rcuhead_debug_descr,
555 STATE_RCU_HEAD_QUEUED,
556 STATE_RCU_HEAD_READY);
557 debug_object_deactivate(head, &rcuhead_debug_descr);
558}
559#else /* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
560static inline void debug_rcu_head_queue(struct rcu_head *head)
561{
562}
563
564static inline void debug_rcu_head_unqueue(struct rcu_head *head)
565{
566}
567#endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */
568
520#endif /* __LINUX_RCUPDATE_H */ 569#endif /* __LINUX_RCUPDATE_H */