dpdk: fix mempool sizing to always yield 2^n -1

Following DPDK's recommendation to size mempool to 2^n - 1,
the current implementation was flawed for certain combos,
e.g. mp_size 1023 and 1 queue, which resulted to 1022.
pull/14908/head
Lukas Sismis 2 months ago committed by Victor Julien
parent 109742932a
commit ea853e92a3

@ -1454,8 +1454,11 @@ static int DeviceConfigureQueues(DPDKIfaceConfig *iconf, const struct rte_eth_de
// +4 for VLAN header
uint16_t mtu_size = iconf->mtu + RTE_ETHER_CRC_LEN + RTE_ETHER_HDR_LEN + 4;
uint16_t mbuf_size = ROUNDUP(mtu_size, 1024) + RTE_PKTMBUF_HEADROOM;
// ceil the div so e.g. mp_size of 262144 and 262143 both lead to 65535 on 4 rx queues
uint32_t q_mp_sz = (iconf->mempool_size + iconf->nb_rx_queues - 1) / iconf->nb_rx_queues - 1;
// Follows DPDK recommendation of having a mempool size that is a power of 2 minus one.
// So e.g. mp_size of 262144 and 262143 both lead to 65535 on 4 rx queues
uint32_t raw = iconf->mempool_size / iconf->nb_rx_queues;
uint32_t next_p2 = rte_align32pow2(raw + 1);
uint32_t q_mp_sz = (next_p2 == raw + 1) ? raw : (next_p2 >> 1) - 1;
uint32_t q_mp_cache_sz = iconf->mempool_cache_size_auto ? MempoolCacheSizeCalculate(q_mp_sz)
: iconf->mempool_cache_size;
SCLogInfo("%s: creating %u packet mempools of size %u, cache size %u, mbuf size %u",

Loading…
Cancel
Save