From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-x231.google.com (mail-wg0-x231.google.com [IPv6:2a00:1450:400c:c00::231]) by dpdk.org (Postfix) with ESMTP id 407916A22 for ; Mon, 6 May 2013 18:13:35 +0200 (CEST) Received: by mail-wg0-f49.google.com with SMTP id j13so3612890wgh.28 for ; Mon, 06 May 2013 09:13:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:x-gm-message-state; bh=XcwRvqTe7dumkPD+M1xg7blxM1e2dqJ5P66fKoa3m60=; b=eizTxgTxvfTr7IFrYmrj4RxVPqt+dsKHACbm8154rA+RDcFt2MGznX8wy+jUMiYfYl 1CQtaqTQYdCRc1W/K1qP32vNYY2QBpiFDdtE3l4fSR4QW8hmJmW9boegDs9YPUYT78KY AdEjp+nSp8OCoLHoQqFtSjojvPzansbPAapQNqiJFf+XWpk+HWCbsjt1Pbx/6O4Wrpcp /+a6GadcjuEgZ9+co67c8Oh7eX6BUXFOBvHsKWalvPuXYa3/9qjs8iOfv1gGqmMIIhgo Kn2aMaLsOdCz73pCA/bLK/4GfOf6om46gD4nw6yhggPH/jDA0Sk0+sGWogOxhj/fz1MS ELVw== X-Received: by 10.194.143.50 with SMTP id sb18mr26231155wjb.44.1367856815134; Mon, 06 May 2013 09:13:35 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id cw8sm3818514wib.7.2013.05.06.09.13.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 06 May 2013 09:13:34 -0700 (PDT) Date: Mon, 6 May 2013 18:13:34 +0200 From: Adrien Mazarguil To: dev@dpdk.org 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 Content-Disposition: inline In-Reply-To: <1367856001-25036-1-git-send-email-thomas.monjalon@6wind.com> X-Gm-Message-State: ALoCoQmWXVBNJFM3NljLehDS53kLqAbR2BaYk8A09GZDdSZphOeBEzpUyeZAIBtKDAm71N5+K1IF Subject: Re: [dpdk-dev] [PATCH] app: fix refcnt in mbuf allocation 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 May 2013 16:13:35 -0000 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