Netdev List
 help / color / mirror / Atom feed
From: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>
To: netdev-bot+sashiko@kernel.org
Cc: davem@davemloft.net, alexanderduyck@fb.com, kuba@kernel.org,
	kernel-team@meta.com, andrew+netdev@lunn.ch, edumazet@kernel.org,
	pabeni@redhat.com, shuah@kernel.org, hmohsin@meta.com,
	mike.marciniszyn@gmail.com, sdf@fomichev.me,
	bobbyeshleman@meta.com, bjorn@kernel.org, leitao@debian.org,
	horms@kernel.org, almasrymina@google.com,
	vadim.fedorenko@linux.dev, daskald@meta.com,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net v2 5/5] selftests: drv-net: stats: query timestamping stats while down
Date: Thu, 19 Nov 2026 09:56:47 -0800	[thread overview]
Message-ID: <e10e6b18-ec08-4f21-b972-b63c73ddfb25@gmail.com> (raw)
In-Reply-To: <179508206338.3136.8445234401487583362@kernel.org>



On 11/19/26 1:54 AM, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
> 
> Low priority / nit picks for your consideration:
> 
> - [Low] In check_down_ts_stats()
>   (tools/testing/selftests/drivers/net/stats.py), if a counter present…
> 
> --
> 
> selftests: drv-net: stats: query timestamping stats while down
> 
> This patch adds check_down_ts_stats() to the drv-net stats selftest. The
> test reads timestamping stats over ethtool netlink before and after taking
> the link down. It then checks that no counter went backwards.
> 
>> diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py
>> index b08e4d48b15ce..e61db30b51817 100755
>> --- a/tools/testing/selftests/drivers/net/stats.py
>> +++ b/tools/testing/selftests/drivers/net/stats.py
>> @@ -220,6 +220,28 @@ def check_down(cfg) -> None:
> 
> [ ... ]
> 
>> +    ip(f"link set dev {cfg.dev['ifname']} down")
>> +    defer(ip, f"link set dev {cfg.dev['ifname']} up")
>> +
>> +    stats2 = ethnl.tsinfo_get(req).get("stats", {})
>> +    for k in stats:
>> +        ksft_ge(stats2[k], stats[k], comment=f"{k} went backwards on device down")
> 
> [Severity: Low]
> What happens here if a counter that was reported while the link was up is
> missing from the reply after ifdown?
> 
> The kernel only puts counters in the reply when the driver filled them in.
> tsinfo_prepare_data() resets every counter on each query:
> 
> net/ethtool/tsinfo.c:tsinfo_prepare_data() {
>     ...
> 	ethtool_stats_init((u64 *)&data->stats,
> 				   sizeof(data->stats) / sizeof(u64));
>     ...
> }
> 
> Then tsinfo_put_stat() skips any counter that is still unset:
> 
> net/ethtool/tsinfo.c:tsinfo_put_stat() {
> 	if (val == ETHTOOL_STAT_NOT_SET)
> 		return 0;
>     ...
> }
> 
> So the second reply can contain fewer keys than the first. When that
> happens, stats2[k] raises KeyError before ksft_ge() runs.
> 
> This already happens with wangxun ngbe/txgbe. On ifdown, ngbe_close() and
> txgbe_close() call wx_ptp_stop(), which does:
> 
> 	if (wx->ptp_clock) {
> 		ptp_clock_unregister(wx->ptp_clock);
> 		wx->ptp_clock = NULL;
> 		...
> 	}
> 
> After that, wx_get_ptp_stats() fills nothing while the link is down:
> 
> 	if (wx->ptp_clock) {
> 		ts_stats->pkts = wx->tx_hwtstamp_pkts;
> 		...
> 	}
> 
> ksft_run() catches the KeyError and still marks the test as failed. The
> output is a Python traceback, though, and not the "went backwards on device
> down" message.
> 
> Would it be better to check that the key is present first, for example
> with ksft_in(k, stats2, ...), before calling ksft_ge()?
> 
> Also, when ETHTOOL_FLAG_STATS is set, tsinfo_fill_reply()->tsinfo_put_stats()
> always adds the stats nest to the reply. The {} default in
> .get("stats", {}) therefore never takes effect, and it can be dropped.
> 

The preference is for the test to fail, as this is unexpected behavior.

      reply	other threads:[~2026-11-19 17:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 21:54 [PATCH net v2 0/5] eth: fbnic: miscellaneous driver fixes Dimitri Daskalakis
2026-11-17 21:54 ` [PATCH net v2 1/5] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Dimitri Daskalakis
2026-11-18 13:13   ` Björn Töpel
2026-11-19  9:54   ` netdev-bot+sashiko
2026-11-19 17:56     ` Dimitri Daskalakis
2026-11-17 21:54 ` [PATCH net v2 2/5] eth: fbnic: skip disabled Tx rings when setting the queue NAPI Dimitri Daskalakis
2026-11-18 13:15   ` Björn Töpel
2026-11-17 21:54 ` [PATCH net v2 3/5] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats() Dimitri Daskalakis
2026-11-18 13:26   ` Björn Töpel
2026-11-17 21:54 ` [PATCH net v2 4/5] netdevsim: report fake timestamping stats Dimitri Daskalakis
2026-11-17 21:54 ` [PATCH net v2 5/5] selftests: drv-net: stats: query timestamping stats while down Dimitri Daskalakis
2026-11-19  9:54   ` netdev-bot+sashiko
2026-11-19 17:56     ` Dimitri Daskalakis [this message]

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=e10e6b18-ec08-4f21-b972-b63c73ddfb25@gmail.com \
    --to=dimitri.daskalakis1@gmail.com \
    --cc=alexanderduyck@fb.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=bobbyeshleman@meta.com \
    --cc=daskald@meta.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hmohsin@meta.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mike.marciniszyn@gmail.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --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