From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [IPv6:2a00:1450:400c:c05::22e]) by dpdk.org (Postfix) with ESMTP id 8ED554AAA for ; Mon, 6 May 2013 14:47:52 +0200 (CEST) Received: by mail-wi0-f174.google.com with SMTP id m6so2496060wiv.7 for ; Mon, 06 May 2013 05:47:52 -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=zGwkP/xG8tK+dZaTNcd0ew/+j0eCQI/7RZQHhMREgs0=; b=mHWaWmpW903XDdQyGGYgc/Y5X1IFAX/XTgoTZDD7uMlWYrwHFCCgYGiHxucaIykWR8 ub1bSPsd8sUokeOVXkumEed4P1GomecqfiRcv/BhSmPDrcZc0phyAJBbVjN8s6pMfBK5 AZcptRVArGpldEiQU+/p8AZJ7BJnvXjJKRT6jDK5UmFJTCskN/HDz3xlGD9rIFGOC3v9 YUealP50CI2oDgMKMRh7e3Eq0mIMlNs+CKYR4s1r9NPWSu0t7t8IXan/aeKIreKVjlgo BF/H9I0895bu+v2Ig97UGYhFRBiL5tAtRWAiXR0LhUDIBq2DQgDkMaa2z35Fr/9RYp0D um8Q== X-Received: by 10.194.61.10 with SMTP id l10mr8908741wjr.32.1367844472460; Mon, 06 May 2013 05:47:52 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id ge7sm15031423wib.6.2013.05.06.05.47.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 06 May 2013 05:47:50 -0700 (PDT) Received: by 6wind.com (sSMTP sendmail emulation); Mon, 06 May 2013 14:47:50 +0200 From: Thomas Monjalon To: dongsuh@cs.cmu.edu Date: Mon, 6 May 2013 14:47:50 +0200 Message-Id: <1367844470-15346-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-Gm-Message-State: ALoCoQlAkuDGgE+D86j5clBNvP1gkRKWvOgA4Vm3jyK9gHv9Xdkev0MrOEwx7JGbpu8+h4F9x92+ 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 12:47:52 -0000 Hi Dongsu Han, I think your fix is right. I've just removed tx_mbuf_alloc() and directly called rte_pktmbuf_alloc() instead. Is it OK for you ? Could you also review this (modified) description ? Thank you --- 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. By using the right API, refcnt is correctly handled among other initializations. Signed-off-by: Dongsu Han Signed-off-by: Thomas Monjalon --- app/test-pmd/txonly.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index d7c8c31..53f7138 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -89,19 +89,6 @@ static struct ipv4_hdr pkt_ip_hdr; /**< IP header of transmitted packets. */ static struct udp_hdr pkt_udp_hdr; /**< UDP header of transmitted packets. */ -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; - __rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1); - return m; -} - static void copy_buf_to_pkt_segs(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset) @@ -223,7 +210,7 @@ pkt_burst_transmit(struct fwd_stream *fs) vlan_tci = ports[fs->tx_port].tx_vlan_id; ol_flags = ports[fs->tx_port].tx_ol_flags; for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) { - pkt = tx_mbuf_alloc(mbp); + pkt = rte_pktmbuf_alloc(mbp); if (pkt == NULL) { nomore_mbuf: if (nb_pkt == 0) @@ -233,7 +220,7 @@ pkt_burst_transmit(struct fwd_stream *fs) pkt->pkt.data_len = tx_pkt_seg_lengths[0]; pkt_seg = pkt; for (i = 1; i < tx_pkt_nb_segs; i++) { - pkt_seg->pkt.next = tx_mbuf_alloc(mbp); + pkt_seg->pkt.next = rte_pktmbuf_alloc(mbp); if (pkt_seg->pkt.next == NULL) { pkt->pkt.nb_segs = i; rte_pktmbuf_free(pkt); -- 1.7.10.4