diff options
Diffstat (limited to 'include/linux/rcupdate.h')
-rw-r--r-- | include/linux/rcupdate.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index b653b4aaa8a6..9fbc54a2585d 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 |
45 | extern int rcutorture_runnable; /* for sysctl */ | 46 | extern 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 | ||
90 | extern void init_rcu_head_on_stack(struct rcu_head *head); | ||
91 | extern void destroy_rcu_head_on_stack(struct rcu_head *head); | ||
92 | #else /* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ | ||
82 | static inline void init_rcu_head_on_stack(struct rcu_head *head) | 93 | static 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) | |||
86 | static inline void destroy_rcu_head_on_stack(struct rcu_head *head) | 97 | static 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,74 @@ extern void call_rcu(struct rcu_head *head, | |||
517 | extern void call_rcu_bh(struct rcu_head *head, | 529 | extern 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 | |||
542 | extern struct debug_obj_descr rcuhead_debug_descr; | ||
543 | |||
544 | static 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 | |||
552 | static 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 */ | ||
560 | static inline void debug_rcu_head_queue(struct rcu_head *head) | ||
561 | { | ||
562 | } | ||
563 | |||
564 | static inline void debug_rcu_head_unqueue(struct rcu_head *head) | ||
565 | { | ||
566 | } | ||
567 | #endif /* #else !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ | ||
568 | |||
569 | #ifndef CONFIG_PROVE_RCU | ||
570 | #define __do_rcu_dereference_check(c) do { } while (0) | ||
571 | #endif /* #ifdef CONFIG_PROVE_RCU */ | ||
572 | |||
573 | #define __rcu_dereference_index_check(p, c) \ | ||
574 | ({ \ | ||
575 | typeof(p) _________p1 = ACCESS_ONCE(p); \ | ||
576 | __do_rcu_dereference_check(c); \ | ||
577 | smp_read_barrier_depends(); \ | ||
578 | (_________p1); \ | ||
579 | }) | ||
580 | |||
581 | /** | ||
582 | * rcu_dereference_index_check() - rcu_dereference for indices with debug checking | ||
583 | * @p: The pointer to read, prior to dereferencing | ||
584 | * @c: The conditions under which the dereference will take place | ||
585 | * | ||
586 | * Similar to rcu_dereference_check(), but omits the sparse checking. | ||
587 | * This allows rcu_dereference_index_check() to be used on integers, | ||
588 | * which can then be used as array indices. Attempting to use | ||
589 | * rcu_dereference_check() on an integer will give compiler warnings | ||
590 | * because the sparse address-space mechanism relies on dereferencing | ||
591 | * the RCU-protected pointer. Dereferencing integers is not something | ||
592 | * that even gcc will put up with. | ||
593 | * | ||
594 | * Note that this function does not implicitly check for RCU read-side | ||
595 | * critical sections. If this function gains lots of uses, it might | ||
596 | * make sense to provide versions for each flavor of RCU, but it does | ||
597 | * not make sense as of early 2010. | ||
598 | */ | ||
599 | #define rcu_dereference_index_check(p, c) \ | ||
600 | __rcu_dereference_index_check((p), (c)) | ||
601 | |||
520 | #endif /* __LINUX_RCUPDATE_H */ | 602 | #endif /* __LINUX_RCUPDATE_H */ |