[1/2] rcu: use atomic operation on acked token

Message ID 20240205045949.1085128-1-honnappa.nagarahalli@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [1/2] rcu: use atomic operation on acked token |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Honnappa Nagarahalli Feb. 5, 2024, 4:59 a.m. UTC
  acked_token should be read using atomic operation as the
the API rte_rcu_qsbr_check is advertised as multi-thread safe.

Fixes: 1f90d32ce175 ("rcu: add least acknowledged token optimization")
Cc: stable@dpdk.org

Reported-by: Ola Liljedahl <ola.liljedahl@arm.com>
Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>
---
 lib/rcu/rte_rcu_qsbr.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h
index 5979fb0efb..f6a3731308 100644
--- a/lib/rcu/rte_rcu_qsbr.h
+++ b/lib/rcu/rte_rcu_qsbr.h
@@ -667,7 +667,8 @@  rte_rcu_qsbr_check(struct rte_rcu_qsbr *v, uint64_t t, bool wait)
 	RTE_ASSERT(v != NULL);
 
 	/* Check if all the readers have already acknowledged this token */
-	if (likely(t <= v->acked_token)) {
+	if (likely(t <= rte_atomic_load_explicit(&v->acked_token,
+						rte_memory_order_relaxed))) {
 		__RTE_RCU_DP_LOG(DEBUG,
 			"%s: check: token = %" PRIu64 ", wait = %d",
 			__func__, t, wait);