On Wed, 28 Jan 2026 11:57:16 -0800 Scott Mitchell <[email protected]> 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.

