Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp570260rdb; Fri, 5 Jan 2024 23:17:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHAl4wAFoZ5yKBlD8vW80nog/Ont3oz7WBia6vx0zWbM0JMzSVD+WTRRQHndezSiyEPtgU X-Received: by 2002:a17:902:eb8b:b0:1d4:e1f4:e18 with SMTP id q11-20020a170902eb8b00b001d4e1f40e18mr728760plg.77.1704525420803; Fri, 05 Jan 2024 23:17:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704525420; cv=none; d=google.com; s=arc-20160816; b=iRsiC0Uo7FrxQo6az/rshlf5K6wuVlznHH2VKPzrPAtjY6S/EHfXP1FQEg7PyqJpKa OkDGmRa/U+3tPfQQWkIszWyv0vOvv2AqzVyjdjtoufPJciUsZn8xWoEYWQJiYRtzfaaZ ftTj74bPiruN8vteZn3eBDitSn9fR1Vr80hGUtZG+MTE4gmGQsoiGTlqIirLMXxidbcE BHupLL8/u+PhJCDZp03FIv2q0vSjHhtXkEDlMf92WXPoK00aK8BjIg51fndELR0jV8Wn z77LyUw+LmwAHR19gvmEuVnftEUJjkcW4zYaGKG5UKo2Gkzuzyarms4fyVO5dmapaSXr 7oQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=k5BQzwQ/QoIUjZpNq2Kzm36SkiOzoyvenE8l45JUEw8=; fh=pZdhdTkn4PXksFQg4aTV4CeKf67vReAyxCeF+szoQF8=; b=VQStQZ5mbotx3qCR18h+qU1IkBvebqH6vt/7HHZHj3nacJ3wu/oCPayUwGm1S0G/MI UKqn1ZHLZv44b+bDKLjFBpf1+D33nr4b1dckzEQqf8RXn8b5ahCZDwKIoDQYaE8GiQQP 3kQyJkNcZfz1Q3WyNGrksBYS70h4Dj3ODx/1nskpRiYxBVcY5AhyYtbpcIvt2gRCs57D EO/qhCBuLAG9iGcFgcaduBaHkNQLVKozf52Fkeq6WziaGxMHGPIUA7ZTWjmHSWM1KY4y pd9srGr2szpBK/cHeAel3BQaSgH1lo97HVC2nwGukFOOw3pZIG9bp5fIAa6H1XLQ/V4Y jSJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UFXeACEH; spf=pass (google.com: domain of linux-kernel+bounces-18520-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c8-20020a170902d48800b001d3e5749922si2497991plg.324.2024.01.05.23.17.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 23:17:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18520-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UFXeACEH; spf=pass (google.com: domain of linux-kernel+bounces-18520-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18520-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 76688284FEA for ; Sat, 6 Jan 2024 07:17:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30EE246B4; Sat, 6 Jan 2024 07:16:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UFXeACEH" X-Original-To: linux-kernel@vger.kernel.org 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 2FBA13C15; Sat, 6 Jan 2024 07:16:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9290FC433C7; Sat, 6 Jan 2024 07:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704525408; bh=dG0phtdnvCCkXxKsiM0aT+uPfINQvrWi1CxX3oZjNpk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UFXeACEHnSPawP6cd9scXaSiG/L0zYDNa6b03SxmQ06d+UguZqTrXUbK74SEx+QXa jXkGyoBBeJjY7TO/u0N50pS0Tfc624K+B4RUakx1tZ60wTlblLS+Tc9ZEYPX4z7Alw AgzgcBeA3CF+LkFyjNODcKMSNCb4oXWfJsu+rJFH7f6F2uQcSIXdroOKp0BB5YGdEw xOT3zbXOH6VrIY8NMQwd/yH80j4zHFV5kkJ0U8P3SHQwcKL8oHI5MSUHTtGKNlMKZE ynS31RyIRXfXEug2ZqdRD0jozOi/gP14IYrlGOn2LVYXpJsevBm4O7rPrWfX/jfgG2 4avy2DAskjOyQ== Date: Sat, 6 Jan 2024 15:04:01 +0800 From: Jisheng Zhang To: Petr Tesarik Cc: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Andrew Lunn , "open list:STMMAC ETHERNET DRIVER" , "moderated list:ARM/STM32 ARCHITECTURE" , "moderated list:ARM/STM32 ARCHITECTURE" , open list , stable@vger.kernel.org Subject: Re: [PATCH net] net: stmmac: fix ethtool per-queue statistics Message-ID: References: <20240105201642.30904-1-petr@tesarici.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240105201642.30904-1-petr@tesarici.cz> On Fri, Jan 05, 2024 at 09:16:42PM +0100, Petr Tesarik wrote: > Fix per-queue statistics for devices with more than one queue. > > The output data pointer is currently reset in each loop iteration, > effectively summing all queue statistics in the first four u64 values. > > The summary values are not even labeled correctly. For example, if eth0 has > 2 queues, ethtool -S eth0 shows: > > q0_tx_pkt_n: 374 (actually tx_pkt_n over all queues) > q0_tx_irq_n: 23 (actually tx_normal_irq_n over all queues) > q1_tx_pkt_n: 462 (actually rx_pkt_n over all queues) > q1_tx_irq_n: 446 (actually rx_normal_irq_n over all queues) > q0_rx_pkt_n: 0 > q0_rx_irq_n: 0 > q1_rx_pkt_n: 0 > q1_rx_irq_n: 0 > > Fixes: 133466c3bbe1 ("net: stmmac: use per-queue 64 bit statistics where necessary") > Cc: stable@vger.kernel.org > Signed-off-by: Petr Tesarik Good catch! I mixed this with the statics sum up for stmmac_qstats_string[]. Reviewed-by: Jisheng Zhang > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c > index f628411ae4ae..112a36a698f1 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c > @@ -543,15 +543,12 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data) > u32 rx_cnt = priv->plat->rx_queues_to_use; > unsigned int start; > int q, stat; > - u64 *pos; > char *p; > > - pos = data; > for (q = 0; q < tx_cnt; q++) { > struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[q]; > struct stmmac_txq_stats snapshot; > > - data = pos; > do { > start = u64_stats_fetch_begin(&txq_stats->syncp); > snapshot = *txq_stats; > @@ -559,17 +556,15 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data) > > p = (char *)&snapshot + offsetof(struct stmmac_txq_stats, tx_pkt_n); > for (stat = 0; stat < STMMAC_TXQ_STATS; stat++) { > - *data++ += (*(u64 *)p); > + *data++ = (*(u64 *)p); > p += sizeof(u64); > } > } > > - pos = data; > for (q = 0; q < rx_cnt; q++) { > struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[q]; > struct stmmac_rxq_stats snapshot; > > - data = pos; > do { > start = u64_stats_fetch_begin(&rxq_stats->syncp); > snapshot = *rxq_stats; > @@ -577,7 +572,7 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data) > > p = (char *)&snapshot + offsetof(struct stmmac_rxq_stats, rx_pkt_n); > for (stat = 0; stat < STMMAC_RXQ_STATS; stat++) { > - *data++ += (*(u64 *)p); > + *data++ = (*(u64 *)p); > p += sizeof(u64); > } > } > -- > 2.43.0 >