* Looks like rte_mempool_free_count() and rte_mempool_count() are swapped
@ 2013-09-12 7:52 Dmitry Vyal
[not found] ` <523172C3.2040309-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Vyal @ 2013-09-12 7:52 UTC (permalink / raw)
To: dev-VfR2kkLFssw
Greetings.
I had a suspect I run into a mbuf depletion issue and decided to check
using rte_mempool_free_count(). To my surprise, it returned a value
equal to mempool size. I tried calling rte_mempool_count() and it
returned zero.
I inspected the code in dpdk-1.3.1-7 and dpdk.1.4.1-4:
rte_mempool_count(const struct rte_mempool *mp)
{
unsigned count;
count = rte_ring_count(mp->ring);
#if RTE_MEMPOOL_CACHE_MAX_SIZE > 0
{
unsigned lcore_id;
if (mp->cache_size == 0)
return count;
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
count += mp->local_cache[lcore_id].len;
}
#endif
/*
* due to race condition (access to len is not locked), the
* total can be greater than size... so fix the result
*/
if (count > mp->size)
return mp->size;
return count;
}
If I understand it correctly, the ring contains free buffers and
rte_ring_count() returns a number of entries inside a ring. So this
function actually calculates the number of free entries, not busy.
Moreover, rte_mempool_count() is used in many places. For example it's
called in rte_mempool_free_count() and rte_mempool_full().
Can anyone confirm or refute my findings?
Regards,
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Looks like rte_mempool_free_count() and rte_mempool_count() are swapped
[not found] ` <523172C3.2040309-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-01-02 13:32 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2014-01-02 13:32 UTC (permalink / raw)
To: Dmitry Vyal; +Cc: dev-VfR2kkLFssw
12/09/2013 09:52, Dmitry Vyal :
> If I understand it correctly, the ring contains free buffers and
> rte_ring_count() returns a number of entries inside a ring. So this
> function actually calculates the number of free entries, not busy.
Yes, you're right. mempool's objects are free mbufs.
So mempool_count is the number of free mbufs,
and mempool_free_count is the number of free slots to store more free mbufs.
I agree that the naming is confusing but I'm not sure we should change it.
--
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-02 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-12 7:52 Looks like rte_mempool_free_count() and rte_mempool_count() are swapped Dmitry Vyal
[not found] ` <523172C3.2040309-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-02 13:32 ` Thomas Monjalon
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).