DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] lib/mempool : rte_mempool_avail_count, fixing return bigger than mempool size
@ 2023-05-16 13:41 Yasin CANER
  2023-05-16 15:23 ` Stephen Hemminger
  0 siblings, 1 reply; 12+ messages in thread
From: Yasin CANER @ 2023-05-16 13:41 UTC (permalink / raw)
  To: dev; +Cc: Yasin CANER, Olivier Matz, Andrew Rybchenko

From: Yasin CANER <yasin.caner@ulakhaberlesme.com.tr>

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 <yasin.caner@ulakhaberlesme.com.tr>
---
 lib/mempool/rte_mempool.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index cf5dea2304..17ed1eb845 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -1009,8 +1009,11 @@ rte_mempool_avail_count(const struct rte_mempool *mp)
 
 	count = rte_mempool_ops_get_count(mp);
 
-	if (mp->cache_size == 0)
+	if (mp->cache_size == 0) {
+		if (count > mp->size)
+			return mp->size;
 		return count;
+	}
 
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
 		count += mp->local_cache[lcore_id].len;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-05-18 15:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 13:41 [PATCH] lib/mempool : rte_mempool_avail_count, fixing return bigger than mempool size Yasin CANER
2023-05-16 15:23 ` Stephen Hemminger
2023-05-16 16:03   ` Morten Brørup
2023-05-17  8:01     ` Yasin CANER
2023-05-17  8:38       ` Morten Brørup
2023-05-17  9:04         ` Morten Brørup
2023-05-17 11:37           ` Yasin CANER
2023-05-17 11:53           ` David Marchand
2023-05-17 12:23             ` Morten Brørup
2023-05-18  8:37               ` Yasin CANER
2023-05-18  8:53                 ` Morten Brørup
2023-05-18 15:40     ` Mattias Rönnblom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).