* [dpdk-dev] mbuf pool and ring size...
@ 2015-09-22 5:10 Vithal Mohare
2015-09-22 9:07 ` Olivier MATZ
0 siblings, 1 reply; 2+ messages in thread
From: Vithal Mohare @ 2015-09-22 5:10 UTC (permalink / raw)
To: dev
Hi,
While creating mbuf pool, suppose if mbuf-pool size passed to DPDK API is already pow-of-2 [ rte_mempool_create()-->rte_mempool_xmem_create()]. Then, noticed that, corresponding size of the ring created for this pool will be double the size of mbuf-pool. This is because of below code snippet:
rte_mempool_xmem_create(...) {
....
r = rte_ring_create(rg_name, rte_align32pow2(n+1), socket_id, rg_flags); <<<<<<<< Notice that its 'n+1' here, rte_align32pow2(n+1)
....
}
Question: why is this 'n+1'? Shouldn't this be just 'n'?
Thanks,
-Vithal
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] mbuf pool and ring size...
2015-09-22 5:10 [dpdk-dev] mbuf pool and ring size Vithal Mohare
@ 2015-09-22 9:07 ` Olivier MATZ
0 siblings, 0 replies; 2+ messages in thread
From: Olivier MATZ @ 2015-09-22 9:07 UTC (permalink / raw)
To: Vithal Mohare, dev
Hi Vithal,
On 09/22/2015 07:10 AM, Vithal Mohare wrote:
> Hi,
>
> While creating mbuf pool, suppose if mbuf-pool size passed to DPDK API is already pow-of-2 [ rte_mempool_create()-->rte_mempool_xmem_create()]. Then, noticed that, corresponding size of the ring created for this pool will be double the size of mbuf-pool. This is because of below code snippet:
> rte_mempool_xmem_create(...) {
> ....
> r = rte_ring_create(rg_name, rte_align32pow2(n+1), socket_id, rg_flags); <<<<<<<< Notice that its 'n+1' here, rte_align32pow2(n+1)
> ....
> }
> Question: why is this 'n+1'? Shouldn't this be just 'n'?
>From rte_ring_init() documentation:
The ring size is set to *count*, which must be a power of two.
The real usable ring size is *count-1* instead of *count* to
differentiate a free ring from an empty ring.
Therefore, if the user asks for a mempool with 2048 elements,
the ring size has to be 4096.
>From mempool documentation:
The optimum size (in terms of memory usage) for a mempool is
when n is a power of two minus 1: n = (2^q - 1).
Regards,
Olivier
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-22 9:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22 5:10 [dpdk-dev] mbuf pool and ring size Vithal Mohare
2015-09-22 9:07 ` Olivier MATZ
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).