Received: by 10.192.165.148 with SMTP id m20csp7052imm; Thu, 26 Apr 2018 14:52:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx48tcThSaz528cxUClqNfp9LgRL9kI/fBOlj6VlXznQJOSTsII/SAkNBz6a7jH7VBhYxu1zt X-Received: by 2002:a17:902:1665:: with SMTP id g92-v6mr35912179plg.195.1524779570508; Thu, 26 Apr 2018 14:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524779570; cv=none; d=google.com; s=arc-20160816; b=MO7CaZwWvjyxOxITpK7ip2jKOyhYkSbfVENnTOU642tqeo5LFCbaADpDAD79EskAmH FhVh3lYrO/ltghI2vXIqgPYN6SSOl3EvND8c/xj6Ag42xLIVqSYYEPckXXkt90CX8SZN 3sOZD4N325Wd5r+bzB9GTP+rEF7oREZFK6ExWXcvQlJrSH1PuiTYcQOrX9yaWlkx18Qj N6CMNR5cTltm+LMGT4qfS9GN7yrnelf0aG9G8FVfFKRyNzcDeDHg3qKCh5g2fquyRJqK FjQB35+XMiw3vr60ubgonIG2SY8ZJpb1G6zcxK89yMFmlEQqtwGdD27sheAH/F3x6/OU kyTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=CnZmo/BmvevGbPiIu3RM79DDbP4xu6wQtasGq0JEwpg=; b=0X1J3297bw3/LAs50lk9sVCUceeI5pyrANUBRWd1OFtRQuWxvNwcvVT23x4wQ//bK4 8TZM8f/se31A0PbO8uFgkfMyOtCf7gm0Wv6o31tUq3Gz7Wm3B37eRAfZSJw9ktztuGe/ Px4iIeCp9kmnUyP8bDsxyLMAp1i2G3GMVADvB3sf8NAdV5nM3lIrfqF9wKq8A9itDV9H xCR3YSE5bECpvj60rl7/lZR2+0EWsM5o8rah64vlyIlA2sP1qAg/9GCaZK/QiMnqwVcb dBD+jBUAgYHblnYLvjfETZK63kK41hsjt1zYxKLqS26IV92NoS4Dm9OaQgGcrH46sGxQ SQKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=UrGcl7lO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si4768450pgc.617.2018.04.26.14.52.36; Thu, 26 Apr 2018 14:52:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=UrGcl7lO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757010AbeDZVvY (ORCPT + 99 others); Thu, 26 Apr 2018 17:51:24 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:41815 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755325AbeDZVvV (ORCPT ); Thu, 26 Apr 2018 17:51:21 -0400 Received: by mail-lf0-f65.google.com with SMTP id o123-v6so30323249lfe.8 for ; Thu, 26 Apr 2018 14:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CnZmo/BmvevGbPiIu3RM79DDbP4xu6wQtasGq0JEwpg=; b=UrGcl7lO6qMAF2HzkCKrldpbFda36QjiRvvxvZaa3rx3ANi4bG7mi4aYO869La6M6S 4yPbmWMN5Y92IR74V2foNLBj/b23mvyXP5Z2aMxgNaSd0b70uxb82ECbOaJWlf1WBlzY q2M8tIqLxCgP7FkJ96uA6v2JcgovhG8lr+ngc+KYhpzqb3sa4MkUR4mmfAVTZ6XHTsUI oMajZ/+cxUiwnjRD4UxkxqWas7sAi4p+PkrrkQYHng5jdTsj9Zk0rtNNb6G2PGGi7DSw ASs/R+BAiNCscTBdOxB0MM5i5rj5Cr1yUYti34Xyj0ktMWSVj77KBFK+49c0x/PGV6qF Y3Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CnZmo/BmvevGbPiIu3RM79DDbP4xu6wQtasGq0JEwpg=; b=iEmc0Que1UPU52LjdJFlr1TNQ2bWdnY2z/4QE9blNpD8sbNVQhxPQMwhrjX48cGJLG OZhysR7HN6HP0VEfCRYYimwzdyyjQqG+cglD6mPY8taUlKrFK0RHLE/XGz8ggRdXYMpQ DEsztE+eQWLFsMxRVdJ1LfQrwh7ulcVgGVowJIKZuW9YP4s0raku/T0cmu5MF/fLJtyj S02va393ysJYGiUdJrtAs+Q5so8d+pfYJGS2bNJwR1zYrc01de+9UnJWVZu1B7ljHRIB b0651yoxG1sGrpWY6c1uaT7xJGViPHQnZP7g3jlWM5Y8QVhizkQHgSTbui07cdQetWUd mwhw== X-Gm-Message-State: ALQs6tDebXFCAOC4+M9j1RZpKkuYwkFyqri7OvK/9S5LYyVR408BMqOz Po2rjEXDISJx9L0P8iC2ycLzNDMBr1K09AfCUY6C+w== X-Received: by 10.46.147.204 with SMTP id p12mr2212471ljh.80.1524779480285; Thu, 26 Apr 2018 14:51:20 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:2947:0:0:0:0:0 with HTTP; Thu, 26 Apr 2018 14:50:59 -0700 (PDT) In-Reply-To: <1524775057-8012-1-git-send-email-qing.huang@oracle.com> References: <1524775057-8012-1-git-send-email-qing.huang@oracle.com> From: Saeed Mahameed Date: Thu, 26 Apr 2018 14:50:59 -0700 Message-ID: Subject: Re: [PATCH] net/mlx5: report persistent netdev stats across ifdown/ifup commands To: Qing Huang , Eran Ben Elisha Cc: linux-kernel , RDMA mailing list , Linux Netdev List , Leon Romanovsky , Matan Barak , Saeed Mahameed Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 26, 2018 at 1:37 PM, Qing Huang wrote: > Current stats collecting scheme in mlx5 driver is to periodically fetch > aggregated stats from all the active mlx5 software channels associated > with the device. However when a mlx5 interface is brought down(ifdown), > all the channels will be deactivated and closed. A new set of channels > will be created when next ifup command or a similar command is called. > Unfortunately the new channels will have all stats reset to 0. So you > lose the accumulated stats information. This behavior is different from > other netdev drivers including the mlx4 driver. In order to fix it, we > now save prior mlx5 software stats into netdev stats fields, so all the > accumulated stats will survive multiple runs of ifdown/ifup commands and > be shown correctly. > > Orabug: 27548610 > > Signed-off-by: Qing Huang > --- Hi Qing, I am adding Eran since he is currently working on a similar patch, He is also taking care of all cores/rings stats to make them persistent, so you won't have discrepancy between ethtool and ifconfig stats. I am ok with this patch, but this means Eran has to work his way around it. so we have two options: 1. Temporary accept this patch, and change it later with Eran's work. 2. Wait for Eran's work. I am ok with either one of them, please let me know. Thanks ! > drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 30 +++++++++++++++++++---- > 1 file changed, 25 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > index f1fe490..5d50e69 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > @@ -2621,6 +2621,23 @@ static void mlx5e_netdev_set_tcs(struct net_device *netdev) > netdev_set_tc_queue(netdev, tc, nch, 0); > } > > +static void mlx5e_netdev_save_stats(struct mlx5e_priv *priv) > +{ > + struct net_device *netdev = priv->netdev; > + > + netdev->stats.rx_packets += priv->stats.sw.rx_packets; > + netdev->stats.rx_bytes += priv->stats.sw.rx_bytes; > + netdev->stats.tx_packets += priv->stats.sw.tx_packets; > + netdev->stats.tx_bytes += priv->stats.sw.tx_bytes; > + netdev->stats.tx_dropped += priv->stats.sw.tx_queue_dropped; > + > + priv->stats.sw.rx_packets = 0; > + priv->stats.sw.rx_bytes = 0; > + priv->stats.sw.tx_packets = 0; > + priv->stats.sw.tx_bytes = 0; > + priv->stats.sw.tx_queue_dropped = 0; > +} > + This means that we are now explicitly clearing channels stats on ifconfig down or switch_channels. and now after ifconfing down, ethtool will always show 0, before this patch it didn't. Anyway update sw stats function will always override them with the new channels stats next time we load new channels. so it is not that big of a deal. > static void mlx5e_build_channels_tx_maps(struct mlx5e_priv *priv) > { > struct mlx5e_channel *c; > @@ -2691,6 +2708,7 @@ void mlx5e_switch_priv_channels(struct mlx5e_priv *priv, > netif_set_real_num_tx_queues(netdev, new_num_txqs); > > mlx5e_deactivate_priv_channels(priv); > + mlx5e_netdev_save_stats(priv); > mlx5e_close_channels(&priv->channels); > > priv->channels = *new_chs; > @@ -2770,6 +2788,7 @@ int mlx5e_close_locked(struct net_device *netdev) > > netif_carrier_off(priv->netdev); > mlx5e_deactivate_priv_channels(priv); > + mlx5e_netdev_save_stats(priv); > mlx5e_close_channels(&priv->channels); > > return 0; > @@ -3215,11 +3234,12 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, > stats->tx_packets = PPORT_802_3_GET(pstats, a_frames_transmitted_ok); > stats->tx_bytes = PPORT_802_3_GET(pstats, a_octets_transmitted_ok); > } else { > - stats->rx_packets = sstats->rx_packets; > - stats->rx_bytes = sstats->rx_bytes; > - stats->tx_packets = sstats->tx_packets; > - stats->tx_bytes = sstats->tx_bytes; > - stats->tx_dropped = sstats->tx_queue_dropped; > + stats->rx_packets = sstats->rx_packets + dev->stats.rx_packets; > + stats->rx_bytes = sstats->rx_bytes + dev->stats.rx_bytes; > + stats->tx_packets = sstats->tx_packets + dev->stats.tx_packets; > + stats->tx_bytes = sstats->tx_bytes + dev->stats.tx_bytes; > + stats->tx_dropped = sstats->tx_queue_dropped + > + dev->stats.tx_dropped; > } > > stats->rx_dropped = priv->stats.qcnt.rx_out_of_buffer; > -- > 1.8.3.1 >