From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-x229.google.com (mail-we0-x229.google.com [IPv6:2a00:1450:400c:c03::229]) by dpdk.org (Postfix) with ESMTP id AD39C6A44 for ; Mon, 6 May 2013 18:00:02 +0200 (CEST) Received: by mail-we0-f169.google.com with SMTP id x51so3181363wey.0 for ; Mon, 06 May 2013 09:00:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=e0KS4FQQnGQ8HqnmGJjXoStBhv/KemeeCHtGJ1Zw5PQ=; b=HmrOd3cujHw636OXUPStm7QBckHp5tTLv0vyRdkgC0BgoJ2Evl8DO1VycngpPgc3uk Gxy4im4Cnejhb/D/pXF/7CTIRkVHXKT5t4tULYG8qdSwjEcDcodtRltj2tS1/ODG8XWb GRoEcc4k1iDYMnz720sr9+cNFWZEumSD9cIUIQlI+PHBqvqjhZndJW+c3sI9MwEvdZAX KXQblZXE0oAhPsFA6tnHos3em2iEPY8m8IN45CPBG57ZxXLaFlDgJ3KHWCEY7Ib0EiRx epGPtP9PO0HHIxsW1MgO2ghoY6CudywUonnV8DjdOiaiYEyQkvJ+IJKXnPWY8SvEhL90 N6Nw== X-Received: by 10.194.93.231 with SMTP id cx7mr26143935wjb.33.1367856002589; Mon, 06 May 2013 09:00:02 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id eu18sm14691776wid.1.2013.05.06.08.59.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 06 May 2013 09:00:01 -0700 (PDT) Received: by 6wind.com (sSMTP sendmail emulation); Mon, 06 May 2013 18:00:01 +0200 From: Thomas Monjalon To: Adrien Mazarguil Date: Mon, 6 May 2013 18:00:01 +0200 Message-Id: <1367856001-25036-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20130506135616.GN12221@6wind.com> References: <20130506135616.GN12221@6wind.com> X-Gm-Message-State: ALoCoQkYuIYgcUMFbSsCFaK86niR9d3e0hAI4gWt2wbHnJYtITcapp5X2ImGZQZq/kEfxwyZR2NY Cc: dev@dpdk.org Subject: [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:00:03 -0000 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