Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: eric.joyner@amd.com
Cc: netdev@vger.kernel.org, brett.creeley@amd.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, vadim.fedorenko@linux.dev,
	nikhil.rao@amd.com, edumazet@kernel.org
Subject: Re: [PATCH net-next v5 1/6] ionic: write the extra_stats invalid markers one counter at a time
Date: Mon, 23 Nov 2026 04:25:52 +0000	[thread overview]
Message-ID: <179540795235.3135.479285551896184785@kernel.org> (raw)
In-Reply-To: <20261118-ionic-get-fec-stats-v5-1-c9c0ee63df4c@amd.com>

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 patch makes only the writer side single-copy atomic.

--

ionic: write the extra_stats invalid markers one counter at a time

ionic_port_init() used to mark the extra_stats block invalid with a
memset(). It now writes IONIC_STAT_INVALID to each __le64 counter with
WRITE_ONCE(). The goal is that a counter read on its own is either a
complete value or the marker.

> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
> index 9955ab77d86d0..b8d0ce5971769 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c

[ ... ]

> @@ -745,8 +748,9 @@ int ionic_port_init(struct ionic *ionic)
>  	/* If the driver knows about more "extra stats" than the firmware,
>  	 * make sure these stats are marked as invalid.
>  	 */
> -	memset(&idev->port_info->extra_stats, 0xff,
> -	       sizeof(idev->port_info->extra_stats));
> +	stat = (__le64 *)&idev->port_info->extra_stats;
> +	for (i = 0; i < sizeof(idev->port_info->extra_stats) / sizeof(*stat); i++)
> +		WRITE_ONCE(stat[i], IONIC_STAT_INVALID);

[Severity: Medium]
This change only covers the store side. Is the existing ethtool -S
reader of these same markers still exposed to the torn read that the
commit message describes?

The .get_fec_stats handler added later in the series reads each counter
with READ_ONCE(), so it gets the intended guarantee. But
ionic_extra_port_stats_get_count() in ionic_stats.c still takes its
snapshot with a plain aggregate struct copy:

drivers/net/ethernet/pensando/ionic/ionic_stats.c:ionic_extra_port_stats_get_count() {
    ...
	*pes_cache = idev->port_info->extra_stats;

	if (pes_cache->rx_bits_phy != IONIC_STAT_INVALID)
		count++;
    ...
}

The compiler can lower that struct copy to memcpy() or to inline copies
of any width. That is the same objection the commit message makes
against memset(). The series leaves this line unchanged.

Here is the race. Firmware reset recovery runs from deferred work
without rtnl:

ionic_lif_deferred_work()->ionic_lif_handle_fw_up()->ionic_port_init()

It can overlap this rtnl-held ethtool path:

ionic_get_stats_count()->ionic_sw_stats_get_count()->
    ionic_extra_port_stats_get_count()

The netif_device_present() checks in the ethtool ioctl and netlink paths
don't close this window. ionic_lif_handle_fw_down() calls
netif_device_detach() without synchronizing against rtnl holders, so a
caller that passed the check before the detach can still overlap the
later marker writes.

In that case, a torn rx_bits_phy (some 0xff bytes, some old-value bytes)
could pass the IONIC_STAT_INVALID test and get cached. Then
ionic_extra_port_stats_get_strings() and
ionic_extra_port_stats_get_values() would report a bogus rx_bits_phy to
userspace. The plain read racing the WRITE_ONCE() stores is also an
unmarked data race, which KCSAN could flag.

Should the ethtool -S snapshot use per-counter READ_ONCE() loads, at
least for rx_bits_phy? Otherwise, could the commit message say that the
"complete value or the marker" guarantee only applies to readers that
use READ_ONCE() on each counter?

>  
>  	WRITE_ONCE(idev->link_down_count_init, false);
>  

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-ionic-get-fec-stats-v5-0-c9c0ee63df4c%40amd.com

  reply	other threads:[~2026-11-23  4:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  2:56 [PATCH net-next v5 0/6] ionic: FEC reporting fixes and .get_fec_stats handler Eric Joyner
2026-11-19  2:56 ` [PATCH net-next v5 1/6] ionic: write the extra_stats invalid markers one counter at a time Eric Joyner
2026-11-23  4:25   ` netdev-bot+sashiko [this message]
2026-11-19  2:56 ` [PATCH net-next v5 2/6] ionic: report FEC off as a supported link mode Eric Joyner
2026-11-19  2:56 ` [PATCH net-next v5 3/6] ionic: report the configured FEC mode in ethtool_fecparam.fec Eric Joyner
2026-11-19  2:56 ` [PATCH net-next v5 4/6] ionic: map the FEC type through a helper in ionic_get_fecparam() Eric Joyner
2026-11-23  4:25   ` netdev-bot+sashiko
2026-11-19  2:56 ` [PATCH net-next v5 5/6] ionic: report the operational FEC mode from ethtool --show-fec Eric Joyner
2026-11-23  4:25   ` netdev-bot+sashiko
2026-11-19  2:56 ` [PATCH net-next v5 6/6] ionic: Add .get_fec_stats ethtool handler Eric Joyner

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=179540795235.3135.479285551896184785@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=eric.joyner@amd.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikhil.rao@amd.com \
    --cc=pabeni@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox