[PATCH v2 18/27] rcu: Rename rcu_dynticks_in_eqs_since() into rcu_watching_changed_since()

From: Valentin Schneider
Date: Tue Apr 30 2024 - 05:23:34 EST


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

Furthermore, the "in_eqs_since" part confuses me, as IIUC this only checks
for a change in watching/eqs state, not that RCU transitionned *into* a
EQS after the snapshot was taken.

e.g. if
snap = 0b1000 (EQS)
and the following rcu_watching_snap(CPU) is:
0b1100 (watching)
then
rcu_watching_in_eqs_since(rdp, snap) -> true

but because RCU was already in EQS at the time of the
snap - it hasn't entered EQS "since" the snap was taken.

Update the name to reflect that we're only looking at watching/EQS
transitions, not specifically transitions into EQS.

Signed-off-by: Valentin Schneider <vschneid@xxxxxxxxxx>
---
.../RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst | 2 +-
kernel/rcu/tree.c | 4 ++--
kernel/rcu/tree_exp.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst b/Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst
index e8ef12ca1e9da..0533814a1f69a 100644
--- a/Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst
+++ b/Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst
@@ -150,7 +150,7 @@ This case is handled by calls to the strongly ordered
is invoked within ``rcu_dynticks_eqs_enter()`` at idle-entry
time and within ``rcu_dynticks_eqs_exit()`` at idle-exit time.
The grace-period kthread invokes ``rcu_watching_snap()`` and
-``rcu_dynticks_in_eqs_since()`` (both of which invoke
+``rcu_watching_changed_since()`` (both of which invoke
an ``atomic_add_return()`` of zero) to detect idle CPUs.

+-----------------------------------------------------------------------+
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index d772755ccd564..ffcde8203c04f 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -320,7 +320,7 @@ static bool rcu_watching_in_eqs(int snap)
* structure has spent some time in an extended quiescent state since
* rcu_watching_snap() returned the specified snapshot.
*/
-static bool rcu_dynticks_in_eqs_since(struct rcu_data *rdp, int snap)
+static bool rcu_watching_changed_since(struct rcu_data *rdp, int snap)
{
return snap != rcu_watching_snap(rdp->cpu);
}
@@ -803,7 +803,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
* read-side critical section that started before the beginning
* of the current RCU grace period.
*/
- if (rcu_dynticks_in_eqs_since(rdp, rdp->dynticks_snap)) {
+ if (rcu_watching_changed_since(rdp, rdp->dynticks_snap)) {
trace_rcu_fqs(rcu_state.name, rdp->gp_seq, rdp->cpu, TPS("dti"));
rcu_gpnum_ovf(rnp, rdp);
return 1;
diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
index 68dea1427c8bd..4046fae99517e 100644
--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -381,7 +381,7 @@ static void __sync_rcu_exp_select_node_cpus(struct rcu_exp_work *rewp)
unsigned long mask = rdp->grpmask;

retry_ipi:
- if (rcu_dynticks_in_eqs_since(rdp, rdp->exp_dynticks_snap)) {
+ if (rcu_watching_changed_since(rdp, rdp->exp_dynticks_snap)) {
mask_ofl_test |= mask;
continue;
}
--
2.43.0