From: Sean Anderson <sean.anderson@linux.dev>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Michal Simek <michal.simek@amd.com>,
Jakub Kicinski <kuba@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
linux-kernel@vger.kernel.org,
"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH net-next 3/3] net: xilinx: axienet: Add statistics support
Date: Tue, 11 Jun 2024 11:36:31 -0400 [thread overview]
Message-ID: <4d3871c1-afa1-4402-ad62-2fdb9d58dc3c@linux.dev> (raw)
In-Reply-To: <40cff9a6-bad3-4f85-8cbc-6d4bc72f9b9f@lunn.ch>
On 6/10/24 20:26, Andrew Lunn wrote:
>> +static u64 axienet_stat(struct axienet_local *lp, enum temac_stat stat)
>> +{
>> + return u64_stats_read(&lp->hw_stats[stat]);
>> +}
>> @@ -1695,6 +1760,35 @@ axienet_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
>> stats->tx_packets = u64_stats_read(&lp->tx_packets);
>> stats->tx_bytes = u64_stats_read(&lp->tx_bytes);
>> } while (u64_stats_fetch_retry(&lp->tx_stat_sync, start));
>> +
>> + if (!(lp->features & XAE_FEATURE_STATS))
>> + return;
>> +
>> + do {
>> + start = u64_stats_fetch_begin(&lp->hw_stat_sync);
>> + stats->rx_length_errors =
>> + axienet_stat(lp, STAT_RX_LENGTH_ERRORS);
>
> I'm i reading this correctly. You are returning the counters from the
> last refresh period. What is that? 2.5Gbps would wrapper around a 32
> byte counter in 13 seconds. I hope these statistics are not 13 seconds
> out of date?
By default we use a 1 Hz refresh period. You can of course configure this
up to 13 seconds, but we refuse to raise it further since we risk missing
a wrap-around. It's configurable by userspace so they can determine how
out-of-date they like their stats (vs how often they want to wake up the
CPU).
> Since axienet_stats_update() also uses the lp->hw_stat_sync, i don't
> see why you cannot read the hardware counter value and update to the
> latest value.
We would need to synchronize against updates to hw_last_counter. Imagine
a scenario like
CPU 1 CPU 2
__axienet_device_reset()
axienet_stats_update()
axienet_stat()
u64_stats_read()
axienet_ior()
/* device reset */
hw_last_counter = 0
stats->foo = ... - hw_last_counter[...]
and now we have a glitch in the counter values, since we effectively are
double-counting the current counter value. Alternatively, we could read
the counter after reset but before hw_last_counter was updated and get a
glitch due to underflow.
--Sean
next prev parent reply other threads:[~2024-06-11 15:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 23:10 [PATCH net-next 0/3] net: xilinx: axienet: Add statistics support Sean Anderson
2024-06-10 23:10 ` [PATCH net-next 1/3] net: xilinx: axienet: Use NL_SET_ERR_MSG instead of netdev_err Sean Anderson
2024-06-10 23:49 ` Andrew Lunn
2024-06-11 15:06 ` Sean Anderson
2024-06-10 23:10 ` [PATCH net-next 2/3] net: xilinx: axienet: Report RxRject as rx_dropped Sean Anderson
2024-06-10 23:10 ` [PATCH net-next 3/3] net: xilinx: axienet: Add statistics support Sean Anderson
2024-06-11 0:13 ` Andrew Lunn
2024-06-11 0:29 ` Andrew Lunn
2024-06-11 16:43 ` Sean Anderson
2024-06-11 15:14 ` Sean Anderson
2024-06-11 0:26 ` Andrew Lunn
2024-06-11 15:36 ` Sean Anderson [this message]
2024-06-18 17:03 ` Sean Anderson
2024-06-18 18:19 ` Andrew Lunn
2024-06-14 16:30 ` Simon Horman
2024-06-14 20:54 ` Sean Anderson
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=4d3871c1-afa1-4402-ad62-2fdb9d58dc3c@linux.dev \
--to=sean.anderson@linux.dev \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=michal.simek@amd.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radhey.shyam.pandey@amd.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;
as well as URLs for NNTP newsgroup(s).