From: Hemant Agrawal Date: Wed, 23 Jul 2014 06:45:12 +0000 (+0530) Subject: kni: optimize Rx burst X-Git-Tag: spdx-start~9601 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3e12a98fe39786c3ecf0bc0fb2a439e9c17a0da4;p=dpdk.git kni: optimize Rx burst The current implementation of rte_kni_rx_burst polls the fifo for buffers. Irrespective of success or failure, it allocates the mbuf and try to put them into the alloc_q if the buffers are not added to alloc_q, it frees them. This waste lots of cpu cycles in allocating and freeing the buffers if alloc_q is full. The logic has been changed to: 1. Initially allocand add buffer(burstsize) to alloc_q 2. Add buffers to alloc_q only when you are pulling out the buffers. Signed-off-by: Hemant Agrawal Reviewed-by: Jay Rolette --- diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index fdb75094eb..4e70fa0872 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -450,6 +450,9 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, ctx->in_use = 1; + /* Allocate mbufs and then put them into alloc_q */ + kni_allocate_mbufs(ctx); + return ctx; kni_fail: @@ -570,8 +573,9 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num) { unsigned ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num); - /* Allocate mbufs and then put them into alloc_q */ - kni_allocate_mbufs(kni); + /* If buffers removed, allocate mbufs and then put them into alloc_q */ + if (ret) + kni_allocate_mbufs(kni); return ret; }