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 22015C6A2 for ; Fri, 29 Jan 2016 11:33:33 +0100 (CET) Received: by mail-wm0-f50.google.com with SMTP id 128so46845331wmz.1 for ; Fri, 29 Jan 2016 02:33:33 -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=vYoZZv9UsNlMCiqYgKv2ZGsFe1BbODtb3L4q1dPHX7E=; b=DxKqnu5gybNg7ib8I1gDZWR37A4oeEPE5E9B3xl2v2TJxnYVIU7l5rYvvvVh2gbLRm 0Ry4XealMG6L0pnHg4esTr5GLS5+tzUClUBOQZ1ruVVrl8qhPxCldc2/E66GnQ6Ci+r6 JzdYmW2wDANKexSmzjWH6lt2SMSUiUViwm+e6BZmFYQyS1jEGp2hMZEK5OY7L/sFTXjZ l0BTjIRQbi2+gRh/5FxXbvysw4bpBM/lAid8YyoYghSxUag3mEA4HmdDeAijng3iNgSt OfrP+i2azjiG6lfYFjLUDlMBgaJ1ePuC7tMBI+64G0mtNSisAi/qemarslrvOVmLn8HC QEbw== 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=vYoZZv9UsNlMCiqYgKv2ZGsFe1BbODtb3L4q1dPHX7E=; b=J0v7nss/CWvHsUbJUeDHUdRDRLovXf5pipm0A/ZhIPnEV1qyLtD5I1it9LgocPWME5 91EkCO/3klMUPvnL3M2VzwIYrAa1o+bymafZiui++CCrV21aqqiMWJEPFcPSdA7djgPz RQteTNZwkDEffMsPvrj+wOLD+lrKBJmCtQv+sITp9M6JH0Ol2gxhV21nafGPlEIzaGFV wpQSjqveH1A/oOgoOj8qGmljzlkQVX+TWSDgYalNcpyG4OSy7SigRkCYcDgiFyZ/EOkK U5pl0/JNGEJ2kdl9vOAFLN74S/QhYJgr0CVxgmlAkEnME/2qHS+KgT4mVRvcbshsxlX6 bSgg== X-Gm-Message-State: AG10YORsgxDoleTxDcGVHn+r1YUE8wMG9BVScqmbeZrnBlr9qH8njrWrr1zQtCtCEaaLHF/l X-Received: by 10.194.175.233 with SMTP id cd9mr8073747wjc.115.1454063612994; Fri, 29 Jan 2016 02:33:32 -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 u130sm6824356wmg.15.2016.01.29.02.33.32 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 29 Jan 2016 02:33:32 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Fri, 29 Jan 2016 11:32:53 +0100 Message-Id: <1454063573-1993-7-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454063573-1993-1-git-send-email-adrien.mazarguil@6wind.com> References: <1454063573-1993-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH 6/6] 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: Fri, 29 Jan 2016 10:33:33 -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 579efa0..36abeef 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 = @@ -567,7 +573,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