7373
7474/* Data structures. */
7575
76+ /*
77+ * Steal a bit from the bottom of ->dynticks for idle entry/exit
78+ * control. Initially this is for TLB flushing.
79+ */
80+ #define RCU_DYNTICK_CTRL_MASK 0x1
81+ #define RCU_DYNTICK_CTRL_CTR (RCU_DYNTICK_CTRL_MASK + 1)
82+ #ifndef rcu_eqs_special_exit
83+ #define rcu_eqs_special_exit () do { } while (0)
84+ #endif
85+
7686static DEFINE_PER_CPU_SHARED_ALIGNED (struct rcu_data , rcu_data ) = {
7787 .dynticks_nesting = 1 ,
7888 .dynticks_nmi_nesting = DYNTICK_IRQ_NONIDLE ,
89+ .dynticks = ATOMIC_INIT (RCU_DYNTICK_CTRL_CTR ),
7990};
8091struct rcu_state rcu_state = {
8192 .level = { & rcu_state .node [0 ] },
@@ -202,35 +213,21 @@ void rcu_softirq_qs(void)
202213 rcu_preempt_deferred_qs (current );
203214}
204215
205- /*
206- * Steal a bit from the bottom of ->dynticks for idle entry/exit
207- * control. Initially this is for TLB flushing.
208- */
209- #define RCU_DYNTICK_CTRL_MASK 0x1
210- #define RCU_DYNTICK_CTRL_CTR (RCU_DYNTICK_CTRL_MASK + 1)
211- #ifndef rcu_eqs_special_exit
212- #define rcu_eqs_special_exit () do { } while (0)
213- #endif
214-
215- static DEFINE_PER_CPU (struct rcu_dynticks , rcu_dynticks ) = {
216- .dynticks = ATOMIC_INIT (RCU_DYNTICK_CTRL_CTR ),
217- };
218-
219216/*
220217 * Record entry into an extended quiescent state. This is only to be
221218 * called when not already in an extended quiescent state.
222219 */
223220static void rcu_dynticks_eqs_enter (void )
224221{
225- struct rcu_dynticks * rdtp = this_cpu_ptr (& rcu_dynticks );
222+ struct rcu_data * rdp = this_cpu_ptr (& rcu_data );
226223 int seq ;
227224
228225 /*
229226 * CPUs seeing atomic_add_return() must see prior RCU read-side
230227 * critical sections, and we also must force ordering with the
231228 * next idle sojourn.
232229 */
233- seq = atomic_add_return (RCU_DYNTICK_CTRL_CTR , & rdtp -> dynticks );
230+ seq = atomic_add_return (RCU_DYNTICK_CTRL_CTR , & rdp -> dynticks );
234231 /* Better be in an extended quiescent state! */
235232 WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) &&
236233 (seq & RCU_DYNTICK_CTRL_CTR ));
@@ -245,19 +242,19 @@ static void rcu_dynticks_eqs_enter(void)
245242 */
246243static void rcu_dynticks_eqs_exit (void )
247244{
248- struct rcu_dynticks * rdtp = this_cpu_ptr (& rcu_dynticks );
245+ struct rcu_data * rdp = this_cpu_ptr (& rcu_data );
249246 int seq ;
250247
251248 /*
252249 * CPUs seeing atomic_add_return() must see prior idle sojourns,
253250 * and we also must force ordering with the next RCU read-side
254251 * critical section.
255252 */
256- seq = atomic_add_return (RCU_DYNTICK_CTRL_CTR , & rdtp -> dynticks );
253+ seq = atomic_add_return (RCU_DYNTICK_CTRL_CTR , & rdp -> dynticks );
257254 WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) &&
258255 !(seq & RCU_DYNTICK_CTRL_CTR ));
259256 if (seq & RCU_DYNTICK_CTRL_MASK ) {
260- atomic_andnot (RCU_DYNTICK_CTRL_MASK , & rdtp -> dynticks );
257+ atomic_andnot (RCU_DYNTICK_CTRL_MASK , & rdp -> dynticks );
261258 smp_mb__after_atomic (); /* _exit after clearing mask. */
262259 /* Prefer duplicate flushes to losing a flush. */
263260 rcu_eqs_special_exit ();
@@ -276,11 +273,11 @@ static void rcu_dynticks_eqs_exit(void)
276273 */
277274static void rcu_dynticks_eqs_online (void )
278275{
279- struct rcu_dynticks * rdtp = this_cpu_ptr (& rcu_dynticks );
276+ struct rcu_data * rdp = this_cpu_ptr (& rcu_data );
280277
281- if (atomic_read (& rdtp -> dynticks ) & RCU_DYNTICK_CTRL_CTR )
278+ if (atomic_read (& rdp -> dynticks ) & RCU_DYNTICK_CTRL_CTR )
282279 return ;
283- atomic_add (RCU_DYNTICK_CTRL_CTR , & rdtp -> dynticks );
280+ atomic_add (RCU_DYNTICK_CTRL_CTR , & rdp -> dynticks );
284281}
285282
286283/*
@@ -290,18 +287,18 @@ static void rcu_dynticks_eqs_online(void)
290287 */
291288bool rcu_dynticks_curr_cpu_in_eqs (void )
292289{
293- struct rcu_dynticks * rdtp = this_cpu_ptr (& rcu_dynticks );
290+ struct rcu_data * rdp = this_cpu_ptr (& rcu_data );
294291
295- return !(atomic_read (& rdtp -> dynticks ) & RCU_DYNTICK_CTRL_CTR );
292+ return !(atomic_read (& rdp -> dynticks ) & RCU_DYNTICK_CTRL_CTR );
296293}
297294
298295/*
299296 * Snapshot the ->dynticks counter with full ordering so as to allow
300297 * stable comparison of this counter with past and future snapshots.
301298 */
302- int rcu_dynticks_snap (struct rcu_dynticks * rdtp )
299+ int rcu_dynticks_snap (struct rcu_data * rdp )
303300{
304- int snap = atomic_add_return (0 , & rdtp -> dynticks );
301+ int snap = atomic_add_return (0 , & rdp -> dynticks );
305302
306303 return snap & ~RCU_DYNTICK_CTRL_MASK ;
307304}
@@ -316,13 +313,13 @@ static bool rcu_dynticks_in_eqs(int snap)
316313}
317314
318315/*
319- * Return true if the CPU corresponding to the specified rcu_dynticks
316+ * Return true if the CPU corresponding to the specified rcu_data
320317 * structure has spent some time in an extended quiescent state since
321318 * rcu_dynticks_snap() returned the specified snapshot.
322319 */
323- static bool rcu_dynticks_in_eqs_since (struct rcu_dynticks * rdtp , int snap )
320+ static bool rcu_dynticks_in_eqs_since (struct rcu_data * rdp , int snap )
324321{
325- return snap != rcu_dynticks_snap (rdtp );
322+ return snap != rcu_dynticks_snap (rdp );
326323}
327324
328325/*
@@ -336,14 +333,14 @@ bool rcu_eqs_special_set(int cpu)
336333{
337334 int old ;
338335 int new ;
339- struct rcu_dynticks * rdtp = & per_cpu (rcu_dynticks , cpu );
336+ struct rcu_data * rdp = & per_cpu (rcu_data , cpu );
340337
341338 do {
342- old = atomic_read (& rdtp -> dynticks );
339+ old = atomic_read (& rdp -> dynticks );
343340 if (old & RCU_DYNTICK_CTRL_CTR )
344341 return false;
345342 new = old | RCU_DYNTICK_CTRL_MASK ;
346- } while (atomic_cmpxchg (& rdtp -> dynticks , old , new ) != old );
343+ } while (atomic_cmpxchg (& rdp -> dynticks , old , new ) != old );
347344 return true;
348345}
349346
@@ -360,11 +357,11 @@ bool rcu_eqs_special_set(int cpu)
360357 */
361358static void __maybe_unused rcu_momentary_dyntick_idle (void )
362359{
363- struct rcu_dynticks * rdtp = this_cpu_ptr (& rcu_dynticks );
364360 int special ;
365361
366362 raw_cpu_write (rcu_data .rcu_need_heavy_qs , false);
367- special = atomic_add_return (2 * RCU_DYNTICK_CTRL_CTR , & rdtp -> dynticks );
363+ special = atomic_add_return (2 * RCU_DYNTICK_CTRL_CTR ,
364+ & this_cpu_ptr (& rcu_data )-> dynticks );
368365 /* It is illegal to call this from idle state. */
369366 WARN_ON_ONCE (!(special & RCU_DYNTICK_CTRL_CTR ));
370367 rcu_preempt_deferred_qs (current );
@@ -573,9 +570,7 @@ static struct rcu_node *rcu_get_root(void)
573570static void rcu_eqs_enter (bool user )
574571{
575572 struct rcu_data * rdp = this_cpu_ptr (& rcu_data );
576- struct rcu_dynticks * rdtp ;
577573
578- rdtp = this_cpu_ptr (& rcu_dynticks );
579574 WARN_ON_ONCE (rdp -> dynticks_nmi_nesting != DYNTICK_IRQ_NONIDLE );
580575 WRITE_ONCE (rdp -> dynticks_nmi_nesting , 0 );
581576 WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) &&
@@ -586,7 +581,7 @@ static void rcu_eqs_enter(bool user)
586581 }
587582
588583 lockdep_assert_irqs_disabled ();
589- trace_rcu_dyntick (TPS ("Start" ), rdp -> dynticks_nesting , 0 , rdtp -> dynticks );
584+ trace_rcu_dyntick (TPS ("Start" ), rdp -> dynticks_nesting , 0 , rdp -> dynticks );
590585 WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) && !user && !is_idle_task (current ));
591586 rdp = this_cpu_ptr (& rcu_data );
592587 do_nocb_deferred_wakeup (rdp );
@@ -635,7 +630,7 @@ void rcu_user_enter(void)
635630
636631/*
637632 * If we are returning from the outermost NMI handler that interrupted an
638- * RCU-idle period, update rdtp ->dynticks and rdp->dynticks_nmi_nesting
633+ * RCU-idle period, update rdp ->dynticks and rdp->dynticks_nmi_nesting
639634 * to let the RCU grace-period handling know that the CPU is back to
640635 * being RCU-idle.
641636 *
@@ -645,7 +640,6 @@ void rcu_user_enter(void)
645640static __always_inline void rcu_nmi_exit_common (bool irq )
646641{
647642 struct rcu_data * rdp = this_cpu_ptr (& rcu_data );
648- struct rcu_dynticks __maybe_unused * rdtp = this_cpu_ptr (& rcu_dynticks );
649643
650644 /*
651645 * Check for ->dynticks_nmi_nesting underflow and bad ->dynticks.
@@ -660,14 +654,14 @@ static __always_inline void rcu_nmi_exit_common(bool irq)
660654 * leave it in non-RCU-idle state.
661655 */
662656 if (rdp -> dynticks_nmi_nesting != 1 ) {
663- trace_rcu_dyntick (TPS ("--=" ), rdp -> dynticks_nmi_nesting , rdp -> dynticks_nmi_nesting - 2 , rdtp -> dynticks );
657+ trace_rcu_dyntick (TPS ("--=" ), rdp -> dynticks_nmi_nesting , rdp -> dynticks_nmi_nesting - 2 , rdp -> dynticks );
664658 WRITE_ONCE (rdp -> dynticks_nmi_nesting , /* No store tearing. */
665659 rdp -> dynticks_nmi_nesting - 2 );
666660 return ;
667661 }
668662
669663 /* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */
670- trace_rcu_dyntick (TPS ("Startirq" ), rdp -> dynticks_nmi_nesting , 0 , rdtp -> dynticks );
664+ trace_rcu_dyntick (TPS ("Startirq" ), rdp -> dynticks_nmi_nesting , 0 , rdp -> dynticks );
671665 WRITE_ONCE (rdp -> dynticks_nmi_nesting , 0 ); /* Avoid store tearing. */
672666
673667 if (irq )
@@ -742,11 +736,9 @@ void rcu_irq_exit_irqson(void)
742736static void rcu_eqs_exit (bool user )
743737{
744738 struct rcu_data * rdp ;
745- struct rcu_dynticks * rdtp ;
746739 long oldval ;
747740
748741 lockdep_assert_irqs_disabled ();
749- rdtp = this_cpu_ptr (& rcu_dynticks );
750742 rdp = this_cpu_ptr (& rcu_data );
751743 oldval = rdp -> dynticks_nesting ;
752744 WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) && oldval < 0 );
@@ -757,7 +749,7 @@ static void rcu_eqs_exit(bool user)
757749 rcu_dynticks_task_exit ();
758750 rcu_dynticks_eqs_exit ();
759751 rcu_cleanup_after_idle ();
760- trace_rcu_dyntick (TPS ("End" ), rdp -> dynticks_nesting , 1 , rdtp -> dynticks );
752+ trace_rcu_dyntick (TPS ("End" ), rdp -> dynticks_nesting , 1 , rdp -> dynticks );
761753 WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) && !user && !is_idle_task (current ));
762754 WRITE_ONCE (rdp -> dynticks_nesting , 1 );
763755 WARN_ON_ONCE (rdp -> dynticks_nmi_nesting );
@@ -802,7 +794,7 @@ void rcu_user_exit(void)
802794 * rcu_nmi_enter_common - inform RCU of entry to NMI context
803795 * @irq: Is this call from rcu_irq_enter?
804796 *
805- * If the CPU was idle from RCU's viewpoint, update rdtp ->dynticks and
797+ * If the CPU was idle from RCU's viewpoint, update rdp ->dynticks and
806798 * rdp->dynticks_nmi_nesting to let the RCU grace-period handling know
807799 * that the CPU is active. This implementation permits nested NMIs, as
808800 * long as the nesting level does not overflow an int. (You will probably
@@ -814,7 +806,6 @@ void rcu_user_exit(void)
814806static __always_inline void rcu_nmi_enter_common (bool irq )
815807{
816808 struct rcu_data * rdp = this_cpu_ptr (& rcu_data );
817- struct rcu_dynticks __maybe_unused * rdtp = this_cpu_ptr (& rcu_dynticks );
818809 long incby = 2 ;
819810
820811 /* Complain about underflow. */
@@ -842,7 +833,7 @@ static __always_inline void rcu_nmi_enter_common(bool irq)
842833 }
843834 trace_rcu_dyntick (incby == 1 ? TPS ("Endirq" ) : TPS ("++=" ),
844835 rdp -> dynticks_nmi_nesting ,
845- rdp -> dynticks_nmi_nesting + incby , rdtp -> dynticks );
836+ rdp -> dynticks_nmi_nesting + incby , rdp -> dynticks );
846837 WRITE_ONCE (rdp -> dynticks_nmi_nesting , /* Prevent store tearing. */
847838 rdp -> dynticks_nmi_nesting + incby );
848839 barrier ();
@@ -995,7 +986,7 @@ static void rcu_gpnum_ovf(struct rcu_node *rnp, struct rcu_data *rdp)
995986 */
996987static int dyntick_save_progress_counter (struct rcu_data * rdp )
997988{
998- rdp -> dynticks_snap = rcu_dynticks_snap (rdp -> dynticks );
989+ rdp -> dynticks_snap = rcu_dynticks_snap (rdp );
999990 if (rcu_dynticks_in_eqs (rdp -> dynticks_snap )) {
1000991 trace_rcu_fqs (rcu_state .name , rdp -> gp_seq , rdp -> cpu , TPS ("dti" ));
1001992 rcu_gpnum_ovf (rdp -> mynode , rdp );
@@ -1046,7 +1037,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
10461037 * read-side critical section that started before the beginning
10471038 * of the current RCU grace period.
10481039 */
1049- if (rcu_dynticks_in_eqs_since (rdp -> dynticks , rdp -> dynticks_snap )) {
1040+ if (rcu_dynticks_in_eqs_since (rdp , rdp -> dynticks_snap )) {
10501041 trace_rcu_fqs (rcu_state .name , rdp -> gp_seq , rdp -> cpu , TPS ("dti" ));
10511042 rdp -> dynticks_fqs ++ ;
10521043 rcu_gpnum_ovf (rnp , rdp );
@@ -3198,9 +3189,8 @@ rcu_boot_init_percpu_data(int cpu)
31983189
31993190 /* Set up local state, ensuring consistent view of global state. */
32003191 rdp -> grpmask = leaf_node_cpu_bit (rdp -> mynode , cpu );
3201- rdp -> dynticks = & per_cpu (rcu_dynticks , cpu );
32023192 WARN_ON_ONCE (rdp -> dynticks_nesting != 1 );
3203- WARN_ON_ONCE (rcu_dynticks_in_eqs (rcu_dynticks_snap (rdp -> dynticks )));
3193+ WARN_ON_ONCE (rcu_dynticks_in_eqs (rcu_dynticks_snap (rdp )));
32043194 rdp -> rcu_ofl_gp_seq = rcu_state .gp_seq ;
32053195 rdp -> rcu_ofl_gp_flags = RCU_GP_CLEANED ;
32063196 rdp -> rcu_onl_gp_seq = rcu_state .gp_seq ;
0 commit comments