From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: [PATCH] app: fix refcnt in mbuf allocation Date: Mon, 6 May 2013 18:13:34 +0200 Message-ID: <20130506161334.GO12221@6wind.com> References: <20130506135616.GN12221@6wind.com> <1367856001-25036-1-git-send-email-thomas.monjalon@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: dev-VfR2kkLFssw@public.gmane.org Return-path: Content-Disposition: inline In-Reply-To: <1367856001-25036-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" On Mon, May 06, 2013 at 06:00:01PM +0200, Thomas Monjalon wrote: > From: Dongsu Han > > test-pmd txonly leaks mbuf from the pool. > The function tx_mbuf_alloc() does not change the refcnt > and the refcnt is 0 when it is first allocated. > However, rte_pktmbuf_free_seg called by the driver's xmit code decrements > reference count to -1. So mbuf never goes back to the pool. > As a result, txonly can't send packets after it exhausts the mempool. > > The function tx_mbuf_alloc() was getting mbuf directly from mempool and so > was bypassing mbuf API. > The dedicated function is rte_pktmbuf_alloc() but it is much slower because > it does unnecessary initializations in rte_pktmbuf_reset(). > By using the internal API __rte_mbuf_raw_alloc(), refcnt is correctly handled > without adding too much overload. > > Signed-off-by: Dongsu Han > Signed-off-by: Thomas Monjalon > --- > app/test-pmd/txonly.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c > index d7c8c31..e7c9a1a 100644 > --- a/app/test-pmd/txonly.c > +++ b/app/test-pmd/txonly.c > @@ -93,11 +93,8 @@ static inline struct rte_mbuf * > tx_mbuf_alloc(struct rte_mempool *mp) > { > struct rte_mbuf *m; > - void *mb; > > - if (rte_mempool_get(mp, &mb) < 0) > - return NULL; > - m = (struct rte_mbuf *)mb; > + m = __rte_mbuf_raw_alloc(mp); > __rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1); > return m; > } > -- > 1.7.10.4 Looks good. Acked-by: Adrien Mazarguil -- Adrien Mazarguil 6WIND