diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2010-08-17 17:18:46 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2010-08-20 12:00:16 -0400 |
commit | 7b0b759b65247cbc66384a912be9acf8d4800636 (patch) | |
tree | 085a18f506193725ab16fa61cae41f93dcc7c3e9 /include/linux/rcupdate.h | |
parent | 73d4da4d360136826b36f78f5cf72b29da82c8a6 (diff) |
rcu: combine duplicate code, courtesy of CONFIG_PREEMPT_RCU
The CONFIG_PREEMPT_RCU kernel configuration parameter was recently
re-introduced, but as an indication of the type of RCU (preemptible
vs. non-preemptible) instead of as selecting a given implementation.
This commit uses CONFIG_PREEMPT_RCU to combine duplicate code
from include/linux/rcutiny.h and include/linux/rcutree.h into
include/linux/rcupdate.h. This commit also combines a few other pieces
of duplicate code that have accumulated.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'include/linux/rcupdate.h')
-rw-r--r-- | include/linux/rcupdate.h | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 325bad7bbca9..89414d67d961 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
@@ -61,16 +61,30 @@ struct rcu_head { | |||
61 | }; | 61 | }; |
62 | 62 | ||
63 | /* Exported common interfaces */ | 63 | /* Exported common interfaces */ |
64 | extern void call_rcu_sched(struct rcu_head *head, | ||
65 | void (*func)(struct rcu_head *rcu)); | ||
66 | extern void synchronize_sched(void); | ||
64 | extern void rcu_barrier_bh(void); | 67 | extern void rcu_barrier_bh(void); |
65 | extern void rcu_barrier_sched(void); | 68 | extern void rcu_barrier_sched(void); |
66 | extern void synchronize_sched_expedited(void); | 69 | extern void synchronize_sched_expedited(void); |
67 | extern int sched_expedited_torture_stats(char *page); | 70 | extern int sched_expedited_torture_stats(char *page); |
68 | 71 | ||
69 | /* Internal to kernel */ | 72 | static inline void __rcu_read_lock_bh(void) |
70 | extern void rcu_init(void); | 73 | { |
74 | local_bh_disable(); | ||
75 | } | ||
76 | |||
77 | static inline void __rcu_read_unlock_bh(void) | ||
78 | { | ||
79 | local_bh_enable(); | ||
80 | } | ||
71 | 81 | ||
72 | #ifdef CONFIG_PREEMPT_RCU | 82 | #ifdef CONFIG_PREEMPT_RCU |
73 | 83 | ||
84 | extern void __rcu_read_lock(void); | ||
85 | extern void __rcu_read_unlock(void); | ||
86 | void synchronize_rcu(void); | ||
87 | |||
74 | /* | 88 | /* |
75 | * Defined as a macro as it is a very low level header included from | 89 | * Defined as a macro as it is a very low level header included from |
76 | * areas that don't even know about current. This gives the rcu_read_lock() | 90 | * areas that don't even know about current. This gives the rcu_read_lock() |
@@ -79,7 +93,53 @@ extern void rcu_init(void); | |||
79 | */ | 93 | */ |
80 | #define rcu_preempt_depth() (current->rcu_read_lock_nesting) | 94 | #define rcu_preempt_depth() (current->rcu_read_lock_nesting) |
81 | 95 | ||
82 | #endif /* #ifdef CONFIG_PREEMPT_RCU */ | 96 | #else /* #ifdef CONFIG_PREEMPT_RCU */ |
97 | |||
98 | static inline void __rcu_read_lock(void) | ||
99 | { | ||
100 | preempt_disable(); | ||
101 | } | ||
102 | |||
103 | static inline void __rcu_read_unlock(void) | ||
104 | { | ||
105 | preempt_enable(); | ||
106 | } | ||
107 | |||
108 | static inline void synchronize_rcu(void) | ||
109 | { | ||
110 | synchronize_sched(); | ||
111 | } | ||
112 | |||
113 | static inline int rcu_preempt_depth(void) | ||
114 | { | ||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | #endif /* #else #ifdef CONFIG_PREEMPT_RCU */ | ||
119 | |||
120 | /* Internal to kernel */ | ||
121 | extern void rcu_init(void); | ||
122 | extern void rcu_sched_qs(int cpu); | ||
123 | extern void rcu_bh_qs(int cpu); | ||
124 | extern void rcu_check_callbacks(int cpu, int user); | ||
125 | struct notifier_block; | ||
126 | |||
127 | #ifdef CONFIG_NO_HZ | ||
128 | |||
129 | extern void rcu_enter_nohz(void); | ||
130 | extern void rcu_exit_nohz(void); | ||
131 | |||
132 | #else /* #ifdef CONFIG_NO_HZ */ | ||
133 | |||
134 | static inline void rcu_enter_nohz(void) | ||
135 | { | ||
136 | } | ||
137 | |||
138 | static inline void rcu_exit_nohz(void) | ||
139 | { | ||
140 | } | ||
141 | |||
142 | #endif /* #else #ifdef CONFIG_NO_HZ */ | ||
83 | 143 | ||
84 | #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) | 144 | #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) |
85 | #include <linux/rcutree.h> | 145 | #include <linux/rcutree.h> |
@@ -626,6 +686,8 @@ struct rcu_synchronize { | |||
626 | 686 | ||
627 | extern void wakeme_after_rcu(struct rcu_head *head); | 687 | extern void wakeme_after_rcu(struct rcu_head *head); |
628 | 688 | ||
689 | #ifdef CONFIG_PREEMPT_RCU | ||
690 | |||
629 | /** | 691 | /** |
630 | * call_rcu() - Queue an RCU callback for invocation after a grace period. | 692 | * call_rcu() - Queue an RCU callback for invocation after a grace period. |
631 | * @head: structure to be used for queueing the RCU updates. | 693 | * @head: structure to be used for queueing the RCU updates. |
@@ -642,6 +704,13 @@ extern void wakeme_after_rcu(struct rcu_head *head); | |||
642 | extern void call_rcu(struct rcu_head *head, | 704 | extern void call_rcu(struct rcu_head *head, |
643 | void (*func)(struct rcu_head *head)); | 705 | void (*func)(struct rcu_head *head)); |
644 | 706 | ||
707 | #else /* #ifdef CONFIG_PREEMPT_RCU */ | ||
708 | |||
709 | /* In classic RCU, call_rcu() is just call_rcu_sched(). */ | ||
710 | #define call_rcu call_rcu_sched | ||
711 | |||
712 | #endif /* #else #ifdef CONFIG_PREEMPT_RCU */ | ||
713 | |||
645 | /** | 714 | /** |
646 | * call_rcu_bh() - Queue an RCU for invocation after a quicker grace period. | 715 | * call_rcu_bh() - Queue an RCU for invocation after a quicker grace period. |
647 | * @head: structure to be used for queueing the RCU updates. | 716 | * @head: structure to be used for queueing the RCU updates. |