Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rcu: Rename rcu_dynticks_in_eqs_since() into rcu_watching_snap_stopped_since()

The context_tracking.state RCU_DYNTICKS subvariable has been renamed to
RCU_WATCHING, the dynticks prefix can go.

While at it, this helper is only meant to be called after failing an
earlier call to rcu_watching_snap_in_eqs(), document this in the comments
and add a WARN_ON_ONCE() for good measure.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Neeraj Upadhyay <neeraj.upadhyay@kernel.org>

authored by

Valentin Schneider and committed by
Neeraj Upadhyay
3116a32e 9629936d

+19 -8
+1 -1
Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst
··· 150 150 is invoked within ``rcu_dynticks_eqs_enter()`` at idle-entry 151 151 time and within ``rcu_dynticks_eqs_exit()`` at idle-exit time. 152 152 The grace-period kthread invokes first ``ct_rcu_watching_cpu_acquire()`` 153 - (preceded by a full memory barrier) and ``rcu_dynticks_in_eqs_since()`` 153 + (preceded by a full memory barrier) and ``rcu_watching_snap_stopped_since()`` 154 154 (both of which rely on acquire semantics) to detect idle CPUs. 155 155 156 156 +-----------------------------------------------------------------------+
+17 -6
kernel/rcu/tree.c
··· 308 308 return !(snap & CT_RCU_WATCHING); 309 309 } 310 310 311 - /* 312 - * Return true if the CPU corresponding to the specified rcu_data 313 - * structure has spent some time in an extended quiescent state since 314 - * rcu_dynticks_snap() returned the specified snapshot. 311 + /** 312 + * rcu_watching_snap_stopped_since() - Has RCU stopped watching a given CPU 313 + * since the specified @snap? 314 + * 315 + * @rdp: The rcu_data corresponding to the CPU for which to check EQS. 316 + * @snap: rcu_watching snapshot taken when the CPU wasn't in an EQS. 317 + * 318 + * Returns true if the CPU corresponding to @rdp has spent some time in an 319 + * extended quiescent state since @snap. Note that this doesn't check if it 320 + * /still/ is in an EQS, just that it went through one since @snap. 321 + * 322 + * This is meant to be used in a loop waiting for a CPU to go through an EQS. 315 323 */ 316 - static bool rcu_dynticks_in_eqs_since(struct rcu_data *rdp, int snap) 324 + static bool rcu_watching_snap_stopped_since(struct rcu_data *rdp, int snap) 317 325 { 318 326 /* 319 327 * The first failing snapshot is already ordered against the accesses ··· 331 323 * performed by the remote CPU prior to entering idle and therefore can 332 324 * rely solely on acquire semantics. 333 325 */ 326 + if (WARN_ON_ONCE(rcu_watching_snap_in_eqs(snap))) 327 + return true; 328 + 334 329 return snap != ct_rcu_watching_cpu_acquire(rdp->cpu); 335 330 } 336 331 ··· 826 815 * read-side critical section that started before the beginning 827 816 * of the current RCU grace period. 828 817 */ 829 - if (rcu_dynticks_in_eqs_since(rdp, rdp->dynticks_snap)) { 818 + if (rcu_watching_snap_stopped_since(rdp, rdp->dynticks_snap)) { 830 819 trace_rcu_fqs(rcu_state.name, rdp->gp_seq, rdp->cpu, TPS("dti")); 831 820 rcu_gpnum_ovf(rnp, rdp); 832 821 return 1;
+1 -1
kernel/rcu/tree_exp.h
··· 400 400 unsigned long mask = rdp->grpmask; 401 401 402 402 retry_ipi: 403 - if (rcu_dynticks_in_eqs_since(rdp, rdp->exp_dynticks_snap)) { 403 + if (rcu_watching_snap_stopped_since(rdp, rdp->exp_dynticks_snap)) { 404 404 mask_ofl_test |= mask; 405 405 continue; 406 406 }