DPDK patches and discussions
 help / color / mirror / Atom feed
From: Zhihong Wang <wangzhihong.wzh@bytedance.com>
To: dev@dpdk.org, ferruh.yigit@intel.com, xiaoyun.li@intel.com,
	aman.deep.singh@intel.com, irusskikh@marvell.com,
	cchemparathy@tilera.com
Cc: Zhihong Wang <wangzhihong.wzh@bytedance.com>
Subject: [dpdk-dev] [PATCH v3 4/4] app/testpmd: use per-core variable in flowgen
Date: Thu, 12 Aug 2021 19:11:05 +0800	[thread overview]
Message-ID: <20210812111105.54307-5-wangzhihong.wzh@bytedance.com> (raw)
In-Reply-To: <20210812111105.54307-1-wangzhihong.wzh@bytedance.com>

Use per-core variable for flow indexing to solve cache contention in
multi-core scenarios.

Signed-off-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
---
 app/test-pmd/flowgen.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c
index 229794ee9c..fc9dae4ab3 100644
--- a/app/test-pmd/flowgen.c
+++ b/app/test-pmd/flowgen.c
@@ -51,6 +51,8 @@ static struct rte_ether_addr cfg_ether_src =
 static struct rte_ether_addr cfg_ether_dst =
 	{{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x01 }};
 
+RTE_DEFINE_PER_LCORE(int, _next_flow);
+
 #define IP_DEFTTL  64   /* from RFC 1340. */
 
 /*
@@ -80,7 +82,6 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
 	uint32_t retry;
 	uint64_t tx_offloads;
 	uint64_t start_tsc = 0;
-	static int next_flow = 0;
 
 	get_start_cycles(&start_tsc);
 
@@ -136,7 +137,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
 			ip_hdr->packet_id	= 0;
 			ip_hdr->src_addr	= rte_cpu_to_be_32(cfg_ip_src);
 			ip_hdr->dst_addr	= rte_cpu_to_be_32(cfg_ip_dst +
-								   next_flow);
+					RTE_PER_LCORE(_next_flow));
 			ip_hdr->total_length	= RTE_CPU_TO_BE_16(pkt_size -
 								   sizeof(*eth_hdr));
 			ip_hdr->hdr_checksum	= rte_ipv4_cksum(ip_hdr);
@@ -163,7 +164,8 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
 		}
 		pkts_burst[nb_pkt] = pkt;
 
-		next_flow = (next_flow + 1) % cfg_n_flows;
+		RTE_PER_LCORE(_next_flow) = (RTE_PER_LCORE(_next_flow) + 1) %
+				cfg_n_flows;
 	}
 
 	nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt);
@@ -183,9 +185,9 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
 	inc_tx_burst_stats(fs, nb_tx);
 	if (unlikely(nb_tx < nb_pkt)) {
 		/* Back out the flow counter. */
-		next_flow -= (nb_pkt - nb_tx);
-		while (next_flow < 0)
-			next_flow += cfg_n_flows;
+		RTE_PER_LCORE(_next_flow) -= (nb_pkt - nb_tx);
+		while (RTE_PER_LCORE(_next_flow) < 0)
+			RTE_PER_LCORE(_next_flow) += cfg_n_flows;
 
 		fs->fwd_dropped += nb_pkt - nb_tx;
 		do {
-- 
2.11.0


  parent reply	other threads:[~2021-08-12 11:11 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09  6:25 [dpdk-dev] [PATCH] app/testpmd: flowgen support ip and udp fields Zhihong Wang
2021-08-09  6:52 ` [dpdk-dev] [PATCH v2] " Zhihong Wang
2021-08-09 12:21   ` Singh, Aman Deep
2021-08-10  7:30     ` [dpdk-dev] [External] " 王志宏
2021-08-09 15:18   ` [dpdk-dev] " Ferruh Yigit
2021-08-10  7:57     ` [dpdk-dev] [External] " 王志宏
2021-08-10  9:12       ` Ferruh Yigit
2021-08-11  2:48         ` 王志宏
2021-08-11 10:31           ` Ferruh Yigit
2021-08-12  9:32             ` 王志宏
2021-08-12 11:11 ` [dpdk-dev] [PATCH v3 0/4] app/testpmd: flowgen fixes and improvements Zhihong Wang
2021-08-12 11:11   ` [dpdk-dev] [PATCH v3 1/4] app/testpmd: fix tx retry in flowgen Zhihong Wang
2021-08-12 11:11   ` [dpdk-dev] [PATCH v3 2/4] app/testpmd: use rte_ipv4_cksum " Zhihong Wang
2021-08-12 11:11   ` [dpdk-dev] [PATCH v3 3/4] app/testpmd: record rx_burst and fwd_dropped " Zhihong Wang
2021-08-12 11:11   ` Zhihong Wang [this message]
2021-08-12 13:18 ` [dpdk-dev] [PATCH v4 0/4] app/testpmd: flowgen fixes and improvements Zhihong Wang
2021-08-12 13:18   ` [dpdk-dev] [PATCH v4 1/4] app/testpmd: fix tx retry in flowgen Zhihong Wang
2021-08-13  1:33     ` Li, Xiaoyun
2021-08-13  2:27       ` [dpdk-dev] [External] " 王志宏
2021-08-12 13:18   ` [dpdk-dev] [PATCH v4 2/4] app/testpmd: use rte_ipv4_cksum " Zhihong Wang
2021-08-13  1:37     ` Li, Xiaoyun
2021-08-12 13:19   ` [dpdk-dev] [PATCH v4 3/4] app/testpmd: record rx_burst and fwd_dropped " Zhihong Wang
2021-08-13  1:44     ` Li, Xiaoyun
2021-08-12 13:19   ` [dpdk-dev] [PATCH v4 4/4] app/testpmd: use per-core variable " Zhihong Wang
2021-08-13  1:56     ` Li, Xiaoyun
2021-08-13  2:35       ` [dpdk-dev] [External] " 王志宏
2021-08-13  8:05 ` [dpdk-dev] [PATCH v5 0/4] app/testpmd: flowgen fixes and improvements Zhihong Wang
2021-08-13  8:05   ` [dpdk-dev] [PATCH v5 1/4] app/testpmd: fix tx retry in flowgen Zhihong Wang
2021-08-13  8:05   ` [dpdk-dev] [PATCH v5 2/4] app/testpmd: use rte_ipv4_cksum " Zhihong Wang
2021-08-13  8:05   ` [dpdk-dev] [PATCH v5 3/4] app/testpmd: record rx_burst and fwd_dropped " Zhihong Wang
2021-08-13  8:05   ` [dpdk-dev] [PATCH v5 4/4] app/testpmd: use per-core variable " Zhihong Wang
2021-08-24 17:21   ` [dpdk-dev] [PATCH v5 0/4] app/testpmd: flowgen fixes and improvements Ferruh Yigit

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=20210812111105.54307-5-wangzhihong.wzh@bytedance.com \
    --to=wangzhihong.wzh@bytedance.com \
    --cc=aman.deep.singh@intel.com \
    --cc=cchemparathy@tilera.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=irusskikh@marvell.com \
    --cc=xiaoyun.li@intel.com \
    /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).