public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Scott Mitchell <scott.k.mitch1@gmail.com>
Cc: dev@dpdk.org, "John W. Linville" <linville@tuxdriver.com>
Subject: Re: [RFC 1/4] net/af_packet: remove volatile from statistics
Date: Wed, 28 Jan 2026 13:00:30 -0800	[thread overview]
Message-ID: <20260128130014.0489e0a0@phoenix.local> (raw)
In-Reply-To: <CAFn2buD=1CwnP92LGuj7fGzi_Cujnp8eTV96ZzTNKBjsA6kzOA@mail.gmail.com>

On Wed, 28 Jan 2026 11:57:16 -0800
Scott Mitchell <scott.k.mitch1@gmail.com> wrote:

> Can you clarify why removal of volatile is safe (visibility, ordering)
> when the producer thread and consumer thread can be different?

The short version is, volatile protects against compiler reordering code
where it thinks variable can't change. The atomic primitives protect against
load/store ordering issues on non-cache coherent CPU architectures.
The DPDK design pattern has been that statistics don't need to be
protected since producer is single thread and consumer should be ok
with slightly out of date data. The point is that using atomic requires
going out of cache on ARM (where it would matter) and on x86 locked
operations cause a pipeline stall. At the high data rates in DPDK
any stall or cache miss matters.

The one exception would be drivers that advertise lock free transmit
would need to use atomic on the Tx stats to avoid multi-producer problems.

  reply	other threads:[~2026-01-28 21:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 17:30 [RFC 0/4] net/af_packet: cleanups and optimizations Stephen Hemminger
2026-01-28 17:30 ` [RFC 1/4] net/af_packet: remove volatile from statistics Stephen Hemminger
2026-01-28 19:57   ` Scott Mitchell
2026-01-28 21:00     ` Stephen Hemminger [this message]
2026-02-02  7:02       ` Scott Mitchell
2026-02-02 17:34         ` Stephen Hemminger
2026-02-02 19:12           ` Scott Mitchell
2026-02-02 20:12             ` Stephen Hemminger
2026-01-28 17:30 ` [RFC 2/4] test: add test for af_packet Stephen Hemminger
2026-01-28 20:36   ` Scott Mitchell
2026-01-28 21:45     ` Stephen Hemminger
2026-01-28 17:30 ` [RFC 3/4] net/af_packet: fix indentation Stephen Hemminger
2026-01-28 17:30 ` [RFC 4/4] net/af_packet: add VPP-style prefetching to receive path Stephen Hemminger
2026-01-29  1:06   ` Stephen Hemminger
2026-01-29  9:00     ` Morten Brørup
2026-02-02  7:09       ` Scott Mitchell
2026-02-02 18:43       ` Stephen Hemminger
2026-02-03  7:31         ` Morten Brørup

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=20260128130014.0489e0a0@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=linville@tuxdriver.com \
    --cc=scott.k.mitch1@gmail.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