Article View: linux.kernel.netdev
Article #11816Re: [PATCH net] net/mlx5e: Fix queue stats access to queues without stats
From: netdev-bot+sashiko
Date: Thu, 05 Nov 2026 17:05
Date: Thu, 05 Nov 2026 17:05
97 lines
11505 bytes
11505 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] When HTB leaves are configured and the netdev is brought down,
the device-wide qstats lose all HTB TX counters.
--
net/mlx5e: Fix queue stats access to queues without stats
This commit fixes NULL pointer dereferences in the mlx5e per-queue
netdev-genl stats callbacks. The core calls them for every queue below
real_num_{rx,tx}_queues, and some of those queues have no stats behind
them. The RX callback now returns early for queues at or above stats_nch,
and the TX callback returns early when txq2sq_stats[i] is NULL.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index c3c2c5720c6f3..72bca10c579df 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
[ ... ]
> @@ -5521,6 +5521,9 @@ static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i,
> * inactive sqs.
> */
> sq_stats = priv->txq2sq_stats[i];
> + if (!sq_stats)
> + return;
> +
[Severity: Medium]
With HTB offload leaves configured, do the HTB TX counters drop out of
the device-wide qstats totals while the netdev is down?
The early return depends on the comment above it, which says
get_base_stats "takes care of inactive sqs". For HTB SQs that does not
seem to hold.
On ifdown, mlx5e_deactivate_channel()->mlx5e_qos_deactivate_queues()
clears the entry for every HTB txq:
drivers/net/ethernet/mellanox/mlx5/core/en/qos.c:mlx5e_qos_deactivate_queues() {
...
c->priv->txq2sq[txq_ix] = NULL;
c->priv->txq2sq_stats[txq_ix] = NULL;
...
}
real_num_tx_queues still includes those txqs, because
mlx5e_update_tx_netdev_queues() sets it to nch * ntc +
mlx5e_htb_cur_leaf_nodes(priv->htb) whether or not the channels are
open. So netdev_nl_stats_by_netdev() still calls
mlx5e_get_queue_stats_tx() for those indices, and with this change it
now returns without reporting anything.
mlx5e_get_base_stats() only walks channel_stats[]->sq[tc] and
ptp_stats.sq[tc]:
for (i = 0; i < nch; i++) {
struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];
...
It never reads priv->htb_qos_sq_stats[], which is where the persistent
HTB counters live. So tx packets, bytes, hw-gso-packets, hw-gso-bytes,
csum-none, stop and wake for HTB queues disappear from the total on
ifdown and come back on ifup.
That looks like it would make device qstats go backwards on ifdown,
which tools/testing/selftests/drivers/net/stats.py check_down() tests
for:
ksft_ge(qstat2[k], qstat[k], comment=f"{k} went backwards on device down")
The qstats totals would also stop matching the SW/rtnl totals, since
mlx5e_stats_grp_sw_update_stats_qos() still adds every
htb_qos_sq_stats[i].
Should mlx5e_get_base_stats() add priv->htb_qos_sq_stats[] for HTB
queues whose txq2sq_stats entry is NULL? If not, could the comment
above be corrected to document this gap?
> stats->packets = sq_stats->packets;
> stats->bytes = sq_stats->bytes;
>
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261104-mlx5e-qstats-null-v1-1-a6a003245cec%40debian.org
Technical Details
Message-ID:
<179389832803.994134.11688655413292808723@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357514-linux-kernel-netdev=dewy.ruReferences:
<20261104-mlx5e-qstats-null-v1-1-a6a003245cec@debian.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357514-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/mlx5e: Fix queue stats access to queues without stats Date: Thu, 05 Nov 2026 17:05:28 +0000 Organization: Usenet Network Message-ID: <179389832803.994134.11688655413292808723@kernel.org> References: <20261104-mlx5e-qstats-null-v1-1-a6a003245cec@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3687491"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:7b3r3QzzbklO3FGz/aQuTp6rYas= sha256:OO4ZIEsq63ZPbkrFcmrcbGycHeju4wGwBHtitB49pak= sha1:j66y7nRuWNIQHez4wHAfsac94tc= sha256:rXsT1yv24ewZODPki9DDtaCWHpJYcBdpXgkn6dwqmss= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 70E1F113002; Thu, 5 Nov 2026 20:13:46 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PmknaffR3LIj; Thu, 5 Nov 2026 20:13:42 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-357514-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 6AC43113031; Thu, 5 Nov 2026 20:13:34 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id D267660C2FE; Thu, 5 Nov 2026 17:05:43 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793898336; b=RTiZsx/Q17e25RurgqKv0044nAgoyUifsfqsiv1FRUNG2vv4yZuVu18JuFWzEbqQozIx rp6vC4COcObXSzWUojGV6hYETKLubPyc8y6lU1tSHZECuw18ay9suponcnqDMyxP8RQ1s IvoCccrBt6WRW4mNRMwtWR0jP/uv9pasinYT8vR3TuzgHOdiZ3aV5e5lIBzwWgHRNxvoo S0V0QrShEwsiIIGqxvHChedhEG/isoWP7UxxYLaOZTAHooPkfyowcvUzf07TFE1LtrKyJ iq0e7/EYM2AP3W292v7E/dCsImKPC06s5TSQQ/caFzkimbODivf/SAXyUC4LoxpgKmQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793898336; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=dt+bS/VdQDFXRnSUlgwag2EWurUxCShd4OV+Ezmnvzo=; b=C36BlfVMZGvTcizsPB/aBWqqKS6xaIgmxiyUHWdH4/rwpwTBhf86pCwrU2sI2RhCL0c/ P612hxVTOkAXLVBaPnC3Eg+ad3/Gx/sfoGwylAXE+eKTcfW/kEnRPPOIdFq0qz0JY5+pq LGGTO4PvXSI6neBV/zmMCKKgfxG1HgOELR+KrAqMjkHOPKPBCBJ4ljJnb6IfvbST7BjBM +wE1fJ+9E+LEo6jbdjnKAwnynUnENtogtjPldvE/TJ2QMiYQQn950qyQ1BNjBNS72URmj xkKDbLAJk84hXud1pD/KpGBDg1USYUgaAziPGdjdHVZEx4NdbSl/zcXf3R3aEdje9nw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WM+qS0yH; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCD00606D811; Thu, 5 Nov 2026 17:05:35 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WM+qS0yH X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793898330; b=iFHB5A1PA8UvKjHsIRS92+9zOiINJdNzJvHeZmer0ncQ4xaeW/Qdw5G/7A2dkdXVhVWA ZxXt/bAQ4Nw4HRKNGHtXJtKlQdxYObVV6xbV/rDrm22HP01ylfOc/KP6db9da4EjCmwr+ l0wussRYXZiCqaHcyCYTIENf9sYJRKOEWPveK6KAwOwqF1DpRz8EdykFgIZHs0WpL+2x3 O9zsZxzUS3edqUiNmGQg22wvFIjAj9gvIYihigM1Z8iJ1teRhxbeBKTohxHy8Hb40+lqc hHFmjFCYVCq74MDQELkyU8ryddNbcDLYRFP+KHc8m1y6Irq38aFMrH1rZAgCZJfspbQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793898330; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=dt+bS/VdQDFXRnSUlgwag2EWurUxCShd4OV+Ezmnvzo=; b=xKVJ26Xrf9hCirTdK81uWrzOKTYcRBUEVfRnKRcQR6BKlfpl38AzRjcOEtrcpo0dzudq W9MnnBWWs7dYMqTsVRyG/SjJNMCQWYP47Rdsm/XF9NKPNJ1zbMnyPPF+fDj3O6PW85+EI 4zv17V55R5JzEbodH2J7+4ebHRcWvpeIJJWqYQfPccZlnOLFfEDheLYaf1YBiQAMtKb2v 6xnhMgZnw/e7FDzvYmV1K0EPeV68ax/zj5Z19AN7ay+jecB9LBldoj1CymgC3TfmBoLE4 6CDb0l9avIo8+AMXaqFOrqmgYDa1pS5woofR2cEqTO48tiEyMb8HB5zY+LVYM48pKoQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WM+qS0yH; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6618606A329; Thu, 5 Nov 2026 17:05:29 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78B731F000C1; Thu, 5 Nov 2026 17:05:28 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793898329; bh=dt+bS/VdQDFXRnSUlgwag2EWurUxCShd4OV+Ezmnvzo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=WM+qS0yHv+48Q7hye6rHq3MFiDy2DoTqYvlIiFYvue1b/KpZc/R7As+Zo7TrwNwXG TCbkGZRZrIbe/vH0EwXdI3Jv1835GYgSpKCJjezm8Q3Sa46mENULDc1JdBH5kTLrWg mwcyUCqzHR6UigI9qB3nCV7BGfDmoASd1vMlje+mZB8G5q0zNfDWvTNcpOJlrKhygf 8MFZPWbp06utKEUo4ZpmkVQXAT9p5b8CM/lkuOuPpgCGYf+CG8XahwjNF0TXGuBPo/ pp5N6yFPvIOak44ud+Mfq1rJGjPtID9yDvko0efo8oJpKZ4YkpdS8zAt28zvq5zGpB HQgPJPrcjKtdQ== X-Cc: saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, joe@dama.to, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, stable@vger.kernel.org X-In-Reply-To: <20261104-mlx5e-qstats-null-v1-1-a6a003245cec@debian.org> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list