On Thu, 2 May 2024 19:37:28 +0200 Mattias Rönnblom <hof...@lysator.liu.se> wrote:
> > > > Do we need to declare count as '_Atomic', I wasn't planning to make > > variable _Atomic. This way assignment won't introduce any memory barrier. > > > > To use atomics in DPDK, the current requirements seems to be to use > RTE_ATOMIC(). That macro expands to _Atomic in enable_stdatomic=true > builds, and nothing otherwise. > > Carefully crafted code using atomics will achieved the same performance > and be more correct than the non-atomic variant. However, in practice, I > think the non-atomic variant is very likely to produce the desired results. You are confusing atomic usage for thread safety, with the necessity of compiler barriers. Stats should not be volatile.