From: Richard Henderson <rth@twiddle.net>
To: Liu Ping Fan <qemulist@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] atomic: using memory_order_relaxed for refcnt inc/dec ops
Date: Fri, 12 Jul 2013 09:24:14 -0700 [thread overview]
Message-ID: <51E02DAE.3040204@twiddle.net> (raw)
In-Reply-To: <1373610771-11819-1-git-send-email-pingfank@linux.vnet.ibm.com>
On 07/11/2013 11:32 PM, Liu Ping Fan wrote:
> Refcnt's atomic inc/dec ops are frequent and its idiom need no seq_cst
> order. So to get better performance, it worth to adopt _relaxed
> other than _seq_cst memory model on them.
You'd need to update the documentation then. As it stands, what you've written
looks like a bug.
> +#ifndef _GLIBCXX_ATOMIC_BUILTINS
This will never be defined. It's private to the libstdc++ implementation. See
how we've defined things using __atomic elsewhere in the file, looking at one
of the __ATOMIC defines.
And in either case, it's better form to use positive tests than negative ones.
I.e. #ifdef rather than #ifndef
> #define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1)
> #define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1)
I'd prefer atomic_fetch_inc_relaxed, as that's more self-documenting.
But I'll re-iterate the necessity of documentation in this area.
r~
next prev parent reply other threads:[~2013-07-12 16:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-12 6:32 [Qemu-devel] [PATCH] atomic: using memory_order_relaxed for refcnt inc/dec ops Liu Ping Fan
2013-07-12 16:24 ` Richard Henderson [this message]
2013-07-14 2:18 ` liu ping fan
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=51E02DAE.3040204@twiddle.net \
--to=rth@twiddle.net \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemulist@gmail.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.