From patchwork Mon Feb 20 12:53:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciara Loftus X-Patchwork-Id: 729970 X-Patchwork-Delegate: dlu998@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vRk7m4zqCz9ryk for ; Mon, 20 Feb 2017 23:53:08 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3B357B37; Mon, 20 Feb 2017 12:53:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5BE7CA48 for ; Mon, 20 Feb 2017 12:53:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A31EE148 for ; Mon, 20 Feb 2017 12:53:05 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2017 04:53:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,186,1484035200"; d="scan'208";a="60436079" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga004.jf.intel.com with ESMTP; 20 Feb 2017 04:53:03 -0800 From: Ciara Loftus To: dev@openvswitch.org Date: Mon, 20 Feb 2017 12:53:00 +0000 Message-Id: <1487595180-5239-1-git-send-email-ciara.loftus@intel.com> X-Mailer: git-send-email 1.7.0.7 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: jan.scheurich@web.de Subject: [ovs-dev] [PATCH v4] dpif-netdev: Change definitions of 'idle' & 'processing' cycles X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Instead of counting all polling cycles as processing cycles, only count the cycles where packets were received from the polling. Signed-off-by: Georg Schmuecking Signed-off-by: Ciara Loftus Co-authored-by: Georg Schmuecking Acked-by: Kevin Traynor Acked-by: Ian Stokes Tested-by: Ian Stokes Acked-by: Darrell Ball --- v4: - Move call to cycles_count_intermediate in order to collect more accurate statistics. v3: - Updated acks & co-author tags - Removed unnecessary PMD_CYCLES_POLLING counter type - Explain terms 'idle' and 'processing' cycles in vswitchd/ovs-vswitchd.8.in v2: - Rebase lib/dpif-netdev.c | 58 +++++++++++++++++++++++++++++++++++----------- vswitchd/ovs-vswitchd.8.in | 5 +++- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 30907b7..a80ffb2 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -279,8 +279,9 @@ enum dp_stat_type { }; enum pmd_cycles_counter_type { - PMD_CYCLES_POLLING, /* Cycles spent polling NICs. */ - PMD_CYCLES_PROCESSING, /* Cycles spent processing packets */ + PMD_CYCLES_IDLE, /* Cycles spent idle or unsuccessful polling */ + PMD_CYCLES_PROCESSING, /* Cycles spent successfully polling and + * processing polled packets */ PMD_N_CYCLES }; @@ -755,10 +756,10 @@ pmd_info_show_stats(struct ds *reply, } ds_put_format(reply, - "\tpolling cycles:%"PRIu64" (%.02f%%)\n" + "\tidle cycles:%"PRIu64" (%.02f%%)\n" "\tprocessing cycles:%"PRIu64" (%.02f%%)\n", - cycles[PMD_CYCLES_POLLING], - cycles[PMD_CYCLES_POLLING] / (double)total_cycles * 100, + cycles[PMD_CYCLES_IDLE], + cycles[PMD_CYCLES_IDLE] / (double)total_cycles * 100, cycles[PMD_CYCLES_PROCESSING], cycles[PMD_CYCLES_PROCESSING] / (double)total_cycles * 100); @@ -2953,30 +2954,43 @@ cycles_count_end(struct dp_netdev_pmd_thread *pmd, non_atomic_ullong_add(&pmd->cycles.n[type], interval); } -static void +/* Calculate the intermediate cycle result and add to the counter 'type' */ +static inline void +cycles_count_intermediate(struct dp_netdev_pmd_thread *pmd, + enum pmd_cycles_counter_type type) + OVS_NO_THREAD_SAFETY_ANALYSIS +{ + unsigned long long new_cycles = cycles_counter(); + unsigned long long interval = new_cycles - pmd->last_cycles; + pmd->last_cycles = new_cycles; + + non_atomic_ullong_add(&pmd->cycles.n[type], interval); +} + +static int dp_netdev_process_rxq_port(struct dp_netdev_pmd_thread *pmd, struct netdev_rxq *rx, odp_port_t port_no) { struct dp_packet_batch batch; int error; + int batch_cnt = 0; dp_packet_batch_init(&batch); - cycles_count_start(pmd); error = netdev_rxq_recv(rx, &batch); - cycles_count_end(pmd, PMD_CYCLES_POLLING); if (!error) { *recirc_depth_get() = 0; - cycles_count_start(pmd); + batch_cnt = batch.count; dp_netdev_input(pmd, &batch, port_no); - cycles_count_end(pmd, PMD_CYCLES_PROCESSING); } else if (error != EAGAIN && error != EOPNOTSUPP) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); VLOG_ERR_RL(&rl, "error receiving data from %s: %s", netdev_rxq_get_name(rx), ovs_strerror(error)); } + + return batch_cnt; } static struct tx_port * @@ -3438,21 +3452,29 @@ dpif_netdev_run(struct dpif *dpif) struct dp_netdev *dp = get_dp_netdev(dpif); struct dp_netdev_pmd_thread *non_pmd; uint64_t new_tnl_seq; + int process_packets = 0; ovs_mutex_lock(&dp->port_mutex); non_pmd = dp_netdev_get_pmd(dp, NON_PMD_CORE_ID); if (non_pmd) { ovs_mutex_lock(&dp->non_pmd_mutex); + cycles_count_start(non_pmd); HMAP_FOR_EACH (port, node, &dp->ports) { if (!netdev_is_pmd(port->netdev)) { int i; for (i = 0; i < port->n_rxq; i++) { - dp_netdev_process_rxq_port(non_pmd, port->rxqs[i].rx, - port->port_no); + process_packets = + dp_netdev_process_rxq_port(non_pmd, + port->rxqs[i].rx, + port->port_no); + cycles_count_intermediate(non_pmd, process_packets ? + PMD_CYCLES_PROCESSING + : PMD_CYCLES_IDLE); } } } + cycles_count_end(non_pmd, PMD_CYCLES_IDLE); dpif_netdev_xps_revalidate_pmd(non_pmd, time_msec(), false); ovs_mutex_unlock(&dp->non_pmd_mutex); @@ -3577,6 +3599,7 @@ pmd_thread_main(void *f_) bool exiting; int poll_cnt; int i; + int process_packets = 0; poll_list = NULL; @@ -3603,10 +3626,15 @@ reload: lc = UINT_MAX; } + cycles_count_start(pmd); for (;;) { for (i = 0; i < poll_cnt; i++) { - dp_netdev_process_rxq_port(pmd, poll_list[i].rx, - poll_list[i].port_no); + process_packets = + dp_netdev_process_rxq_port(pmd, poll_list[i].rx, + poll_list[i].port_no); + cycles_count_intermediate(pmd, + process_packets ? PMD_CYCLES_PROCESSING + : PMD_CYCLES_IDLE); } if (lc++ > 1024) { @@ -3627,6 +3655,8 @@ reload: } } + cycles_count_end(pmd, PMD_CYCLES_IDLE); + poll_cnt = pmd_load_queues_and_ports(pmd, &poll_list); exiting = latch_is_set(&pmd->exit_latch); /* Signal here to make sure the pmd finishes diff --git a/vswitchd/ovs-vswitchd.8.in b/vswitchd/ovs-vswitchd.8.in index fc19f3b..2e6e684 100644 --- a/vswitchd/ovs-vswitchd.8.in +++ b/vswitchd/ovs-vswitchd.8.in @@ -253,7 +253,10 @@ The sum of ``emc hits'', ``masked hits'' and ``miss'' is the number of packets received by the datapath. Cycles are counted using the TSC or similar facilities (when available on the platform). To reset these counters use \fBdpif-netdev/pmd-stats-clear\fR. The duration of one cycle depends on the -measuring infrastructure. +measuring infrastructure. ``idle cycles'' refers to cycles spent polling +devices but not receiving any packets. ``processing cycles'' refers to cycles +spent polling devices and sucessfully receiving packets, plus the cycles +spent processing said packets. .IP "\fBdpif-netdev/pmd-stats-clear\fR [\fIdp\fR]" Resets to zero the per pmd thread performance numbers shown by the \fBdpif-netdev/pmd-stats-show\fR command. It will NOT reset datapath or