From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DF4E47E27 for ; Mon, 6 Oct 2014 16:46:27 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 06 Oct 2014 07:53:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="396069734" Received: from bricha3-mobl.ger.corp.intel.com (HELO bricha3-mobl.ir.intel.com) ([10.243.20.23]) by FMSMGA003.fm.intel.com with SMTP; 06 Oct 2014 07:46:50 -0700 Received: by bricha3-mobl.ir.intel.com (sSMTP sendmail emulation); Mon, 06 Oct 2014 15:53:30 +0001 Date: Mon, 6 Oct 2014 15:53:30 +0100 From: Bruce Richardson To: "Wiles, Roger Keith" Message-ID: <20141006145330.GA2548@BRICHA3-MOBL> References: <1412464229-125521-1-git-send-email-keith.wiles@windriver.com> <1412464229-125521-2-git-send-email-keith.wiles@windriver.com> <59AF69C657FD0841A61C55336867B5B03441BE9E@IRSMSX103.ger.corp.intel.com> <5DD5FF6E-C045-4764-A5B1-877C88B023F5@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5DD5FF6E-C045-4764-A5B1-877C88B023F5@windriver.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.22 (2013-10-16) Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 2/2] Adding the routines rte_pktmbuf_alloc_bulk() and rte_pktmbuf_free_bulk() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Oct 2014 14:46:28 -0000 On Mon, Oct 06, 2014 at 03:50:38PM +0100, Wiles, Roger Keith wrote: > Hi Bruce, > > Do I need to reject the for the new routines or just make sure the vector driver does not get updated to use those routines? > The new routines are probably useful in the general case. I see no issue with having them in the code, so long as the vector driver is not modified to use them. /Bruce > Thanks > ++Keith > > On Oct 6, 2014, at 3:56 AM, Richardson, Bruce wrote: > > > > > > >> -----Original Message----- > >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Keith Wiles > >> Sent: Sunday, October 05, 2014 12:10 AM > >> To: dev@dpdk.org > >> Subject: [dpdk-dev] [PATCH 2/2] Adding the routines rte_pktmbuf_alloc_bulk() > >> and rte_pktmbuf_free_bulk() > >> > >> Minor helper routines to mirror the mempool routines and remove the code > >> from applications. The ixgbe_rxtx_vec.c routine could be changed to use > >> the ret_pktmbuf_alloc_bulk() routine inplace of rte_mempool_get_bulk(). > >> > > > > I believe such a change would cause a performance regression, as the extra init code in the alloc_bulk() function would take additional cycles and is not needed. The vector routines use the mempool function directly, so that there is no overhead of mbuf initialization, as the vector routines use their additional "knowledge" of what the mbufs will be used for to init them in a faster manner than can be done inside the mbuf library. > > > > /Bruce > > > >> Signed-off-by: Keith Wiles > >> --- > >> lib/librte_mbuf/rte_mbuf.h | 77 > >> ++++++++++++++++++++++++++++++++++++++++++++++ > >> 1 file changed, 77 insertions(+) > >> > >> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > >> index 1c6e115..f298621 100644 > >> --- a/lib/librte_mbuf/rte_mbuf.h > >> +++ b/lib/librte_mbuf/rte_mbuf.h > >> @@ -546,6 +546,41 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf > >> *m) > >> } > >> > >> /** > >> + * @internal Allocate a list of mbufs from mempool *mp*. > >> + * The use of that function is reserved for RTE internal needs. > >> + * Please use rte_pktmbuf_alloc_bulk(). > >> + * > >> + * @param mp > >> + * The mempool from which mbuf is allocated. > >> + * @param m_list > >> + * The array to place the allocated rte_mbufs pointers. > >> + * @param cnt > >> + * The number of mbufs to allocate > >> + * @return > >> + * - 0 if the number of mbufs allocated was ok > >> + * - <0 is an ERROR. > >> + */ > >> +static inline int __rte_mbuf_raw_alloc_bulk(struct rte_mempool *mp, struct > >> rte_mbuf *m_list[], int cnt) > >> +{ > >> + struct rte_mbuf *m; > >> + int ret; > >> + > >> + ret = rte_mempool_get_bulk(mp, (void **)m_list, cnt); > >> + if ( ret == 0 ) { > >> + int i; > >> + for(i = 0; i < cnt; i++) { > >> + m = *m_list++; > >> +#ifdef RTE_MBUF_REFCNT > >> + rte_mbuf_refcnt_set(m, 1); > >> +#endif /* RTE_MBUF_REFCNT */ > >> + rte_pktmbuf_reset(m); > >> + } > >> + ret = cnt; > >> + } > >> + return ret; > >> +} > >> + > >> +/** > >> * Allocate a new mbuf from a mempool. > >> * > >> * This new mbuf contains one segment, which has a length of 0. The pointer > >> @@ -671,6 +706,32 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > >> } > >> > >> /** > >> + * Allocate a list of mbufs from a mempool into a mbufs array. > >> + * > >> + * This mbuf list contains one segment per mbuf, which has a length of 0. The > >> pointer > >> + * to data is initialized to have some bytes of headroom in the buffer > >> + * (if buffer size allows). > >> + * > >> + * The routine is just a simple wrapper routine to reduce code in the application > >> and > >> + * provide a cleaner API for multiple mbuf requests. > >> + * > >> + * @param mp > >> + * The mempool from which the mbuf is allocated. > >> + * @param m_list > >> + * An array of mbuf pointers, cnt must be less then or equal to the size of the > >> list. > >> + * @param cnt > >> + * Number of slots in the m_list array to fill. > >> + * @return > >> + * - The number of valid mbufs pointers in the m_list array. > >> + * - Zero if the request cnt could not be allocated. > >> + */ > >> +static inline int __attribute__((always_inline)) > >> +rte_pktmbuf_alloc_bulk(struct rte_mempool *mp, struct rte_mbuf *m_list[], > >> int16_t cnt) > >> +{ > >> + return __rte_mbuf_raw_alloc_bulk(mp, m_list, cnt); > >> +} > >> + > >> +/** > >> * Free a segment of a packet mbuf into its original mempool. > >> * > >> * Free an mbuf, without parsing other segments in case of chained > >> @@ -708,6 +769,22 @@ static inline void rte_pktmbuf_free(struct rte_mbuf > >> *m) > >> } > >> } > >> > >> +/** > >> + * Free a list of packet mbufs back into its original mempool. > >> + * > >> + * Free a list of mbufs by calling rte_pktmbuf_free() in a loop as a wrapper > >> function. > >> + * > >> + * @param m_list > >> + * An array of rte_mbuf pointers to be freed. > >> + * @param npkts > >> + * Number of packets to free in list. > >> + */ > >> +static inline void rte_pktmbuf_free_bulk(struct rte_mbuf *m_list[], int16_t > >> npkts) > >> +{ > >> + while(npkts--) > >> + rte_pktmbuf_free(*m_list++); > >> +} > >> + > >> #ifdef RTE_MBUF_REFCNT > >> > >> /** > >> -- > >> 2.1.0 > > > > Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533 >