From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Torvald Riegel <triegel@redhat.com>
Cc: Andrew Haley <aph@redhat.com>,
qemu-devel@nongnu.org, Liu Ping Fan <qemulist@gmail.com>,
Anthony Liguori <anthony@codemonkey.ws>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] Java volatile vs. C11 seq_cst (was Re: [PATCH v2 1/2] add a header file for atomic operations)
Date: Tue, 18 Jun 2013 18:57:18 -0700 [thread overview]
Message-ID: <20130619015718.GZ5146@linux.vnet.ibm.com> (raw)
In-Reply-To: <1371573518.16968.23603.camel@triegel.csb>
On Tue, Jun 18, 2013 at 06:38:38PM +0200, Torvald Riegel wrote:
> On Tue, 2013-06-18 at 18:08 +0200, Paolo Bonzini wrote:
> > Il 18/06/2013 16:50, Paul E. McKenney ha scritto:
> > > PS: Nevertheless, I personally prefer the C++ formulation, but that is
> > > only because I stand with one foot in theory and the other in
> > > practice. If I were a pure practitioner, I would probably strongly
> > > prefer the Java formulation.
> >
> > Awesome answer, and this last paragraph sums it up pretty well.
>
> I disagree that for non-Java code the Java model should be better. Both
> C11 and C++11 use the same model, and I don't see a reason to not use it
> if you're writing C/C++ code anyway.
>
> The C++ model is definitely useful for practitioners; just because it
> uses seq-cst memory order as safe default doesn't mean that programmers
> that can deal with weaker ordering guarantees can't make use of those
> weaker ones.
> I thought Paul was referring to seq-cst as default; if that wasn't the
> point he wanted to make, I actually don't understand his theory/practice
> comparison (never mind that whenever you need to reason about concurrent
> stuff, having a solid formal framework as the one by the Cambridge group
> is definitely helpful). Seq-cst and acq-rel are just different
> guarantees -- this doesn't mean that one is better than the other; you
> need to understand anyway what you're doing and which one you need.
> Often, ensuring a synchronized-with edge by pairing release/acquire will
> be sufficient, but that doesn't say anything about the Java vs. C/C++
> model.
Having the Cambridge group's model and tooling around has definitely
made my life much easier!
And yes, I do very much see a need for a wide range of ordering/overhead
tradeoffs, at least until such time as someone figures a way around
either the atomic nature of matter or the finite speed of light. ;-)
Thanx, Paul
> > That was basically my understanding, too. I still do not completely
> > get the relationship between Java semantics and ACQ_REL, but I can
> > sidestep the issue for adding portable atomics to QEMU. QEMU
> > developers and Linux developers have some overlap, and Java volatiles
> > are simple to understand in terms of memory barriers (which Linux
> > uses); hence, I'll treat ourselves as pure practitioners.
>
> I don't think that this is the conclusion here. I strongly suggest to
> just go with the C11/C++11 model, instead of rolling your own or trying
> to replicate the Java model. That would also allow you to just point to
> the C11 model and any information / tutorials about it instead of having
> to document your own (see the patch), and you can make use of any
> (future) tool support (e.g., race detectors).
>
> > I will just not use __atomic_load/__atomic_store to implement the
> > primitives, and always express them in terms of memory barriers.
>
> Why? (If there's some QEMU-specific reason, just let me know; I know
> little about QEMU..)
> I would assume that using the __atomic* builtins is just fine if they're
> available.
>
>
> Torvald
>
next prev parent reply other threads:[~2013-06-19 1:57 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-16 11:21 [Qemu-devel] [PATCH v2 0/2] make AioContext's bh re-entrant Liu Ping Fan
2013-06-16 11:21 ` [Qemu-devel] [PATCH v2 1/2] add a header file for atomic operations Liu Ping Fan
2013-06-17 18:57 ` Richard Henderson
2013-06-18 8:36 ` Paolo Bonzini
2013-06-18 11:03 ` Paolo Bonzini
2013-06-18 14:38 ` Richard Henderson
2013-06-18 15:04 ` Paolo Bonzini
2013-06-18 13:24 ` [Qemu-devel] Java volatile vs. C11 seq_cst (was Re: [PATCH v2 1/2] add a header file for atomic operations) Paolo Bonzini
2013-06-18 14:50 ` Paul E. McKenney
2013-06-18 15:29 ` Peter Sewell
2013-06-18 15:37 ` Torvald Riegel
2013-06-19 1:53 ` Paul E. McKenney
2013-06-19 7:11 ` Torvald Riegel
2013-06-20 15:18 ` Paul E. McKenney
2013-06-18 16:08 ` Paolo Bonzini
2013-06-18 16:38 ` Torvald Riegel
2013-06-19 1:57 ` Paul E. McKenney [this message]
2013-06-19 9:31 ` Paolo Bonzini
2013-06-19 13:15 ` Torvald Riegel
2013-06-19 15:14 ` Paolo Bonzini
2013-06-19 20:25 ` Torvald Riegel
2013-06-20 7:53 ` Paolo Bonzini
2013-06-22 10:55 ` Torvald Riegel
2013-06-18 15:26 ` Torvald Riegel
2013-06-18 17:38 ` Andrew Haley
2013-06-19 9:30 ` Paolo Bonzini
2013-06-19 15:36 ` Andrew Haley
2013-06-16 11:21 ` [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant Liu Ping Fan
2013-06-17 15:28 ` Stefan Hajnoczi
2013-06-17 16:41 ` Paolo Bonzini
2013-06-18 2:19 ` liu ping fan
2013-06-18 9:31 ` Stefan Hajnoczi
2013-06-18 15:14 ` mdroth
2013-06-18 16:19 ` mdroth
2013-06-18 19:20 ` Paolo Bonzini
2013-06-18 22:26 ` mdroth
2013-06-19 9:27 ` Paolo Bonzini
2013-06-20 9:11 ` Stefan Hajnoczi
2013-06-17 7:11 ` [Qemu-devel] [PATCH v2 0/2] " Paolo Bonzini
2013-06-18 2:40 ` liu ping fan
2013-06-18 8:36 ` Paolo Bonzini
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=20130619015718.GZ5146@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=anthony@codemonkey.ws \
--cc=aph@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemulist@gmail.com \
--cc=rth@twiddle.net \
--cc=triegel@redhat.com \
/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.