On Tue, 16 May 2023 13:41:46 +0000 Yasin CANER <[email protected]> wrote:
> From: Yasin CANER <[email protected]> > > after a while working rte_mempool_avail_count function returns bigger > than mempool size that cause miscalculation rte_mempool_in_use_count. > > it helps to avoid miscalculation rte_mempool_in_use_count. > > Bugzilla ID: 1229 > > Signed-off-by: Yasin CANER <[email protected]> An alternative that avoids some code duplication. diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index cf5dea2304a7..2406b112e7b0 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -1010,7 +1010,7 @@ rte_mempool_avail_count(const struct rte_mempool *mp) count = rte_mempool_ops_get_count(mp); if (mp->cache_size == 0) - return count; + goto exit; for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) count += mp->local_cache[lcore_id].len; @@ -1019,6 +1019,7 @@ rte_mempool_avail_count(const struct rte_mempool *mp) * due to race condition (access to len is not locked), the * total can be greater than size... so fix the result */ +exit: if (count > mp->size) return mp->size; return count;

