patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Shahed Shaikh <shshaikh@marvell.com>
Cc: Rasesh Mody <rmody@marvell.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'net/qede: fix performance bottleneck in Rx path' has been queued to LTS release 18.11.1
Date: Thu,  7 Feb 2019 13:25:44 +0000	[thread overview]
Message-ID: <20190207132614.20538-38-ktraynor@redhat.com> (raw)
In-Reply-To: <20190207132614.20538-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to LTS release 18.11.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 02/14/19. 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. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Kevin Traynor

---
>From 7e22a66545262ffcbd07ff6a266614dfeff643e9 Mon Sep 17 00:00:00 2001
From: Shahed Shaikh <shshaikh@marvell.com>
Date: Fri, 18 Jan 2019 02:29:29 -0800
Subject: [PATCH] net/qede: fix performance bottleneck in Rx path

[ upstream commit 8f2312474529ad7ff0e4b65b82efc8530e7484ce ]

Allocating replacement buffer per received packet is expensive.
Instead, process received packets first and allocate
replacement buffers in bulk later.

This improves performance by ~25% in terms of PPS on AMD
platforms.

Fixes: 2ea6f76aff40 ("qede: add core driver")

Signed-off-by: Shahed Shaikh <shshaikh@marvell.com>
Acked-by: Rasesh Mody <rmody@marvell.com>
---
 drivers/net/qede/qede_rxtx.c | 97 +++++++++++++++++++++++++++---------
 drivers/net/qede/qede_rxtx.h |  2 +
 2 files changed, 75 insertions(+), 24 deletions(-)

diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index 0e33be1a3..684c4aeef 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -36,4 +36,50 @@ static inline int qede_alloc_rx_buffer(struct qede_rx_queue *rxq)
 }
 
+#define QEDE_MAX_BULK_ALLOC_COUNT 512
+
+static inline int qede_alloc_rx_bulk_mbufs(struct qede_rx_queue *rxq, int count)
+{
+	void *obj_p[QEDE_MAX_BULK_ALLOC_COUNT] __rte_cache_aligned;
+	struct rte_mbuf *mbuf = NULL;
+	struct eth_rx_bd *rx_bd;
+	dma_addr_t mapping;
+	int i, ret = 0;
+	uint16_t idx;
+
+	idx = rxq->sw_rx_prod & NUM_RX_BDS(rxq);
+
+	if (count > QEDE_MAX_BULK_ALLOC_COUNT)
+		count = QEDE_MAX_BULK_ALLOC_COUNT;
+
+	ret = rte_mempool_get_bulk(rxq->mb_pool, obj_p, count);
+	if (unlikely(ret)) {
+		PMD_RX_LOG(ERR, rxq,
+			   "Failed to allocate %d rx buffers "
+			    "sw_rx_prod %u sw_rx_cons %u mp entries %u free %u",
+			    count, idx, rxq->sw_rx_cons & NUM_RX_BDS(rxq),
+			    rte_mempool_avail_count(rxq->mb_pool),
+			    rte_mempool_in_use_count(rxq->mb_pool));
+		return -ENOMEM;
+	}
+
+	for (i = 0; i < count; i++) {
+		mbuf = obj_p[i];
+		if (likely(i < count - 1))
+			rte_prefetch0(obj_p[i + 1]);
+
+		idx = rxq->sw_rx_prod & NUM_RX_BDS(rxq);
+		rxq->sw_rx_ring[idx].mbuf = mbuf;
+		rxq->sw_rx_ring[idx].page_offset = 0;
+		mapping = rte_mbuf_data_iova_default(mbuf);
+		rx_bd = (struct eth_rx_bd *)
+			ecore_chain_produce(&rxq->rx_bd_ring);
+		rx_bd->addr.hi = rte_cpu_to_le_32(U64_HI(mapping));
+		rx_bd->addr.lo = rte_cpu_to_le_32(U64_LO(mapping));
+		rxq->sw_rx_prod++;
+	}
+
+	return 0;
+}
+
 /* Criterias for calculating Rx buffer size -
  * 1) rx_buf_size should not exceed the size of mbuf
@@ -1132,5 +1178,5 @@ qede_reuse_page(__rte_unused struct qede_dev *qdev,
 {
 	struct eth_rx_bd *rx_bd_prod = ecore_chain_produce(&rxq->rx_bd_ring);
-	uint16_t idx = rxq->sw_rx_cons & NUM_RX_BDS(rxq);
+	uint16_t idx = rxq->sw_rx_prod & NUM_RX_BDS(rxq);
 	struct qede_rx_entry *curr_prod;
 	dma_addr_t new_mapping;
@@ -1365,5 +1411,4 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 #endif
 	uint8_t tunn_parse_flag;
-	uint8_t j;
 	struct eth_fast_path_rx_tpa_start_cqe *cqe_start_tpa;
 	uint64_t ol_flags;
@@ -1374,4 +1419,5 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	struct qede_agg_info *tpa_info = NULL;
 	uint32_t rss_hash;
+	int rx_alloc_count = 0;
 
 	hw_comp_cons = rte_le_to_cpu_16(*rxq->hw_cons_ptr);
@@ -1383,4 +1429,23 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		return 0;
 
+	/* Allocate buffers that we used in previous loop */
+	if (rxq->rx_alloc_count) {
+		if (unlikely(qede_alloc_rx_bulk_mbufs(rxq,
+			     rxq->rx_alloc_count))) {
+			struct rte_eth_dev *dev;
+
+			PMD_RX_LOG(ERR, rxq,
+				   "New buffer allocation failed,"
+				   "dropping incoming packetn");
+			dev = &rte_eth_devices[rxq->port_id];
+			dev->data->rx_mbuf_alloc_failed +=
+							rxq->rx_alloc_count;
+			rxq->rx_alloc_errors += rxq->rx_alloc_count;
+			return 0;
+		}
+		qede_update_rx_prod(qdev, rxq);
+		rxq->rx_alloc_count = 0;
+	}
+
 	while (sw_comp_cons != hw_comp_cons) {
 		ol_flags = 0;
@@ -1554,14 +1619,5 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		}
 
