From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id D42211B4AA for ; Thu, 29 Nov 2018 14:23:20 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4103930031A1; Thu, 29 Nov 2018 13:23:20 +0000 (UTC) Received: from ktraynor.remote.csb (ovpn-117-230.ams2.redhat.com [10.36.117.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 002791001F50; Thu, 29 Nov 2018 13:23:18 +0000 (UTC) From: Kevin Traynor To: Yongseok Koh Cc: Shahaf Shuler , dpdk stable Date: Thu, 29 Nov 2018 13:20:48 +0000 Message-Id: <20181129132128.7609-48-ktraynor@redhat.com> In-Reply-To: <20181129132128.7609-1-ktraynor@redhat.com> References: <20181129132128.7609-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 29 Nov 2018 13:23:20 +0000 (UTC) Subject: [dpdk-stable] patch 'net/mlx5: optimize Tx external memory registration' has been queued to stable release 18.08.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2018 13:23:21 -0000 Hi, FYI, your patch has been queued to stable release 18.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/08/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Kevin Traynor --- >>From 5c354a0f6dbcd7841296acc99e66454130d55d2a Mon Sep 17 00:00:00 2001 From: Yongseok Koh Date: Thu, 15 Nov 2018 10:29:17 +0000 Subject: [PATCH] net/mlx5: optimize Tx external memory registration [ upstream commit feddd5d243b7b43d51d2e9655b9143c462384ea8 ] There's some performance drop due to extra condition checks on the datapath. Checking for external memory registration should be consolidated to the existing bottom-half. Fixes: 7e43a32ee060 ("net/mlx5: support externally allocated static memory") Signed-off-by: Yongseok Koh Acked-by: Shahaf Shuler --- drivers/net/mlx5/mlx5_mr.c | 28 +++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_rxtx.h | 26 ++++++-------------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index 6d7653d7d..442b2d232 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -1046,5 +1046,5 @@ mlx5_rx_addr2mr_bh(struct mlx5_rxq_data *rxq, uintptr_t addr) * Searched LKey on success, UINT32_MAX on no match. */ -uint32_t +static uint32_t mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr) { @@ -1060,4 +1060,30 @@ mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr) } +/** + * Bottom-half of LKey search on Tx. If it can't be searched in the memseg + * list, register the mempool of the mbuf as externally allocated memory. + * + * @param txq + * Pointer to Tx queue structure. + * @param mb + * Pointer to mbuf. + * + * @return + * Searched LKey on success, UINT32_MAX on no match. + */ +uint32_t +mlx5_tx_mb2mr_bh(struct mlx5_txq_data *txq, struct rte_mbuf *mb) +{ + uintptr_t addr = (uintptr_t)mb->buf_addr; + uint32_t lkey; + + lkey = mlx5_tx_addr2mr_bh(txq, addr); + if (lkey == UINT32_MAX && rte_errno == ENXIO) { + /* Mempool may have externally allocated memory. */ + return mlx5_tx_update_ext_mp(txq, addr, mlx5_mb2mp(mb)); + } + return lkey; +} + /** * Flush all of the local cache entries. diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 1db468c3b..e1dc6db21 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -363,5 +363,5 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, void mlx5_mr_flush_local_cache(struct mlx5_mr_ctrl *mr_ctrl); uint32_t mlx5_rx_addr2mr_bh(struct mlx5_rxq_data *rxq, uintptr_t addr); -uint32_t mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr); +uint32_t mlx5_tx_mb2mr_bh(struct mlx5_txq_data *txq, struct rte_mbuf *mb); uint32_t mlx5_tx_update_ext_mp(struct mlx5_txq_data *txq, uintptr_t addr, struct rte_mempool *mp); @@ -619,5 +619,5 @@ mlx5_tx_complete(struct mlx5_txq_data *txq) * Memory pool where data is located for given mbuf. */ -static struct rte_mempool * +static inline struct rte_mempool * mlx5_mb2mp(struct rte_mbuf *buf) { @@ -668,7 +668,8 @@ mlx5_rx_addr2mr(struct mlx5_rxq_data *rxq, uintptr_t addr) */ static __rte_always_inline uint32_t -mlx5_tx_addr2mr(struct mlx5_txq_data *txq, uintptr_t addr) +mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb) { struct mlx5_mr_ctrl *mr_ctrl = &txq->mr_ctrl; + uintptr_t addr = (uintptr_t)mb->buf_addr; uint32_t lkey; @@ -681,21 +682,6 @@ mlx5_tx_addr2mr(struct mlx5_txq_data *txq, uintptr_t addr) if (likely(lkey != UINT32_MAX)) return lkey; - /* Take slower bottom-half (binary search) on miss. */ - return mlx5_tx_addr2mr_bh(txq, addr); -} - -static __rte_always_inline uint32_t -mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb) -{ - uintptr_t addr = (uintptr_t)mb->buf_addr; - uint32_t lkey = mlx5_tx_addr2mr(txq, addr); - - if (likely(lkey != UINT32_MAX)) - return lkey; - if (rte_errno == ENXIO) { - /* Mempool may have externally allocated memory. */ - lkey = mlx5_tx_update_ext_mp(txq, addr, mlx5_mb2mp(mb)); - } - return lkey; + /* Take slower bottom-half on miss. */ + return mlx5_tx_mb2mr_bh(txq, mb); } -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-29 13:11:36.270910483 +0000 +++ 0047-net-mlx5-optimize-Tx-external-memory-registration.patch 2018-11-29 13:11:34.000000000 +0000 @@ -1,14 +1,15 @@ -From feddd5d243b7b43d51d2e9655b9143c462384ea8 Mon Sep 17 00:00:00 2001 +From 5c354a0f6dbcd7841296acc99e66454130d55d2a Mon Sep 17 00:00:00 2001 From: Yongseok Koh Date: Thu, 15 Nov 2018 10:29:17 +0000 Subject: [PATCH] net/mlx5: optimize Tx external memory registration +[ upstream commit feddd5d243b7b43d51d2e9655b9143c462384ea8 ] + There's some performance drop due to extra condition checks on the datapath. Checking for external memory registration should be consolidated to the existing bottom-half. Fixes: 7e43a32ee060 ("net/mlx5: support externally allocated static memory") -Cc: stable@dpdk.org Signed-off-by: Yongseok Koh Acked-by: Shahaf Shuler @@ -60,24 +61,24 @@ /** * Flush all of the local cache entries. diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h -index 1b6200f6c..59fb43fef 100644 +index 1db468c3b..e1dc6db21 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h -@@ -364,5 +364,5 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, +@@ -363,5 +363,5 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, void mlx5_mr_flush_local_cache(struct mlx5_mr_ctrl *mr_ctrl); uint32_t mlx5_rx_addr2mr_bh(struct mlx5_rxq_data *rxq, uintptr_t addr); -uint32_t mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr); +uint32_t mlx5_tx_mb2mr_bh(struct mlx5_txq_data *txq, struct rte_mbuf *mb); uint32_t mlx5_tx_update_ext_mp(struct mlx5_txq_data *txq, uintptr_t addr, struct rte_mempool *mp); -@@ -620,5 +620,5 @@ mlx5_tx_complete(struct mlx5_txq_data *txq) +@@ -619,5 +619,5 @@ mlx5_tx_complete(struct mlx5_txq_data *txq) * Memory pool where data is located for given mbuf. */ -static struct rte_mempool * +static inline struct rte_mempool * mlx5_mb2mp(struct rte_mbuf *buf) { -@@ -669,7 +669,8 @@ mlx5_rx_addr2mr(struct mlx5_rxq_data *rxq, uintptr_t addr) +@@ -668,7 +668,8 @@ mlx5_rx_addr2mr(struct mlx5_rxq_data *rxq, uintptr_t addr) */ static __rte_always_inline uint32_t -mlx5_tx_addr2mr(struct mlx5_txq_data *txq, uintptr_t addr) @@ -87,7 +88,7 @@ + uintptr_t addr = (uintptr_t)mb->buf_addr; uint32_t lkey; -@@ -682,21 +683,6 @@ mlx5_tx_addr2mr(struct mlx5_txq_data *txq, uintptr_t addr) +@@ -681,21 +682,6 @@ mlx5_tx_addr2mr(struct mlx5_txq_data *txq, uintptr_t addr) if (likely(lkey != UINT32_MAX)) return lkey; - /* Take slower bottom-half (binary search) on miss. */