Skip to content

Commit

Permalink
kni: allocate no more mbuf than empty slots in queue
Browse files Browse the repository at this point in the history
In kni_allocate_mbufs(), we attempt to add max_burst (32) count of mbuf
always into alloc_q, which is excessively leading too many rte_pktmbuf_
free() when alloc_q is contending at high packet rate (for eg 10Gig data).
In a situation when alloc_q fifo can only accommodate very few (or zero)
mbuf, create only what needed and add in fifo.

With this patch, we could stop random network stall in KNI at higher packet
rate (eg 1G or 10G data between vEth0 and PMD) sufficiently exhausting
alloc_q on above condition. I tested i40e PMD for this purpose in ppc64le.

Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
gowrishankarm authored and tmonjalo committed Jul 1, 2017
1 parent 814baff commit 49da4e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/librte_kni/rte_kni.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ kni_allocate_mbufs(struct rte_kni *kni)
int i, ret;
struct rte_mbuf *pkts[MAX_MBUF_BURST_NUM];
void *phys[MAX_MBUF_BURST_NUM];
int allocq_free;

RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pool) !=
offsetof(struct rte_kni_mbuf, pool));
Expand All @@ -646,7 +647,9 @@ kni_allocate_mbufs(struct rte_kni *kni)
return;
}

for (i = 0; i < MAX_MBUF_BURST_NUM; i++) {
allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) \
& (MAX_MBUF_BURST_NUM - 1);
for (i = 0; i < allocq_free; i++) {
pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool);
if (unlikely(pkts[i] == NULL)) {
/* Out of memory */
Expand Down

0 comments on commit 49da4e8

Please sign in to comment.