DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] kni: optimizing the rte_kni_rx_burst
@ 2014-07-23  6:45 Hemant Agrawal
  2014-11-11 22:58 ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Hemant Agrawal @ 2014-07-23  6:45 UTC (permalink / raw)
  To: dev

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 <Hemant@freescale.com>
---
 lib/librte_kni/rte_kni.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 76feef4..01e85f8 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -263,6 +263,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;
 
 fail:
@@ -369,8 +372,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;
 }
-- 
1.7.9.6

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-24  1:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23  6:45 [dpdk-dev] [PATCH] kni: optimizing the rte_kni_rx_burst Hemant Agrawal
2014-11-11 22:58 ` Thomas Monjalon
2014-11-26 21:20   ` Thomas Monjalon
2015-01-30  9:59     ` Thomas Monjalon
2015-02-24  1:29       ` 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).