[dpdk-dev,v2] mbuf: reduce pktmbuf init cycles

Message ID 20170627115751.4722-1-jerin.jacob@caviumnetworks.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Jerin Jacob June 27, 2017, 11:57 a.m. UTC
  There is no need for initializing the complete
packet buffer with zero as the packet data area will be
overwritten by the NIC Rx HW anyway.

The testpmd configures the packet mempool
with around 180k buffers with
2176B size. In existing scheme, the init routine
needs to memset around ~370MB vs the proposed scheme
requires only around ~22MB on 128B cache aligned system.

Useful in running DPDK in HW simulators/emulators,
where millions of cycles have an impact on boot time.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
v2:
- Removed RTE_PKTMBUF_HEADROOM from the memset area(Olivier)
---
 lib/librte_mbuf/rte_mbuf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Olivier Matz June 30, 2017, 12:27 p.m. UTC | #1
On Tue, 27 Jun 2017 17:27:51 +0530, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote:
> There is no need for initializing the complete
> packet buffer with zero as the packet data area will be
> overwritten by the NIC Rx HW anyway.
> 
> The testpmd configures the packet mempool
> with around 180k buffers with
> 2176B size. In existing scheme, the init routine
> needs to memset around ~370MB vs the proposed scheme
> requires only around ~22MB on 128B cache aligned system.
> 
> Useful in running DPDK in HW simulators/emulators,
> where millions of cycles have an impact on boot time.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>
  
Thomas Monjalon July 1, 2017, 10:15 a.m. UTC | #2
30/06/2017 14:27, Olivier Matz:
> On Tue, 27 Jun 2017 17:27:51 +0530, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote:
> > There is no need for initializing the complete
> > packet buffer with zero as the packet data area will be
> > overwritten by the NIC Rx HW anyway.
> > 
> > The testpmd configures the packet mempool
> > with around 180k buffers with
> > 2176B size. In existing scheme, the init routine
> > needs to memset around ~370MB vs the proposed scheme
> > requires only around ~22MB on 128B cache aligned system.
> > 
> > Useful in running DPDK in HW simulators/emulators,
> > where millions of cycles have an impact on boot time.
> > 
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 0e3e36a58..ab436b9da 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -131,8 +131,7 @@  rte_pktmbuf_init(struct rte_mempool *mp,
 	RTE_ASSERT(mp->elt_size >= mbuf_size);
 	RTE_ASSERT(buf_len <= UINT16_MAX);
 
-	memset(m, 0, mp->elt_size);
-
+	memset(m, 0, mbuf_size);
 	/* start of buffer is after mbuf structure and priv data */
 	m->priv_size = priv_size;
 	m->buf_addr = (char *)m + mbuf_size;