Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: alexander.duyck@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, horms@kernel.org,
	kernel-team@meta.com, kuba@kernel.org, pabeni@redhat.com
Subject: Re: [net PATCH 3/6] fbnic: Cover all of the HW stats with the stats lock
Date: Tue, 17 Nov 2026 21:14:21 +0000	[thread overview]
Message-ID: <179495006109.3136.9222422977894063290@kernel.org> (raw)
In-Reply-To: <179460250360.8819.2203630667210523871.stgit@ahduyck-xeon-server.home.arpa>

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] The commit message and Fixes: tag describe a race that cannot
  happen at this commit.

--

fbnic: Cover all of the HW stats with the stats lock

This patch puts the fbnic MAC stats under hw_stats.lock. The lock is now
taken in the ethtool pause, eth-mac, eth-ctrl and rmon getters and in
fbnic_reset_hw_stats(), and the ASSERT_RTNL() is gone. It also drops
rtnl_lock() from the PCIe stats debugfs read.

> That is no
> longer the case. ethtool only takes RTNL on the Netlink path for the
> operations a driver lists in op_needs_rtnl, and fbnic lists only the
> pause getter among the stats ones, so the eth-mac, eth-ctrl and rmon
> getters update the MAC stats with only the netdev instance lock held,
> racing each other and the reset.

[ ... ]

> Fixes: 45079e00133e ("net: ethtool: optionally skip rtnl_lock on Netlink path for GET ops")

[Severity: Medium]
Can the race described here actually happen at this commit?

fbnic is ops-locked. fbnic_netdev_alloc() sets queue_mgmt_ops
unconditionally:

    netdev->queue_mgmt_ops = &fbnic_queue_mgmt_ops;

That makes netdev_need_ops_lock() true, so netdev_lock_ops() really takes
netdev->lock for this device.

ethnl_default_doit() takes that lock around prepare_data() whether or not
RTNL is needed:

    if (need_rtnl)
        rtnl_lock();
    netdev_lock_ops(req_info->dev);
    }
    ret = ops->prepare_data(req_info, reply_data, info);

The dump path does the same, and the notify path asserts the same lock.
The only core callers of the fbnic get_eth_mac_stats, get_eth_ctrl_stats,
get_rmon_stats and get_pause_stats callbacks are stats_prepare_data() and
pause_prepare_data(). So the getters are already serialized against each
other by the instance lock.

fbnic_reset_hw_stats() has two callers. fbnic_init_hw_stats() runs from
fbnic_probe() before the netdev is allocated or registered, so no ethtool
request can reach the device yet. __fbnic_pm_attach() holds the same
instance lock around the reset:

    rtnl_lock();
    netdev_lock(netdev);

    fbnic_reset_hw_stats(fbd);

Nothing else touches fbd->hw_stats.mac or calls the fbd->mac->get_*_stats
callbacks.

After 45079e00133e, the old comment and ASSERT_RTNL() in
fbnic_reset_hw_stats() were out of date. But netdev->lock still seems to
serialize every path that touches the MAC stats.

The locking change itself looks fine as a consistency cleanup. Later in
this series the reset moves into __fbnic_pm_resume() and runs under
hw_stats.lock only, without netdev_lock. That later change is what makes
the lock added here necessary.

Could the commit message say that the instance lock already serializes
these paths, and that this patch makes hw_stats.lock the single
protection to prepare for the later reset move? Could the Fixes: tag
also be dropped, or could the message name a path that actually reaches
the race? As written, the tag may lead to this being backported to
stable as a fix for a race that does not exist there.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179460241885.8819.7179935130629202331.stgit%40ahduyck-xeon-server.home.arpa

  reply	other threads:[~2026-11-17 21:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 20:41 [net PATCH 0/6] fbnic: Follow-up fixes for the Tx idle check, HW stats and FW mailbox allocations Alexander Duyck
2026-11-13 20:41 ` [net PATCH 1/6] fbnic: Wait for in-flight PTP timestamps before treating Tx as idle Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko
2026-11-17 21:31     ` Alexander Duyck
2026-11-13 20:41 ` [net PATCH 2/6] fbnic: Do not accumulate HW stats from failed register reads Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko
2026-11-13 20:41 ` [net PATCH 3/6] fbnic: Cover all of the HW stats with the stats lock Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko [this message]
2026-11-13 20:41 ` [net PATCH 4/6] fbnic: Initialize and reset the HW stats before they can be read Alexander Duyck
2026-11-13 20:42 ` [net PATCH 5/6] fbnic: Stamp heartbeat and ownership requests after allocating them Alexander Duyck
2026-11-13 20:42 ` [net PATCH 6/6] fbnic: Allocate FW completions with kvzalloc Alexander Duyck

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=179495006109.3136.9222422977894063290@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexander.duyck@gmail.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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox