rcu: update QS only when there are updates from writer
authorHonnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Tue, 8 Oct 2019 21:12:20 +0000 (16:12 -0500)
committerDavid Marchand <david.marchand@redhat.com>
Mon, 21 Oct 2019 15:54:41 +0000 (17:54 +0200)
When the writer is checking the quiescent state status, it is not
deleting any entries in the data structure. This means, the readers
do not need to update their quiescent state during that period.
Readers update the quiescent state only when there are updates
available from the writer.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
lib/librte_rcu/rte_rcu_qsbr.h

index 3f445ba..0d46645 100644 (file)
@@ -456,12 +456,14 @@ rte_rcu_qsbr_quiescent(struct rte_rcu_qsbr *v, unsigned int thread_id)
         */
        t = __atomic_load_n(&v->token, __ATOMIC_ACQUIRE);
 
-       /* Inform the writer that updates are visible to this reader.
+       /* Check if there are updates available from the writer.
+        * Inform the writer that updates are visible to this reader.
         * Prior loads of the shared data structure should not move
         * beyond this store. Hence use store-release.
         */
-       __atomic_store_n(&v->qsbr_cnt[thread_id].cnt,
-                        t, __ATOMIC_RELEASE);
+       if (t != __atomic_load_n(&v->qsbr_cnt[thread_id].cnt, __ATOMIC_RELAXED))
+               __atomic_store_n(&v->qsbr_cnt[thread_id].cnt,
+                                        t, __ATOMIC_RELEASE);
 
        __RTE_RCU_DP_LOG(DEBUG, "%s: update: token = %"PRIu64", Thread ID = %d",
                __func__, t, thread_id);