[dpdk-dev] release/acquire memory barriers and ring

Stephen Hemminger stephen at networkplumber.org
Fri Feb 16 18:58:12 CET 2018


On Tue, 13 Feb 2018 22:37:37 +0300
Alex Kiselev <kiselev99 at gmail.com> wrote:

> Hi.
> 
> I've been wondering should I use a release/acquire memory barrier pair
> in order to be sure that the other thread will see the fully/corrected
> initialized object
> passed to it via a dpdk ring or ring itself is a kind of barrier?
> 
> Let's say I have a pseudo code:
> 
> Thread1:
> obj = alloc();
> ...
> obj initialization
> ...
> 
> ??? fence(memory_order_release); ???
> rte_ring_sp_enqueue(ring, obj)
> 
> 
> Thread2:
> ??? fence(memory_order_acquire); ???
> rte_ring_sc_dequeue(ring, obj)
> 
> Should I use fences in that code?
> 
> Thanks.
> 
> --
> Alex

Not necessary. Enqueue/dequeue has necessary ordering; it is built
on compare-exchange which has implied barrier.


More information about the dev mailing list