[RFC 2/2] srcu: Remove memory barrier "E" as it is not required

From: Joel Fernandes (Google)
Date: Sun Dec 18 2022 - 14:14:40 EST


During a flip, we have a full memory barrier before idx is incremented.

The effect of this seems to be to guarantee that, if a READER sees srcu_idx
updates (srcu_flip), then prior scans would not see its updates to counters on
that index.

That does not matter because of the following reason: If a prior scan did see
counter updates on the new index, that means the prior scan would would wait
for the reader when it probably did not need to.

And if the prior scan did see both lock and unlock count updates on that index,
that reader is essentially done, so it is OK to end the grace period.

For this reason, remove the full memory barrier before incrementing
srcu_idx.

6 hours of testing shows all SRCU-* scenarios pass with this.

Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
---
kernel/rcu/srcutree.c | 8 --------
1 file changed, 8 deletions(-)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index d6a4c2439ca6..2d2e6d304a43 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -982,14 +982,6 @@ static bool try_check_zero(struct srcu_struct *ssp, int idx, int trycount)
*/
static void srcu_flip(struct srcu_struct *ssp)
{
- /*
- * Ensure that if a given reader sees the new value of ->srcu_idx, this
- * updater's earlier scans cannot have seen that reader's increments
- * (which is OK, because this grace period need not wait on that
- * reader).
- */
- smp_mb(); /* E */ /* Pairs with B and C. */
-
WRITE_ONCE(ssp->srcu_idx, ssp->srcu_idx + 1);

/*
--
2.39.0.314.g84b9a713c41-goog