-		if (unlikely(qede_alloc_rx_buffer(rxq) != 0)) {
-			PMD_RX_LOG(ERR, rxq,
-				   "New buffer allocation failed,"
-				   "dropping incoming packet\n");
-			qede_recycle_rx_bd_ring(rxq, qdev, fp_cqe->bd_num);
-			rte_eth_devices[rxq->port_id].
-			    data->rx_mbuf_alloc_failed++;
-			rxq->rx_alloc_errors++;
-			break;
-		}
+		rx_alloc_count++;
 		qede_rx_bd_ring_consume(rxq);
 
@@ -1575,15 +1631,7 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 						 pkt_len - len))
 				goto next_cqe;
-			for (j = 0; j < num_segs; j++) {
-				if (qede_alloc_rx_buffer(rxq)) {
-					PMD_RX_LOG(ERR, rxq,
-						"Buffer allocation failed");
-					rte_eth_devices[rxq->port_id].
-						data->rx_mbuf_alloc_failed++;
-					rxq->rx_alloc_errors++;
-					break;
-				}
-				rxq->rx_segs++;
-			}
+
+			rx_alloc_count += num_segs;
+			rxq->rx_segs += num_segs;
 		}
 		rxq->rx_segs++; /* for the first segment */
@@ -1627,5 +1675,6 @@ next_cqe:
 	}
 
-	qede_update_rx_prod(qdev, rxq);
+	/* Request number of bufferes to be allocated in next loop */
+	rxq->rx_alloc_count = rx_alloc_count;
 
 	rxq->rcv_pkts += rx_pkt;
