X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_rcu%2Frte_rcu_qsbr.c;h=2f3fad776ee727e2ea9a45c1d8bc8546d68b0487;hb=a9f31a90bbf978fa57a876d670a53a5910c964ab;hp=de25464647960a784e9be8226e0be57e4d3d9a40;hpb=b9444280003a0cc758b63e9797ffc822a9ae2548;p=dpdk.git diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c index de25464647..2f3fad776e 100644 --- a/lib/librte_rcu/rte_rcu_qsbr.c +++ b/lib/librte_rcu/rte_rcu_qsbr.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -23,7 +22,7 @@ #include "rte_rcu_qsbr.h" /* Get the memory size of QSBR variable */ -size_t __rte_experimental +size_t rte_rcu_qsbr_get_memsize(uint32_t max_threads) { size_t sz; @@ -49,7 +48,7 @@ rte_rcu_qsbr_get_memsize(uint32_t max_threads) } /* Initialize a quiescent state variable */ -int __rte_experimental +int rte_rcu_qsbr_init(struct rte_rcu_qsbr *v, uint32_t max_threads) { size_t sz; @@ -73,6 +72,7 @@ rte_rcu_qsbr_init(struct rte_rcu_qsbr *v, uint32_t max_threads) __RTE_QSBR_THRID_ARRAY_ELM_SIZE) / __RTE_QSBR_THRID_ARRAY_ELM_SIZE; v->token = __RTE_QSBR_CNT_INIT; + v->acked_token = __RTE_QSBR_CNT_INIT - 1; return 0; } @@ -80,7 +80,7 @@ rte_rcu_qsbr_init(struct rte_rcu_qsbr *v, uint32_t max_threads) /* Register a reader thread to report its quiescent state * on a QS variable. */ -int __rte_experimental +int rte_rcu_qsbr_thread_register(struct rte_rcu_qsbr *v, unsigned int thread_id) { unsigned int i, id, success; @@ -132,7 +132,7 @@ rte_rcu_qsbr_thread_register(struct rte_rcu_qsbr *v, unsigned int thread_id) /* Remove a reader thread, from the list of threads reporting their * quiescent state on a QS variable. */ -int __rte_experimental +int rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id) { unsigned int i, id, success; @@ -158,7 +158,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id) /* Check if the thread is already unregistered */ old_bmap = __atomic_load_n(__RTE_QSBR_THRID_ARRAY_ELM(v, i), __ATOMIC_RELAXED); - if (old_bmap & ~(1UL << id)) + if (!(old_bmap & (1UL << id))) return 0; do { @@ -175,7 +175,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id) if (success) __atomic_fetch_sub(&v->num_threads, 1, __ATOMIC_RELAXED); - else if (old_bmap & ~(1UL << id)) + else if (!(old_bmap & (1UL << id))) /* Someone else unregistered this thread. * Counter should not be incremented. */ @@ -186,7 +186,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id) } /* Wait till the reader threads have entered quiescent state. */ -void __rte_experimental +void rte_rcu_qsbr_synchronize(struct rte_rcu_qsbr *v, unsigned int thread_id) { uint64_t t; @@ -206,7 +206,7 @@ rte_rcu_qsbr_synchronize(struct rte_rcu_qsbr *v, unsigned int thread_id) } /* Dump the details of a single quiescent state variable to a file. */ -int __rte_experimental +int rte_rcu_qsbr_dump(FILE *f, struct rte_rcu_qsbr *v) { uint64_t bmap; @@ -245,6 +245,9 @@ rte_rcu_qsbr_dump(FILE *f, struct rte_rcu_qsbr *v) fprintf(f, " Token = %"PRIu64"\n", __atomic_load_n(&v->token, __ATOMIC_ACQUIRE)); + fprintf(f, " Least Acknowledged Token = %"PRIu64"\n", + __atomic_load_n(&v->acked_token, __ATOMIC_ACQUIRE)); + fprintf(f, "Quiescent State Counts for readers:\n"); for (i = 0; i < v->num_elems; i++) { bmap = __atomic_load_n(__RTE_QSBR_THRID_ARRAY_ELM(v, i),