From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-2.cisco.com (alln-iport-2.cisco.com [173.37.142.89]) by dpdk.org (Postfix) with ESMTP id ECA779AC8 for ; Sat, 9 Jul 2016 00:22:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1972; q=dns/txt; s=iport; t=1468016525; x=1469226125; h=from:to:cc:subject:date:message-id; bh=3bW0ir6zhdKDIr6AyxmPYDpL9+GFEldX4mGJ7e500iM=; b=a5A7xV+dSbtad6bNN8O7fmP8XLuRtUotrSEw/Jd+4MWrZtsOdW5kSeUA fKIzS6o179P5o5x4m9xKmbiEoEqdSTb0BmIwT8ypjL30SUyfYyxEspW5d MLeD4bea8mlkseVLRM7dHnYKU5Sb4xVwAlSUarOhJtwD/j8/sZMwVkpi6 A=; X-IronPort-AV: E=Sophos;i="5.28,332,1464652800"; d="scan'208";a="294003137" Received: from rcdn-core-1.cisco.com ([173.37.93.152]) by alln-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jul 2016 22:22:04 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id u68MM3gd002139; Fri, 8 Jul 2016 22:22:03 GMT Received: by cisco.com (Postfix, from userid 392789) id AB6CA3FAAE44; Fri, 8 Jul 2016 15:22:03 -0700 (PDT) From: John Daley To: dev@dpdk.org Cc: bruce.richardson@intel.com, John Daley Date: Fri, 8 Jul 2016 15:22:00 -0700 Message-Id: <1468016521-20280-1-git-send-email-johndale@cisco.com> X-Mailer: git-send-email 2.7.0 Subject: [dpdk-dev] [PATCH] net/enic: decrement Tx mbuf reference count before recycling 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: Fri, 08 Jul 2016 22:22:05 -0000 In the Tx cleanup function, the reference count in mbufs to be returned to the pool should to be decremented before they are returned. Decrementing is not done by rte_mempool_put_bulk() so it must be done separately using __rte_pktmbuf_prefree_seg(). If decrementing does not result in a 0 reference count the mbuf is not returned to the pool and whatever has the last reference is responsible for freeing. Fixes: 36935afbc53c ("net/enic: refactor Tx mbuf recycling") Reviewed-by: Nelson Escobar Signed-off-by: John Daley --- Since reference counts are set to 0 when mbufs are reallocated from the pool, and sending packets with reference count not equal to 1 is probably an application error, this patch may not be critical. But a debug ASSERT caught it and it would be nice to have it fixed in 16.07. drivers/net/enic/enic_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c index 5ac1d69..96be478 100644 --- a/drivers/net/enic/enic_rxtx.c +++ b/drivers/net/enic/enic_rxtx.c @@ -398,7 +398,14 @@ static inline void enic_free_wq_bufs(struct vnic_wq *wq, u16 completed_index) pool = ((struct rte_mbuf *)buf->mb)->pool; for (i = 0; i < nb_to_free; i++) { buf = &wq->bufs[tail_idx]; - m = (struct rte_mbuf *)(buf->mb); + m = __rte_pktmbuf_prefree_seg((struct rte_mbuf *)(buf->mb)); + buf->mb = NULL; + + if (unlikely(m == NULL)) { + tail_idx = enic_ring_incr(desc_count, tail_idx); + continue; + } + if (likely(m->pool == pool)) { ENIC_ASSERT(nb_free < ENIC_MAX_WQ_DESCS); free[nb_free++] = m; @@ -409,7 +416,6 @@ static inline void enic_free_wq_bufs(struct vnic_wq *wq, u16 completed_index) pool = m->pool; } tail_idx = enic_ring_incr(desc_count, tail_idx); - buf->mb = NULL; } rte_mempool_put_bulk(pool, (void **)free, nb_free); -- 2.7.0