Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2592960lqp; Mon, 25 Mar 2024 03:55:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWa7+JrUlnJv6riRoa8Qylll1rVkWS+aRZYEdgc5OgCZ5HG5SQyaJ+kAU8To+DLP6uzErBrtRuLar7X1my0qbPNhv5iiU7d4sgYpTGrMg== X-Google-Smtp-Source: AGHT+IGSkwQgeiXTMbtPSxMyJbtwOw3pFCIHEORtL9y12nhtLnWSdyypimXKqad7eGgSHi6eYzjh X-Received: by 2002:a05:622a:5488:b0:431:5c25:8105 with SMTP id ep8-20020a05622a548800b004315c258105mr1589891qtb.16.1711364129377; Mon, 25 Mar 2024 03:55:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711364129; cv=pass; d=google.com; s=arc-20160816; b=d8FgxPiQzT8FElbx61M6YbUCk/vVwswsg/RP1kY8Cnrcssr4wZWduvflYcT6pHXf8M Is6RE88qPRpzjUaQTTA6EKfRZPTtJXTU4LylXj9F25l3jbLEFg1KQcFwTgXv35a2Zsa6 FXG4niabxYwxzjxB37c/CJwkO6omMR2i4ZDNH4s7PqR7A8jwgPEBl9Q1RxNJs2Z8w3O0 6IxR6QrwNM61LNj1Vg/kBF41NJWAqI2CUTaGEbvv5xTVMRCx/cLIclwDlvAE8Ix/KiGq MSgGEqHuqAJKwl7m97Q7wNePhZR8gP9iy8VDkg3gPCFfKWCZMaWRw4dNInD2e1R3eG6e 7e/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wqSPPraEhjLQYcpCLZoDg2mn04SfcS4duqY73ksuKhA=; fh=Qg6plfIHVSI3n+l+rdTQVIX6c8zp22N4zlgFtmZ/Gig=; b=XJGaToSz361L9EsXqkbLREY1RiuNhQIn6NJUF3pb4Hkj9cDnLxsVZINISdBzWA9yDT 9ycTHTJKpChVxCsyRYDGVoydCXJyQesV/YTofB9tfbP3GD8ts9UK+QdJ/QwPDfFs1Qyk VbW6abk+hIBitseap4jImO8lB0Ndag3XKm6sqcltV85aKRzIh2cs3s9P8oHabRxF82MU tBx/f7d13KiSifFO0CN3xeoFbkDGKsnHWqkzsVhGEErBRldRjZYXx6ejRnLYb+IuAgMm 007CbBVmU+0iMakJ1gMM34m9NCKiFn397pVPDXBRbChnpLxqslxcJKl4MR7zf9FT1GFR CGSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="dqZbv/7S"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id cm11-20020a05622a250b00b004313c93978dsi5271151qtb.797.2024.03.25.03.55.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="dqZbv/7S"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1C1C61C347D1 for ; Mon, 25 Mar 2024 10:55:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A915D212D05; Mon, 25 Mar 2024 02:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dqZbv/7S" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EB9D14658F; Sun, 24 Mar 2024 22:52:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320779; cv=none; b=bpyOOWKTq+u3HczBAX0J9MQki2U3JdBAM3TrBm/TPjYCUzSW8uEtYXBj0x6bsPTRMIZ/vGLA2cNrWWdICMpz8gTZw2+lwYc2amFh/0lCLtNPiruXMTm8D2EWXR3+2GaEhfS4BcO+NNjB8nSMVPBuxG7/x6vOOM5GE1HUjIYLAKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320779; c=relaxed/simple; bh=jj07wmei3mN6ZMOc0Yk4DtKf6tEJuooz99NDNP+fkjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aZR7KNwMWtufeacDYLy2S1IYz37HeNMIJMu9ieBRWbV9OJDBUm5Fw/rDpa0AvUH7JE+P9Kwpq7tEGz+xF+6Vth12SAos/7PYMp+eghDiNAbBAKfc1ll+6htI3oxoU80B0ILI/ZYVNNLJqDOMSh3kcC2X7UYW/62DqGnFOm/nhuM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dqZbv/7S; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A68CC433F1; Sun, 24 Mar 2024 22:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320779; bh=jj07wmei3mN6ZMOc0Yk4DtKf6tEJuooz99NDNP+fkjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dqZbv/7SHQVBZzazZiyQapwONwZnst91dXPKlJKRS6GhNEE64WvQ2hv3PopQ2n3NJ 0TYzGBo027g7z2JkndDKV7I9IYhScYwgusseDZyN9+BpfEDFzQjJq2KAhsURyGvGfe vn0BHYl+1ifn5M06kXpEiWFCsqnN7NBYTkFE7FIBfVqzn+tuvrFrmYg+/erPs1d11E xuIu8LtsMoLUifgwxMVaWrW0ct9hQ2rvuYvUf8kC+C2R74F5tE1KkjaKBtvXyBDonG BYR/aFcKEVRkZ42JkOuWV3YcOEat/BydnQ/JRu25vqldxt937HW6dfN5rxavSMttIw OIJRajK3qwvUw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Przemek Kitszel , Nebojsa Stevanovic , Christian Rohmann , Jacob Keller , Simon Horman , Pucha Himasekhar Reddy , Tony Nguyen , Sasha Levin Subject: [PATCH 6.7 342/713] ice: fix stats being updated by way too large values Date: Sun, 24 Mar 2024 18:41:08 -0400 Message-ID: <20240324224720.1345309-343-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Przemek Kitszel [ Upstream commit 257310e998700e60382fbd3f4fd275fdbd9b2aaf ] Simplify stats accumulation logic to fix the case where we don't take previous stat value into account, we should always respect it. Main netdev stats of our PF (Tx/Rx packets/bytes) were reported orders of magnitude too big during OpenStack reconfiguration events, possibly other reconfiguration cases too. The regression was reported to be between 6.1 and 6.2, so I was almost certain that on of the two "preserve stats over reset" commits were the culprit. While reading the code, it was found that in some cases we will increase the stats by arbitrarily large number (thanks to ignoring "-prev" part of condition, after zeroing it). Note that this fixes also the case where we were around limits of u64, but that was not the regression reported. Full disclosure: I remember suggesting this particular piece of code to Ben a few years ago, so blame on me. Fixes: 2fd5e433cd26 ("ice: Accumulate HW and Netdev statistics over reset") Reported-by: Nebojsa Stevanovic Link: https://lore.kernel.org/intel-wired-lan/VI1PR02MB439744DEDAA7B59B9A2833FE912EA@VI1PR02MB4397.eurprd02.prod.outlook.com Reported-by: Christian Rohmann Link: https://lore.kernel.org/intel-wired-lan/f38a6ca4-af05-48b1-a3e6-17ef2054e525@inovex.de Reviewed-by: Jacob Keller Signed-off-by: Przemek Kitszel Reviewed-by: Simon Horman Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_main.c | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index a9cca2d24120a..dabf33cec3e1b 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6572,6 +6572,7 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi) { struct rtnl_link_stats64 *net_stats, *stats_prev; struct rtnl_link_stats64 *vsi_stats; + struct ice_pf *pf = vsi->back; u64 pkts, bytes; int i; @@ -6617,21 +6618,18 @@ static void ice_update_vsi_ring_stats(struct ice_vsi *vsi) net_stats = &vsi->net_stats; stats_prev = &vsi->net_stats_prev; - /* clear prev counters after reset */ - if (vsi_stats->tx_packets < stats_prev->tx_packets || - vsi_stats->rx_packets < stats_prev->rx_packets) { - stats_prev->tx_packets = 0; - stats_prev->tx_bytes = 0; - stats_prev->rx_packets = 0; - stats_prev->rx_bytes = 0; + /* Update netdev counters, but keep in mind that values could start at + * random value after PF reset. And as we increase the reported stat by + * diff of Prev-Cur, we need to be sure that Prev is valid. If it's not, + * let's skip this round. + */ + if (likely(pf->stat_prev_loaded)) { + net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; + net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; + net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; + net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; } - /* update netdev counters */ - net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; - net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; - net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; - net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; - stats_prev->tx_packets = vsi_stats->tx_packets; stats_prev->tx_bytes = vsi_stats->tx_bytes; stats_prev->rx_packets = vsi_stats->rx_packets; -- 2.43.0