From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: netdev@vger.kernel.org
Cc: alexanderduyck@fb.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, horms@kernel.org,
kernel-team@meta.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, mohsin.bashr@gmail.com,
pabeni@redhat.com, sdf@fomichev.me, vadim.fedorenko@linux.dev
Subject: [PATCH net 2/2] eth: fbnic: Lock the tx_dropped update
Date: Fri, 1 Aug 2025 19:46:36 -0700 [thread overview]
Message-ID: <20250802024636.679317-3-mohsin.bashr@gmail.com> (raw)
In-Reply-To: <20250802024636.679317-1-mohsin.bashr@gmail.com>
Wrap copying of drop stats on TX path from fbd->hw_stats by the
hw_stats_lock. Currently, it is being performed outside the lock and
another thread accessing fbd->hw_stats can lead to inconsistencies.
Fixes: 5f8bd2ce8269 ("eth: fbnic: add support for TMI stats")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com>
---
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
index dc295e1b8516..d0e381ad7bee 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
@@ -421,10 +421,12 @@ static void fbnic_get_stats64(struct net_device *dev,
tx_dropped = stats->dropped;
/* Record drops from Tx HW Datapath */
+ spin_lock(&fbd->hw_stats_lock);
tx_dropped += fbd->hw_stats.tmi.drop.frames.value +
fbd->hw_stats.tti.cm_drop.frames.value +
fbd->hw_stats.tti.frame_drop.frames.value +
fbd->hw_stats.tti.tbi_drop.frames.value;
+ spin_unlock(&fbd->hw_stats_lock);
stats64->tx_bytes = tx_bytes;
stats64->tx_packets = tx_packets;
--
2.47.3
next prev parent reply other threads:[~2025-08-02 2:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-02 2:46 [PATCH net 0/2] eth: fbnic: Fix drop stats support Mohsin Bashir
2025-08-02 2:46 ` [PATCH net 1/2] eth: fbnic: Fix tx_dropped reporting Mohsin Bashir
2025-08-04 11:14 ` Simon Horman
2025-08-02 2:46 ` Mohsin Bashir [this message]
2025-08-04 11:12 ` [PATCH net 2/2] eth: fbnic: Lock the tx_dropped update Simon Horman
2025-08-05 23:20 ` [PATCH net 0/2] eth: fbnic: Fix drop stats support patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250802024636.679317-3-mohsin.bashr@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.