From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 7C3555B1A; Tue, 10 Jul 2018 04:34:55 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jul 2018 19:34:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,332,1526367600"; d="scan'208";a="214697006" Received: from dpdk-xiaoyun3.sh.intel.com ([10.67.118.225]) by orsmga004.jf.intel.com with ESMTP; 09 Jul 2018 19:34:53 -0700 From: Xiaoyun Li To: wenzhuo.lu@intel.com Cc: dev@dpdk.org, Xiaoyun Li , stable@dpdk.org Date: Tue, 10 Jul 2018 10:28:29 +0800 Message-Id: <1531189709-312497-1-git-send-email-xiaoyun.li@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] app/testpmd: fix little perf drop with XL710 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2018 02:34:57 -0000 There is about 1.8M perf drop with XL710. 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") Cc: stable@dpdk.org Signed-off-by: Xiaoyun Li --- app/test-pmd/testpmd.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 24c1998..0600806 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; } } @@ -2196,16 +2199,31 @@ static void eth_dev_event_callback(char *device_name, enum rte_dev_event_type type, __rte_unused void *arg) { + portid_t port_id; + uint16_t i; + if (type >= RTE_DEV_EVENT_MAX) { fprintf(stderr, "%s called upon invalid event %d\n", __func__, type); fflush(stderr); } + rte_eth_dev_get_port_by_name(device_name, &port_id); + switch (type) { case RTE_DEV_EVENT_REMOVE: RTE_LOG(ERR, EAL, "The device: %s has been removed!\n", device_name); + + 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; + nb_ports--; + break; + } + } + /* TODO: After finish failure handle, begin to stop * packet forward, stop port, close port, detach port. */ @@ -2213,6 +2231,10 @@ eth_dev_event_callback(char *device_name, enum rte_dev_event_type type, case RTE_DEV_EVENT_ADD: RTE_LOG(ERR, EAL, "The device: %s has been added!\n", device_name); + + ports_ids[nb_ports] = port_id; + nb_ports++; + /* TODO: After finish kernel driver binding, * begin to attach port. */ @@ -2652,6 +2674,7 @@ main(int argc, char** argv) { int diag; portid_t port_id; + uint16_t count; int ret; signal(SIGINT, signal_handler); @@ -2671,7 +2694,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.7.4