From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3DEA6A0C56; Thu, 12 Aug 2021 13:11:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABE9F4120E; Thu, 12 Aug 2021 13:11:27 +0200 (CEST) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id BB3AF41201 for ; Thu, 12 Aug 2021 13:11:26 +0200 (CEST) Received: by mail-pj1-f54.google.com with SMTP id w13-20020a17090aea0db029017897a5f7bcso10122365pjy.5 for ; Thu, 12 Aug 2021 04:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hY6ouGw8T+WDX0exTmT6jQZ3RtudDl+oYJeoGPtVz0Y=; b=O6Rhz9fL+KB1LRif2IHdU8u3UI+hfkDd3UtuEVrjMMIAVSoUbOZwG3GRVGrauR0O/U XcEwBqZW/U+bCRximqpJSLh/Wel5UqQW8wgiMW9ttAKDZzTQ9Ph1FMG/ZLOiZ8ctM7vy APWXvhNMccHSk1RV9vDTtkOzFMebgjnwVGvM7U6oRyRRtwOIoC2HiI0c/yFpoyFKbUZY Aknjk+sYcVy1OGCouvrvaH8vxkfCYRtJiINWhIlYUy6A3hcM67fbuLqjNlROUAmkvY68 kcIlhLd+aHryN/ZOlB1o/v7tMGKuGnVBh9MyuBfxrKHK/ppwz39teKj9k5PK8J78zFbb REEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hY6ouGw8T+WDX0exTmT6jQZ3RtudDl+oYJeoGPtVz0Y=; b=Qgurfrix8oTLK7oub/fHIdKNvX+A6FdhPJvWYMxvGeuTvh4bkHOBgBwHnILCuRUvHd QsrwPRtbLMW8mZO6YDpbe1Ez15Oo20k228y9n1k6pUihAC8Ja/kDkJLH6eHHOJdCIPFG PzM06gIp/ZeNl+Fr4vMMJX4KnczbkeWpkzRhTVGIegplfMTdihbKwo4kMBhupVpsFDl3 1tQ6wJEAs4cXw6IenqFaLwzNOC9TXwMEKgxzJgGHcDJktacryzk7oeJJByhMT6D2gmlM nb6I2E7I+A2V7y8IP6kejXEurg+9tXvNZ56l4Df4XkQG+4Q4k9NtZY631ZlPRtnzOWrS cAnw== X-Gm-Message-State: AOAM533KH12FtweRuxdEX1mPamM4py+jlRtHc2ejqKrWeTMBvXF68tvF j6tkWu4RZ2KM6+Nmq6yBNZtIGKotVzQy7A== X-Google-Smtp-Source: ABdhPJxh3zxOOVzoUrMXUF0lsXvSM8dA4hBY3Vzom/iLfqiHJvvzQKAPD2y9Ch9liU55NtrwMr6iog== X-Received: by 2002:a17:902:d512:b029:12d:4338:531a with SMTP id b18-20020a170902d512b029012d4338531amr3188751plg.52.1628766685728; Thu, 12 Aug 2021 04:11:25 -0700 (PDT) Received: from C02D70YZMD6R.bytedance.net ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id l126sm3291830pgl.14.2021.08.12.04.11.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Aug 2021 04:11:25 -0700 (PDT) From: Zhihong Wang 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 Date: Thu, 12 Aug 2021 19:11:05 +0800 Message-Id: <20210812111105.54307-5-wangzhihong.wzh@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210812111105.54307-1-wangzhihong.wzh@bytedance.com> References: <20210809062548.30187-1-wangzhihong.wzh@bytedance.com> <20210812111105.54307-1-wangzhihong.wzh@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 4/4] app/testpmd: use per-core variable in flowgen X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use per-core variable for flow indexing to solve cache contention in multi-core scenarios. Signed-off-by: Zhihong Wang --- 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