Skip to content

Commit 9a7e73c

Browse files
Frederic Weisbeckerpaulmckrcu
authored andcommitted
rcu: Remove superfluous full memory barrier upon first EQS snapshot
When the grace period kthread checks the extended quiescent state counter of a CPU, full ordering is necessary to ensure that either: * If the GP kthread observes the remote target in an extended quiescent state, then that target must observe all accesses prior to the current grace period, including the current grace period sequence number, once it exits that extended quiescent state. or: * If the GP kthread observes the remote target NOT in an extended quiescent state, then the target further entering in an extended quiescent state must observe all accesses prior to the current grace period, including the current grace period sequence number, once it enters that extended quiescent state. This ordering is enforced through a full memory barrier placed right before taking the first EQS snapshot. However this is superfluous because the snapshot is taken while holding the target's rnp lock which provides the necessary ordering through its chain of smp_mb__after_unlock_lock(). Remove the needless explicit barrier before the snapshot and put a comment about the implicit barrier newly relied upon here. Signed-off-by: Frederic Weisbecker <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Reviewed-by: Neeraj Upadhyay <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 0a5e9bd commit 9a7e73c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ This case is handled by calls to the strongly ordered
149149
``atomic_add_return()`` read-modify-write atomic operation that
150150
is invoked within ``rcu_dynticks_eqs_enter()`` at idle-entry
151151
time and within ``rcu_dynticks_eqs_exit()`` at idle-exit time.
152-
The grace-period kthread invokes ``rcu_dynticks_snap()`` and
153-
``rcu_dynticks_in_eqs_since()`` (both of which invoke
154-
an ``atomic_add_return()`` of zero) to detect idle CPUs.
152+
The grace-period kthread invokes first ``ct_dynticks_cpu_acquire()``
153+
(preceded by a full memory barrier) and ``rcu_dynticks_in_eqs_since()``
154+
(both of which rely on acquire semantics) to detect idle CPUs.
155155

156156
+-----------------------------------------------------------------------+
157157
| **Quick Quiz**: |

kernel/rcu/tree.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,18 @@ static void rcu_gpnum_ovf(struct rcu_node *rnp, struct rcu_data *rdp)
777777
*/
778778
static int dyntick_save_progress_counter(struct rcu_data *rdp)
779779
{
780-
rdp->dynticks_snap = rcu_dynticks_snap(rdp->cpu);
780+
/*
781+
* Full ordering between remote CPU's post idle accesses and updater's
782+
* accesses prior to current GP (and also the started GP sequence number)
783+
* is enforced by rcu_seq_start() implicit barrier and even further by
784+
* smp_mb__after_unlock_lock() barriers chained all the way throughout the
785+
* rnp locking tree since rcu_gp_init() and up to the current leaf rnp
786+
* locking.
787+
*
788+
* Ordering between remote CPU's pre idle accesses and post grace period
789+
* updater's accesses is enforced by the below acquire semantic.
790+
*/
791+
rdp->dynticks_snap = ct_dynticks_cpu_acquire(rdp->cpu);
781792
if (rcu_dynticks_in_eqs(rdp->dynticks_snap)) {
782793
trace_rcu_fqs(rcu_state.name, rdp->gp_seq, rdp->cpu, TPS("dti"));
783794
rcu_gpnum_ovf(rdp->mynode, rdp);

0 commit comments

Comments
 (0)