<div dir="ltr">Hello,<div><br></div><div>I don't have full knowledge of how to work rte_mempool_ops_get_count() but there is another comment about it. Maybe it relates. </div><div>/*<br> * due to race condition (access to len is not locked), the<br> * total can be greater than size... so fix the result<br> */<br></div><div><br></div><div>Best regards.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Morten Brørup <<a href="mailto:mb@smartsharesystems.com">mb@smartsharesystems.com</a>>, 16 May 2023 Sal, 19:04 tarihinde şunu yazdı:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> From: Stephen Hemminger [mailto:<a href="mailto:stephen@networkplumber.org" target="_blank">stephen@networkplumber.org</a>]<br>
> Sent: Tuesday, 16 May 2023 17.24<br>
> <br>
> On Tue, 16 May 2023 13:41:46 +0000<br>
> Yasin CANER <<a href="mailto:yasinncaner@gmail.com" target="_blank">yasinncaner@gmail.com</a>> wrote:<br>
> <br>
> > From: Yasin CANER <<a href="mailto:yasin.caner@ulakhaberlesme.com.tr" target="_blank">yasin.caner@ulakhaberlesme.com.tr</a>><br>
> ><br>
> > after a while working rte_mempool_avail_count function returns bigger<br>
> > than mempool size that cause miscalculation rte_mempool_in_use_count.<br>
> ><br>
> > it helps to avoid miscalculation rte_mempool_in_use_count.<br>
> ><br>
> > Bugzilla ID: 1229<br>
> ><br>
> > Signed-off-by: Yasin CANER <<a href="mailto:yasin.caner@ulakhaberlesme.com.tr" target="_blank">yasin.caner@ulakhaberlesme.com.tr</a>><br>
> <br>
> An alternative that avoids some code duplication.<br>
> <br>
> diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c<br>
> index cf5dea2304a7..2406b112e7b0 100644<br>
> --- a/lib/mempool/rte_mempool.c<br>
> +++ b/lib/mempool/rte_mempool.c<br>
> @@ -1010,7 +1010,7 @@ rte_mempool_avail_count(const struct rte_mempool<br>
> *mp)<br>
> count = rte_mempool_ops_get_count(mp);<br>
> <br>
> if (mp->cache_size == 0)<br>
> - return count;<br>
> + goto exit;<br>
<br>
This bug can only occur here (i.e. with cache_size==0) if rte_mempool_ops_get_count() returns an incorrect value. The bug should be fixed there instead.<br>
<br>
> <br>
> for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)<br>
> count += mp->local_cache[lcore_id].len;<br>
> @@ -1019,6 +1019,7 @@ rte_mempool_avail_count(const struct rte_mempool<br>
> *mp)<br>
> * due to race condition (access to len is not locked), the<br>
> * total can be greater than size... so fix the result<br>
> */<br>
> +exit:<br>
> if (count > mp->size)<br>
> return mp->size;<br>
> return count;<br>
</blockquote></div>