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 CE2A8A0C4D; Fri, 13 Aug 2021 10:06:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7E3E40DF4; Fri, 13 Aug 2021 10:06:12 +0200 (CEST) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id 3076740140 for ; Fri, 13 Aug 2021 10:06:11 +0200 (CEST) Received: by mail-pj1-f51.google.com with SMTP id n13-20020a17090a4e0d00b0017946980d8dso589690pjh.5 for ; Fri, 13 Aug 2021 01:06:11 -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=6GemkUaa0vlWs1s4rI5ZT/10n8WuoFezQYnYqnEzzJo=; b=azXEJ3F/4fhPC4e+Cw98q/LNnub3arNJA+rMcuFL1KQQ8LuzQPC61Svmhbxo4Bj4t5 w68WuoVavC45nC6+xN1KNH8VJ/DAZLQ1tGOURW9PgcovNHTi7kwGzIa4qUmN+4T0Gdj/ HmvBSdxlRiEihQPzZ6MllX+lii0MKKRvZi1uc8SIvZfR17yoERL2BuXopU9Kj3mUTwPe uWX2GKoOnWD9/iZ2pmtxCeaoOtsFDfhmEKNBQXGfOc14TIhV4mQqLXZD8hIaz/vrJGmJ 9Zln8ZJ6y65hrZyzots4f96EfRlHkS3+tEc6HcOLpBoaKrTT7/uxy7PrFIuVLAvTaJ3c uNaw== 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=6GemkUaa0vlWs1s4rI5ZT/10n8WuoFezQYnYqnEzzJo=; b=nbrY7g1WZ8Jz7Afy3W2IXcZs7YNhJTB2rhFXP/6ksqrrIX6HByoB2tx2WmqQpTOgdA trGoXw4qE/VfeUPJVKT34gwCheqoWxp6I4WsWQiKkPDNMV9AIBzF98FNDJsyl4QCi8lU M7cJUQgjOBfTU90y2EYUGRcCOvGYcP0OcxTUy9ym8OwtyF/7f/JwUx105r9Plf/laQ60 Xwm4W9L2T1cM1AvkmEfADLZzWJ0kdTdCQZyRDcGcK2Jlj0xa+SW5+X7lJF5426FAYT6t 0JvB1TGp9e8vGLMD073p13ou4k3GNrLEz+TDtArFlxEMV/jEHcWXUGd+6df8xxHqznuF q5MQ== X-Gm-Message-State: AOAM533UsAJCSnBEjiU5MfCSKzC8+ScvjXP7XN/LBE3lq61JsOeTWNKY qPFxKPdtcVR3G3OYgPq7vitZs4IwHO3+Vg== X-Google-Smtp-Source: ABdhPJzzxDMNhklRdR2DOEfFK1L5RLfh4DYygG38IixDKtY6awoQP4IlafHvsKLHaMPBb1KDHfSDrQ== X-Received: by 2002:a63:5901:: with SMTP id n1mr1254494pgb.378.1628841970140; Fri, 13 Aug 2021 01:06:10 -0700 (PDT) Received: from C02D70YZMD6R.bytedance.net ([139.177.225.227]) by smtp.gmail.com with ESMTPSA id 17sm1118192pjd.3.2021.08.13.01.06.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Aug 2021 01:06:09 -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: Fri, 13 Aug 2021 16:05:48 +0800 Message-Id: <20210813080548.38637-5-wangzhihong.wzh@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210813080548.38637-1-wangzhihong.wzh@bytedance.com> References: <20210809062548.30187-1-wangzhihong.wzh@bytedance.com> <20210813080548.38637-1-wangzhihong.wzh@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 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 Acked-by: Xiaoyun Li --- v5: replace modulo operation to improve performance v4: use loop local variable to improve performance app/test-pmd/flowgen.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index 229794ee9c..9348618d0f 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -53,6 +53,8 @@ static struct rte_ether_addr cfg_ether_dst = #define IP_DEFTTL 64 /* from RFC 1340. */ +RTE_DEFINE_PER_LCORE(int, _next_flow); + /* * Multi-flow generation mode. * @@ -80,7 +82,7 @@ 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; + int next_flow = RTE_PER_LCORE(_next_flow); get_start_cycles(&start_tsc); @@ -163,7 +165,8 @@ pkt_burst_flow_gen(struct fwd_stream *fs) } pkts_burst[nb_pkt] = pkt; - next_flow = (next_flow + 1) % cfg_n_flows; + if (++next_flow >= (int)cfg_n_flows) + next_flow = 0; } nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); @@ -193,6 +196,8 @@ pkt_burst_flow_gen(struct fwd_stream *fs) } while (++nb_tx < nb_pkt); } + RTE_PER_LCORE(_next_flow) = next_flow; + get_end_cycles(fs, start_tsc); } -- 2.11.0