Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 23 Nov 2026 04:25
Re: [PATCH net-next v5 1/6] ionic: write the extra_stats invalid markers one counter at a time
Author: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 04:25
Date: Mon, 23 Nov 2026 04:25
99 lines
11703 bytes
11703 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] 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads