From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by dpdk.org (Postfix) with ESMTP id E53CB5B2C for ; Mon, 30 Jul 2018 18:19:29 +0200 (CEST) Received: from 1.general.paelzer.uk.vpn ([10.172.196.172] helo=lap.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkAsA-00009D-26; Mon, 30 Jul 2018 16:18:14 +0000 From: Christian Ehrhardt To: Xiaoyun Li Cc: Wenzhuo Lu , dpdk stable Date: Mon, 30 Jul 2018 18:13:09 +0200 Message-Id: <20180730161342.16566-144-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730161342.16566-1-christian.ehrhardt@canonical.com> References: <20180730161342.16566-1-christian.ehrhardt@canonical.com> Subject: [dpdk-stable] patch 'app/testpmd: fix little performance drop' has been queued to stable release 18.05.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: Mon, 30 Jul 2018 16:19:30 -0000 Hi, FYI, your patch has been queued to stable release 18.05.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 08/01/18. So please shout if anyone has objections. Thanks. Christian Ehrhardt --- >>From 9aa29ee0cff7636027c717745b1d43abd85a8b0c Mon Sep 17 00:00:00 2001 From: Xiaoyun Li Date: Thu, 12 Jul 2018 15:55:46 +0800 Subject: [PATCH] app/testpmd: fix little performance drop [ upstream commit 4918a35756e505efac912c3fd23473b0d3183e85 ] There is about 3% perf drop. And it is because of a bitrate calculation in the datapath. So improve it by maintaining an array of port indexes in testpmd, which is updated with ethdev events. Fixes: 8728ccf37615 ("fix ethdev ports enumeration") Signed-off-by: Xiaoyun Li Acked-by: Wenzhuo Lu --- app/test-pmd/testpmd.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 63c2a5aca..acdce2a01 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -127,6 +127,8 @@ portid_t nb_ports; /**< Number of probed ethernet ports. */ struct fwd_lcore **fwd_lcores; /**< For all probed logical cores. */ lcoreid_t nb_lcores; /**< Number of probed logical cores. */ +portid_t ports_ids[RTE_MAX_ETHPORTS]; /**< Store all port ids. */ + /* * Test Forwarding Configuration. * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores @@ -1148,8 +1150,9 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) uint64_t tics_per_1sec; uint64_t tics_datum; uint64_t tics_current; - uint16_t idx_port; + uint16_t i, cnt_ports; + cnt_ports = nb_ports; tics_datum = rte_rdtsc(); tics_per_1sec = rte_get_timer_hz(); #endif @@ -1164,9 +1167,9 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) tics_current = rte_rdtsc(); if (tics_current - tics_datum >= tics_per_1sec) { /* Periodic bitrate calculation */ - RTE_ETH_FOREACH_DEV(idx_port) + for (i = 0; i < cnt_ports; i++) rte_stats_bitrate_calc(bitrate_data, - idx_port); + ports_ids[i]); tics_datum = tics_current; } } @@ -1971,6 +1974,7 @@ attach_port(char *identifier) reconfig(pi, socket_id); rte_eth_promiscuous_enable(pi); + ports_ids[nb_ports] = pi; nb_ports = rte_eth_dev_count_avail(); ports[pi].port_status = RTE_PORT_STOPPED; @@ -1985,6 +1989,7 @@ void detach_port(portid_t port_id) { char name[RTE_ETH_NAME_MAX_LEN]; + uint16_t i; printf("Detaching a port...\n"); @@ -2001,6 +2006,13 @@ detach_port(portid_t port_id) return; } + for (i = 0; i < nb_ports; i++) { + if (ports_ids[i] == port_id) { + ports_ids[i] = ports_ids[nb_ports-1]; + ports_ids[nb_ports-1] = 0; + break; + } + } nb_ports = rte_eth_dev_count_avail(); update_fwd_ports(RTE_MAX_ETHPORTS); @@ -2652,6 +2664,7 @@ main(int argc, char** argv) { int diag; portid_t port_id; + uint16_t count; int ret; signal(SIGINT, signal_handler); @@ -2671,7 +2684,12 @@ main(int argc, char** argv) rte_pdump_init(NULL); #endif - nb_ports = (portid_t) rte_eth_dev_count_avail(); + count = 0; + RTE_ETH_FOREACH_DEV(port_id) { + ports_ids[count] = port_id; + count++; + } + nb_ports = (portid_t) count; if (nb_ports == 0) TESTPMD_LOG(WARNING, "No probed ethernet devices\n"); -- 2.17.1