@@ -51,64 +51,22 @@ static struct rcu_ctrlblk rcu_sched_ctrlblk = {
5151 .curtail = & rcu_sched_ctrlblk .rcucblist ,
5252};
5353
54- static struct rcu_ctrlblk rcu_bh_ctrlblk = {
55- .donetail = & rcu_bh_ctrlblk .rcucblist ,
56- .curtail = & rcu_bh_ctrlblk .rcucblist ,
57- };
58-
59- void rcu_barrier_bh (void )
60- {
61- wait_rcu_gp (call_rcu_bh );
62- }
63- EXPORT_SYMBOL (rcu_barrier_bh );
64-
6554void rcu_barrier_sched (void )
6655{
6756 wait_rcu_gp (call_rcu_sched );
6857}
6958EXPORT_SYMBOL (rcu_barrier_sched );
7059
71- /*
72- * Helper function for rcu_sched_qs() and rcu_bh_qs().
73- * Also irqs are disabled to avoid confusion due to interrupt handlers
74- * invoking call_rcu().
75- */
76- static int rcu_qsctr_help (struct rcu_ctrlblk * rcp )
77- {
78- if (rcp -> donetail != rcp -> curtail ) {
79- rcp -> donetail = rcp -> curtail ;
80- return 1 ;
81- }
82-
83- return 0 ;
84- }
85-
86- /*
87- * Record an rcu quiescent state. And an rcu_bh quiescent state while we
88- * are at it, given that any rcu quiescent state is also an rcu_bh
89- * quiescent state. Use "+" instead of "||" to defeat short circuiting.
90- */
60+ /* Record an rcu quiescent state. */
9161void rcu_sched_qs (void )
9262{
9363 unsigned long flags ;
9464
9565 local_irq_save (flags );
96- if (rcu_qsctr_help (& rcu_sched_ctrlblk ) +
97- rcu_qsctr_help (& rcu_bh_ctrlblk ))
98- raise_softirq (RCU_SOFTIRQ );
99- local_irq_restore (flags );
100- }
101-
102- /*
103- * Record an rcu_bh quiescent state.
104- */
105- void rcu_bh_qs (void )
106- {
107- unsigned long flags ;
108-
109- local_irq_save (flags );
110- if (rcu_qsctr_help (& rcu_bh_ctrlblk ))
66+ if (rcu_sched_ctrlblk .donetail != rcu_sched_ctrlblk .curtail ) {
67+ rcu_sched_ctrlblk .donetail = rcu_sched_ctrlblk .curtail ;
11168 raise_softirq (RCU_SOFTIRQ );
69+ }
11270 local_irq_restore (flags );
11371}
11472
@@ -122,32 +80,27 @@ void rcu_check_callbacks(int user)
12280{
12381 if (user )
12482 rcu_sched_qs ();
125- if (user || !in_softirq ())
126- rcu_bh_qs ();
12783}
12884
129- /*
130- * Invoke the RCU callbacks on the specified rcu_ctrlkblk structure
131- * whose grace period has elapsed.
132- */
133- static void __rcu_process_callbacks (struct rcu_ctrlblk * rcp )
85+ /* Invoke the RCU callbacks whose grace period has elapsed. */
86+ static __latent_entropy void rcu_process_callbacks (struct softirq_action * unused )
13487{
13588 struct rcu_head * next , * list ;
13689 unsigned long flags ;
13790
13891 /* Move the ready-to-invoke callbacks to a local list. */
13992 local_irq_save (flags );
140- if (rcp -> donetail == & rcp -> rcucblist ) {
93+ if (rcu_sched_ctrlblk . donetail == & rcu_sched_ctrlblk . rcucblist ) {
14194 /* No callbacks ready, so just leave. */
14295 local_irq_restore (flags );
14396 return ;
14497 }
145- list = rcp -> rcucblist ;
146- rcp -> rcucblist = * rcp -> donetail ;
147- * rcp -> donetail = NULL ;
148- if (rcp -> curtail == rcp -> donetail )
149- rcp -> curtail = & rcp -> rcucblist ;
150- rcp -> donetail = & rcp -> rcucblist ;
98+ list = rcu_sched_ctrlblk . rcucblist ;
99+ rcu_sched_ctrlblk . rcucblist = * rcu_sched_ctrlblk . donetail ;
100+ * rcu_sched_ctrlblk . donetail = NULL ;
101+ if (rcu_sched_ctrlblk . curtail == rcu_sched_ctrlblk . donetail )
102+ rcu_sched_ctrlblk . curtail = & rcu_sched_ctrlblk . rcucblist ;
103+ rcu_sched_ctrlblk . donetail = & rcu_sched_ctrlblk . rcucblist ;
151104 local_irq_restore (flags );
152105
153106 /* Invoke the callbacks on the local list. */
@@ -162,19 +115,13 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
162115 }
163116}
164117
165- static __latent_entropy void rcu_process_callbacks (struct softirq_action * unused )
166- {
167- __rcu_process_callbacks (& rcu_sched_ctrlblk );
168- __rcu_process_callbacks (& rcu_bh_ctrlblk );
169- }
170-
171118/*
172119 * Wait for a grace period to elapse. But it is illegal to invoke
173120 * synchronize_sched() from within an RCU read-side critical section.
174121 * Therefore, any legal call to synchronize_sched() is a quiescent
175122 * state, and so on a UP system, synchronize_sched() need do nothing.
176- * Ditto for synchronize_rcu_bh(). ( But Lai Jiangshan points out the
177- * benefits of doing might_sleep() to reduce latency.)
123+ * ( But Lai Jiangshan points out the benefits of doing might_sleep()
124+ * to reduce latency.)
178125 *
179126 * Cool, huh? (Due to Josh Triplett.)
180127 */
@@ -188,11 +135,11 @@ void synchronize_sched(void)
188135EXPORT_SYMBOL_GPL (synchronize_sched );
189136
190137/*
191- * Helper function for call_rcu() and call_rcu_bh().
138+ * Post an RCU callback to be invoked after the end of an RCU-sched grace
139+ * period. But since we have but one CPU, that would be after any
140+ * quiescent state.
192141 */
193- static void __call_rcu (struct rcu_head * head ,
194- rcu_callback_t func ,
195- struct rcu_ctrlblk * rcp )
142+ void call_rcu_sched (struct rcu_head * head , rcu_callback_t func )
196143{
197144 unsigned long flags ;
198145
@@ -201,37 +148,17 @@ static void __call_rcu(struct rcu_head *head,
201148 head -> next = NULL ;
202149
203150 local_irq_save (flags );
204- * rcp -> curtail = head ;
205- rcp -> curtail = & head -> next ;
151+ * rcu_sched_ctrlblk . curtail = head ;
152+ rcu_sched_ctrlblk . curtail = & head -> next ;
206153 local_irq_restore (flags );
207154
208155 if (unlikely (is_idle_task (current ))) {
209156 /* force scheduling for rcu_sched_qs() */
210157 resched_cpu (0 );
211158 }
212159}
213-
214- /*
215- * Post an RCU callback to be invoked after the end of an RCU-sched grace
216- * period. But since we have but one CPU, that would be after any
217- * quiescent state.
218- */
219- void call_rcu_sched (struct rcu_head * head , rcu_callback_t func )
220- {
221- __call_rcu (head , func , & rcu_sched_ctrlblk );
222- }
223160EXPORT_SYMBOL_GPL (call_rcu_sched );
224161
225- /*
226- * Post an RCU bottom-half callback to be invoked after any subsequent
227- * quiescent state.
228- */
229- void call_rcu_bh (struct rcu_head * head , rcu_callback_t func )
230- {
231- __call_rcu (head , func , & rcu_bh_ctrlblk );
232- }
233- EXPORT_SYMBOL_GPL (call_rcu_bh );
234-
235162void __init rcu_init (void )
236163{
237164 open_softirq (RCU_SOFTIRQ , rcu_process_callbacks );
0 commit comments