* [dpdk-dev] release/acquire memory barriers and ring
@ 2018-02-13 19:37 Alex Kiselev
2018-02-13 19:43 ` Alex Kiselev
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alex Kiselev @ 2018-02-13 19:37 UTC (permalink / raw)
To: dev
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] release/acquire memory barriers and ring
2018-02-13 19:37 [dpdk-dev] release/acquire memory barriers and ring Alex Kiselev
@ 2018-02-13 19:43 ` Alex Kiselev
2018-02-16 17:58 ` Stephen Hemminger
2018-02-17 13:59 ` Burakov, Anatoly
2 siblings, 0 replies; 4+ messages in thread
From: Alex Kiselev @ 2018-02-13 19:43 UTC (permalink / raw)
To: dev
I am sorry. I should've posted to the user list of couse.
My mistake.
2018-02-13 22:37 GMT+03:00 Alex Kiselev <kiselev99@gmail.com>:
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] release/acquire memory barriers and ring
2018-02-13 19:37 [dpdk-dev] release/acquire memory barriers and ring Alex Kiselev
2018-02-13 19:43 ` Alex Kiselev
@ 2018-02-16 17:58 ` Stephen Hemminger
2018-02-17 13:59 ` Burakov, Anatoly
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2018-02-16 17:58 UTC (permalink / raw)
To: Alex Kiselev; +Cc: dev
On Tue, 13 Feb 2018 22:37:37 +0300
Alex Kiselev <kiselev99@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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] release/acquire memory barriers and ring
2018-02-13 19:37 [dpdk-dev] release/acquire memory barriers and ring Alex Kiselev
2018-02-13 19:43 ` Alex Kiselev
2018-02-16 17:58 ` Stephen Hemminger
@ 2018-02-17 13:59 ` Burakov, Anatoly
2 siblings, 0 replies; 4+ messages in thread
From: Burakov, Anatoly @ 2018-02-17 13:59 UTC (permalink / raw)
To: dev
On 13-Feb-18 7:37 PM, Alex Kiselev 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
>
Rings do that automatically, no additional fences needed.
--
Thanks,
Anatoly
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-17 13:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 19:37 [dpdk-dev] release/acquire memory barriers and ring Alex Kiselev
2018-02-13 19:43 ` Alex Kiselev
2018-02-16 17:58 ` Stephen Hemminger
2018-02-17 13:59 ` Burakov, Anatoly
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).