From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id B1AE2532D for ; Mon, 22 Feb 2016 19:18:35 +0100 (CET) Received: by mail-wm0-f50.google.com with SMTP id c200so185105185wme.0 for ; Mon, 22 Feb 2016 10:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VYLjBKpat7Igi/D1Cpjo6wH6AyOdSOj/mAPXXzjQP1I=; b=wO06yUmtQHKQW0PWYwOU25elvurxtQ+8exOrDFQOb7uHhqR87UBXu5XMUSVDY61+70 EqLL/+sPe8dZycsIsmB5s/HoC0z1VBcXk3X0KTWX5gVu9xB+sXiz5WT57npUFh+Oyqfx 6CN/k2AkB/slxuNx4Vo4QB2L5Yw3c89KVrxYRxueKl85S8lLKynIs58zJ9y1WWzJeYht KqhvGF89LcbLDpYx3JJVUzYyHDdQnbgAk7pbQ5CiZCtGV0hXLCCDy8/nLvogAIA1toyI UQ5rcmRXktUv4gG3VoDcoZ9qIkNHe9C+3wjth2rflY+YP8j/L9bn3XJaLPqQNeClUpug id0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VYLjBKpat7Igi/D1Cpjo6wH6AyOdSOj/mAPXXzjQP1I=; b=Git7zzqmQhFRf4kXKtHODm4pBMgyQcLM/QWcY0L8FQKcLv7waQPxtGkf8Fba9N93I4 zYRkyVtY6Rt470vnVk+WC2aL1L/g/bU/QSmTycEFA9wzHrF6QIogmgaaVhwBz70tmFcx TNtE8kHr1bdkhSy8jU0g1k1wMRlzMzq91C413vaEwXJgfXdMI24BJ2G32OrOrKcRR/W+ 3tONr8BRCCjxsQMwpk/4cDQriTYcFCRUxWFzlXNMdLJKe/Da2i912gscmJqn48rdd3P/ cjJi+p9gfDqod0A3Ni8w7yKBa0FosaW0j3rquJbP24WUpPqAVgDvnOFpTh3jD9saszt5 71KA== X-Gm-Message-State: AG10YOS3RjRTQPeus2zVb1Ucw5RQpT5ajfia3/0cnXh++tUbU3rXhcWWDTlXgXlFCCxiNM9t X-Received: by 10.28.50.133 with SMTP id y127mr13537902wmy.4.1456165115587; Mon, 22 Feb 2016 10:18:35 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id r10sm25809209wjz.24.2016.02.22.10.18.34 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 22 Feb 2016 10:18:34 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Mon, 22 Feb 2016 19:18:02 +0100 Message-Id: <1456165083-28316-7-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456165083-28316-1-git-send-email-adrien.mazarguil@6wind.com> References: <1454063573-1993-1-git-send-email-adrien.mazarguil@6wind.com> <1456165083-28316-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH v2 6/7] mlx5: free buffers immediately after completion 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, 22 Feb 2016 18:18:36 -0000 From: Nelio Laranjeiro This lowers the amount of cache misses. Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_rxtx.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index b82017e..622ac17 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -84,6 +84,7 @@ txq_complete(struct txq *txq) { unsigned int elts_comp = txq->elts_comp; unsigned int elts_tail = txq->elts_tail; + unsigned int elts_free = txq->elts_tail; const unsigned int elts_n = txq->elts_n; int wcs_n; @@ -110,6 +111,25 @@ txq_complete(struct txq *txq) elts_tail += wcs_n * txq->elts_comp_cd_init; if (elts_tail >= elts_n) elts_tail -= elts_n; + + while (elts_free != elts_tail) { + struct txq_elt *elt = &(*txq->elts)[elts_free]; + unsigned int elts_free_next = + (((elts_free + 1) == elts_n) ? 0 : elts_free + 1); + struct rte_mbuf *tmp = elt->buf; + struct txq_elt *elt_next = &(*txq->elts)[elts_free_next]; + + RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf); + /* Faster than rte_pktmbuf_free(). */ + do { + struct rte_mbuf *next = NEXT(tmp); + + rte_pktmbuf_free_seg(tmp); + tmp = next; + } while (tmp != NULL); + elts_free = elts_free_next; + } + txq->elts_tail = elts_tail; txq->elts_comp = elts_comp; return 0; @@ -464,7 +484,6 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) struct rte_mbuf *buf_next = pkts[i + 1]; unsigned int elts_head_next = (((elts_head + 1) == elts_n) ? 0 : elts_head + 1); - struct txq_elt *elt_next = &(*txq->elts)[elts_head_next]; struct txq_elt *elt = &(*txq->elts)[elts_head]; unsigned int segs = NB_SEGS(buf); #ifdef MLX5_PMD_SOFT_COUNTERS @@ -472,18 +491,6 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) #endif uint32_t send_flags = 0; - /* Clean up old buffer. */ - if (likely(elt->buf != NULL)) { - struct rte_mbuf *tmp = elt->buf; - - /* Faster than rte_pktmbuf_free(). */ - do { - struct rte_mbuf *next = NEXT(tmp); - - rte_pktmbuf_free_seg(tmp); - tmp = next; - } while (tmp != NULL); - } if (i + 1 < max) rte_prefetch0(buf_next); /* Request TX completion. */ @@ -517,7 +524,6 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) if (txq->priv->vf) rte_prefetch0((volatile void *) (uintptr_t)addr); - RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf); /* Prefetch next buffer data. */ if (i + 1 < max) { buf_next_addr = @@ -568,7 +574,6 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) &sges); if (ret.length == (unsigned int)-1) goto stop; - RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf); /* Put SG list into send queue. */ err = txq->send_pending_sg_list (txq->qp, -- 2.1.4