diff --git a/drivers/net/qede/qede_rxtx.h b/drivers/net/qede/qede_rxtx.h
index 454daa07b..5b249cbb2 100644
--- a/drivers/net/qede/qede_rxtx.h
+++ b/drivers/net/qede/qede_rxtx.h
@@ -193,4 +193,6 @@ struct qede_rx_queue {
 	uint16_t port_id;
 	uint16_t rx_buf_size;
+	uint16_t rx_alloc_count;
+	uint16_t unused;
 	uint64_t rcv_pkts;
 	uint64_t rx_segs;
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-02-07 13:19:56.429751219 +0000
+++ 0038-net-qede-fix-performance-bottleneck-in-Rx-path.patch	2019-02-07 13:19:55.000000000 +0000
@@ -1,8 +1,10 @@
-From 8f2312474529ad7ff0e4b65b82efc8530e7484ce Mon Sep 17 00:00:00 2001
+From 7e22a66545262ffcbd07ff6a266614dfeff643e9 Mon Sep 17 00:00:00 2001
 From: Shahed Shaikh <shshaikh@marvell.com>
 Date: Fri, 18 Jan 2019 02:29:29 -0800
 Subject: [PATCH] net/qede: fix performance bottleneck in Rx path
 
+[ upstream commit 8f2312474529ad7ff0e4b65b82efc8530e7484ce ]
+
 Allocating replacement buffer per received packet is expensive.
 Instead, process received packets first and allocate
 replacement buffers in bulk later.
@@ -11,7 +13,6 @@
 platforms.
 
 Fixes: 2ea6f76aff40 ("qede: add core driver")
-Cc: stable@dpdk.org
 
 Signed-off-by: Shahed Shaikh <shshaikh@marvell.com>
 Acked-by: Rasesh Mody <rmody@marvell.com>

  parent reply	other threads:[~2019-02-07 13:28 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 13:25 [dpdk-stable] patch 'net/mlx5: remove checks for outer tunnel items on E-Switch' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/mlx5: validate tunnel inner " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/mlx5: support " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/mlx5: validate ethernet type " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/mlx5: support ethernet type for tunnels " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/mlx5: fix typos and code style' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/enic: remove useless include' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'drivers: fix sprintf with snprintf' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'eal: fix log level of error in option register' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'doc: fix a typo in power management guide' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'test/hash: fix perf result' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'examples/tep_term: remove unused constant' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'examples/vhost: fix a typo' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'eal: fix core number validation' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'eal: fix out of bound access when no CPU available' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'eal: check string parameter lengths' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'eal: fix clang build with intrinsics forced' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'build: fix meson check for binutils 2.30' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'app/pdump: fix vdev cleanup' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'gro: check invalid TCP header length' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'doc: add GRO limitations in programmers guide' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'examples/kni: fix crash while handling userspace request' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/i40e: fix VF overwrite PF RSS LUT for X722' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/mlx5: fix Rx packet padding' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/mlx5: fix deprecated library API for Rx " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/sfc: fix VF error/missed stats mapping' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/sfc: fix datapath name references in logs' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'vhost: fix memory leak on realloc failure' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'examples/vhost: fix path allocation failure handling' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/sfc: fix Rx packets counter' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'doc: fix ifc naming' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'doc: add missing loopback option in testpmd guide' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'efd: fix tail queue leak' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'bus/ifpga: fix build for cpp applications' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'bus/ifpga: fix forcing optional devargs' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'bus/ifpga: fix AFU probe failure handler' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'raw/ifpga: fix memory leak' " Kevin Traynor
2019-02-07 13:25 ` Kevin Traynor [this message]
2019-02-07 13:25 ` [dpdk-stable] patch 'net/qede: remove prefetch in Tx path' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'doc: fix references in power management guide' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'doc: add GCM AAD limitation in qat " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'test/metrics: fix a negative case' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'vfio: allow secondary process to query IOMMU type' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'ethdev: fix errno to have positive value' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'gso: fix VxLAN/GRE tunnel checks' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'kni: fix build on RHEL8 for arm and Power9' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'kni: fix build for dev_open in Linux 5.0' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'kni: fix build for igb_ndo_bridge_setlink " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'vfio: fix error message' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'eal/linux: fix parsing zero socket memory and limits' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'test: check zero socket memory as valid' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'net/i40e: fix queue region DCB configure' " Kevin Traynor
2019-02-07 13:25 ` [dpdk-stable] patch 'vhost: fix access for indirect descriptors' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/sfc: fix crash in EF10 TSO if no payload' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'app/testpmd: fix Tx metadata show command' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/virtio-user: fix used ring in cvq handling' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/mlx5: fix TC rule handle assignment' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/mlx5: fix VXLAN port registration race condition' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/i40e: fix statistics' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/sfc: fix port ID log' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/mlx5: fix VXLAN without decap action for E-Switch' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/ena: fix dev init with multi-process' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/ena: fix errno to positive value' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'crypto/qat: fix digest in wireless auth case' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'build: mention -march in pkg-config description' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'doc: add dependency for PDF in contributing guide' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'net/mlx5: fix build for armv8' " Kevin Traynor
2019-02-07 13:26 ` [dpdk-stable] patch 'doc: clarify libnuma requirement for NUMA systems' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190207132614.20538-38-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=rmody@marvell.com \
    --cc=shshaikh@marvell.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).