Received: by 10.192.165.148 with SMTP id m20csp45142imm; Thu, 26 Apr 2018 15:39:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+KEOFsRUavCks1g/O+sdZU0jaAoDuNhC00QHzmXg/V29gp1TEjCoUpM3wEOj546PAtnJHg X-Received: by 10.98.0.194 with SMTP id 185mr30453323pfa.238.1524782395942; Thu, 26 Apr 2018 15:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524782395; cv=none; d=google.com; s=arc-20160816; b=YkEb0HU5krIX87zhF3ht4EXF7N90KkHvDUpCSPwoEJikf08YspvbY67lDADtFJdBSD RczP8Hf60jUl56djLnWjFDatz8zVkLFHsORt9PZsF6grf+XMF45XPwLIjO7PjKY/hVvl hS2kdftLU5Gs6mrWtULjFEzI/M00znhlIPh15BCYhMSxEdv8RXyAmDTrmKsC18AlXOR6 /qrxC7BHWRbQs2Psd5jx3zbyIoLzKBxvLVhgA+pvVdBqZo801pdoTzRWihKZ1UeLTTEt 4EQ7qtWKC59pnYzCwU9cRJQ2X8m1T5hI91c6UTuDxAwIJcbpf3gsLcyRzB2XcpCy9vzK S7Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=S0kBo5zPNVNzRYD/z8tQBxIGjIeUeXMnZ3PTUPmggSY=; b=e4KI/kFXYakqGrN052rV+Vtqbnsa4p1opWV5GLONWHv+oApfg9F0O0njr3hlrm2RfR 9+l5oiFzAjEzYKEOkLE2MLH2lcHQZ/mOtyz8CUtCVNoIb9Il/iRkQuRwKGIxC2TdPzvL aeh6ptIngoMnQshDh9/pe7ktgIIpFGgiF/n3iiR1k/ACIFtIuH876g6brgWHjZY7TKzr dmv+jg98nqmNX8oWW213/j53a3hUoMdi0aZ4RtaWT4+EZxpa1DB2RKD9n1XZSNYuKewO S3wKtqAwB9ai1wJs9K4zUmHg4L24/qIzzj3Pf6u5FdhxbtnIQCu2wmsniN8BxViBHlH4 Lr8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=fzAZtu8p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3-v6si21187115plo.437.2018.04.26.15.39.41; Thu, 26 Apr 2018 15:39:55 -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=@oracle.com header.s=corp-2017-10-26 header.b=fzAZtu8p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757335AbeDZWh7 (ORCPT + 99 others); Thu, 26 Apr 2018 18:37:59 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:59092 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754128AbeDZWhm (ORCPT ); Thu, 26 Apr 2018 18:37:42 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3QMW1dX148971; Thu, 26 Apr 2018 22:37:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=S0kBo5zPNVNzRYD/z8tQBxIGjIeUeXMnZ3PTUPmggSY=; b=fzAZtu8pgM8xIaIxBSsaGXXQmcDkt/LznIZYk0IKVrGc+bUdYgMXSkJ4H/6aqIMssXK5 Vfb6eJuHSYDAPbV+t9i41G1ffS+aNWV9iPmmkOXLQD6/EXTKjvIp9BEJ7taVQIanunb6 /szVA5x2hjzBtnCnXDavVV0Giwesd5mVyEVFsXs1RZST8YaP8m0vkLb+3F8tAlyM8iI7 ydw+7nGmIddK9VpS+eZEwV6/sOFJ706+Xh+VY6rBV2HTSQBUFRZCj5cbDktElEQPraXy 8ghMcmznhImilvIMYGt8/2zz/fjKcmIBIptXuA1S0/l8rvJCEMOB8GnhI6ViQiuuVB2M 3Q== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2hfvrc587k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Apr 2018 22:37:35 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3QMbYir012015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Apr 2018 22:37:34 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w3QMbXEv008773; Thu, 26 Apr 2018 22:37:33 GMT Received: from [10.132.91.100] (/10.132.91.100) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 26 Apr 2018 15:37:33 -0700 Subject: Re: [PATCH] net/mlx5: report persistent netdev stats across ifdown/ifup commands To: Saeed Mahameed , Eran Ben Elisha Cc: linux-kernel , RDMA mailing list , Linux Netdev List , Leon Romanovsky , Matan Barak , Saeed Mahameed References: <1524775057-8012-1-git-send-email-qing.huang@oracle.com> From: Qing Huang Message-ID: <5cd29779-fc70-930a-7060-ee3332c15558@oracle.com> Date: Thu, 26 Apr 2018 15:37:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8875 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804260209 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/26/2018 02:50 PM, Saeed Mahameed wrote: > 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 ! Hi Saeed, Any idea on rough ETA of Eran's stats work to be in upstream? If it will be available soon, I think we can wait a bit. If it will take a while to redesign the whole stats scheme (for both ethtool and ifconfig), maybe we can go with this incremental fix first? 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 >>