From: "Mattias Rönnblom" <hofors@lysator.liu.se>
To: "Morten Brørup" <mb@smartsharesystems.com>,
"Ferruh Yigit" <ferruh.yigit@amd.com>,
"Thomas Monjalon" <thomas@monjalon.net>,
"Andrew Rybchenko" <andrew.rybchenko@oktetlabs.ru>
Cc: dev@dpdk.org, stable@dpdk.org,
"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
"Stephen Hemminger" <stephen@networkplumber.org>
Subject: Re: [PATCH] ethdev: document that stats reset APIs are not thread-safe
Date: Mon, 29 Apr 2024 11:30:54 +0200 [thread overview]
Message-ID: <e7002cf2-6da8-45c0-9794-c4f5ad943ccc@lysator.liu.se> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F401@smartserver.smartshare.dk>
On 2024-04-29 09:57, Morten Brørup wrote:
>> From: Mattias Rönnblom [mailto:hofors@lysator.liu.se]
>> Sent: Sunday, 28 April 2024 17.49
>>
>> On 2024-04-26 14:20, Morten Brørup wrote:
>>>> From: Ferruh Yigit [mailto:ferruh.yigit@amd.com]
>>>> Sent: Thursday, 25 April 2024 18.53
>>>>
>>>> Making 'rte_eth_stats_reset()' and 'rte_eth_xstats_reset()' APIs thread
>>>> safe has performance impact on datapath.
>>>>
>>>> Instead document APIs as not thread safe and add condition for reliable
>>>> stats reset functionality, forwarding should be stopped.
>>>
>>
>> What does "forwarding" mean here? Sounds like something from testpmd.
>>
>> Isn't what needs to stop here other threads calling into the ethdev API
>> for this particular device?
>
> Doesn't suffice.
> The NIC hardware counters increment if the NIC's DMA engine receives or transmits packets.
> E.g. in the RX direction, the NIC hardware counters increment according to what the NIC detects happening on the wire. If some packets are DMA'ed into memory and the associated RX descriptors are filled, the NIC's hardware counters progress. It doesn't matter if the software has looked at those RX descriptors or not.
>
>>
>>> I'm not sure stopping forwarding suffices.
>>> NIC hardware counters will keep progressing unless RX and TX is stopped at
>> NIC level.
>>>
>>
>> Why would that be an issue?
>
> My point is:
> Unless you stop everything, including the NIC hardware RX & TX DMA, the counters might not be zero when returning from the stats_reset() functions.
>
The reset can still be MT safe, even though there is no way to retrieve
the exact counter state prior to the reset and also is no guarantee that
the counters are zero immediately after the function returns (whatever
that means).
If you do want to be able to do that, the means to that end is to teach
the reset function to return the prior counter state as a part of the
reset call, not to force the user to have the system grind to a halt.
>>
>>> I don't have any suggestions for a better wording, though. :-(
>
> I think it is fine providing a notice about MT-unsafety in the API documentation.
> But the only way to prevent it is useless in real applications, as it would cause packet loss. So it's not helpful describing how to do that.
>
>>>
>>> Anyway, better with the patch than without...
>>> Acked-by: Morten Brørup <mb@smartsharesystems.com>
>>>
next prev parent reply other threads:[~2024-04-29 9:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 16:53 Ferruh Yigit
2024-04-26 12:20 ` Morten Brørup
2024-04-26 15:13 ` Stephen Hemminger
2024-04-26 15:17 ` Morten Brørup
2024-04-26 22:57 ` Stephen Hemminger
2024-04-28 15:52 ` Mattias Rönnblom
2024-04-29 6:20 ` Morten Brørup
2024-04-29 15:33 ` Stephen Hemminger
2024-04-28 15:48 ` Mattias Rönnblom
2024-04-29 7:57 ` Morten Brørup
2024-04-29 9:30 ` Mattias Rönnblom [this message]
2024-04-26 21:33 ` Patrick Robb
2024-10-04 22:27 ` Stephen Hemminger
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=e7002cf2-6da8-45c0-9794-c4f5ad943ccc@lysator.liu.se \
--to=hofors@lysator.liu.se \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=mattias.ronnblom@ericsson.com \
--cc=mb@smartsharesystems.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/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).