From: Olivier MATZ <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: "Ananyev,
Konstantin"
<konstantin.ananyev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"dev-VfR2kkLFssw@public.gmane.org"
<dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: [PATCH] atomic: clarify use of memory barriers
Date: Tue, 20 May 2014 14:12:36 +0200 [thread overview]
Message-ID: <537B46B4.4000202@6wind.com> (raw)
In-Reply-To: <2601191342CEEE43887BDE71AB9772580EFA776F-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
Hi Konstantin,
Thank you for your review and feedback.
On 05/20/2014 12:05 PM, Ananyev, Konstantin wrote:
>> Note that on x86 CPUs, memory barriers between different cores can be guaranteed by a simple compiler barrier.
>
> I don't think this is totally correct.
> Yes, for Intel cpus in many cases memory barrier could be avoided due to nearly strict memory ordering.
> Though there are few cases where reordering is possible and when fence instructions would be needed.
I tried to mimic the behavior of linux that differentiates *mb() from
smp_*mb(), but I did too fast. In linux, we have [1]:
smp_mb() = mb() = asm volatile("mfence":::"memory")
smp_rmb() = compiler_barrier()
smp_wmb() = compiler_barrier()
At least this should fixed in the patch. By the way, just for reference,
the idea of the patch came from a discussion we had on the list [2].
> For me:
> +#define rte_smp_rmb() rte_compiler_barrier()
> Seems a bit misleading, as there is no real fence.
> So I suggest we keep rte_compiler_barrier() naming and usage.
The objectives of the patch (which was probably not explained very
clearly in the commit log) were:
- make the code more readable to distinguish between the 2 kinds of
memory barrier.
- optimize some code to avoid a real memory barrier when not required
(timers, virtio, ...)
Having a compiler barrier in place of a memory barrier in the code
does not really help to understand what the developper wanted to do.
In the current code we can see that the use of rte_compiler_barrier()
is ambiguous, as it need a comment to clarify the situation:
rte_compiler_barrier(); /* rmb */
Don't you think we could fix the patch but keep its logic?
Regards,
Olivier
[1] http://lxr.free-electrons.com/source/arch/x86/include/asm/barrier.h#L81
[2] http://dpdk.org/ml/archives/dev/2014-March/001741.html
next prev parent reply other threads:[~2014-05-20 12:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 9:36 [PATCH] atomic: clarify use of memory barriers Olivier Matz
[not found] ` <1400578588-21137-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-05-20 10:05 ` Ananyev, Konstantin
[not found] ` <2601191342CEEE43887BDE71AB9772580EFA776F-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-05-20 12:12 ` Olivier MATZ [this message]
[not found] ` <537B46B4.4000202-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-05-20 16:35 ` Ananyev, Konstantin
2014-05-23 14:10 ` Olivier MATZ
[not found] ` <537F56C3.3060503-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-05-26 13:57 ` Ananyev, Konstantin
[not found] ` <2601191342CEEE43887BDE71AB9772580EFB0A95-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-05-26 14:20 ` Olivier MATZ
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=537B46B4.4000202@6wind.com \
--to=olivier.matz-pdr9zngts4eavxtiumwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
--cc=konstantin.ananyev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.