qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pranith Kumar <bobby.prani@gmail.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Emilio G. Cota" <cota@braap.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Richard Henderson" <rth@twiddle.net>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] atomic.h: Use __atomic_load_n() primitive
Date: Tue,  1 Nov 2016 16:39:53 -0400	[thread overview]
Message-ID: <20161101203953.18065-1-bobby.prani@gmail.com> (raw)

Use __atomic_load_n() primitive saving a load and store to a local
variable.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 include/qemu/atomic.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 878fa07..be44094 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -120,20 +120,22 @@
  * same, but this slows down atomic_rcu_read unnecessarily.
  */
 #ifdef __SANITIZE_THREAD__
-#define atomic_rcu_read__nocheck(ptr, valptr)           \
-    __atomic_load(ptr, valptr, __ATOMIC_CONSUME);
+#define atomic_rcu_read__nocheck(ptr)                 \
+    __atomic_load_n(ptr, __ATOMIC_CONSUME);
 #else
-#define atomic_rcu_read__nocheck(ptr, valptr)           \
-    __atomic_load(ptr, valptr, __ATOMIC_RELAXED);       \
-    smp_read_barrier_depends();
+#define atomic_rcu_read__nocheck(ptr)                 \
+    ({                                                \
+    typeof_strip_qual(*ptr) _val;                     \
+    __atomic_load(ptr, &_val, __ATOMIC_RELAXED);      \
+    smp_read_barrier_depends();                       \
+    _val;                                             \
+    })
 #endif
 
 #define atomic_rcu_read(ptr)                          \
     ({                                                \
     QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \
-    typeof_strip_qual(*ptr) _val;                     \
-    atomic_rcu_read__nocheck(ptr, &_val);             \
-    _val;                                             \
+    atomic_rcu_read__nocheck(ptr);                    \
     })
 
 #define atomic_rcu_set(ptr, i) do {                   \
@@ -144,9 +146,7 @@
 #define atomic_load_acquire(ptr)                        \
     ({                                                  \
     QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
-    typeof_strip_qual(*ptr) _val;                       \
-    __atomic_load(ptr, &_val, __ATOMIC_ACQUIRE);        \
-    _val;                                               \
+    __atomic_load_n(ptr, __ATOMIC_ACQUIRE);             \
     })
 
 #define atomic_store_release(ptr, i)  do {              \
-- 
2.10.2

             reply	other threads:[~2016-11-01 20:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-01 20:39 Pranith Kumar [this message]
2016-11-01 20:42 ` [Qemu-devel] [PATCH] atomic.h: Use __atomic_load_n() primitive no-reply

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=20161101203953.18065-1-bobby.prani@gmail.com \
    --to=bobby.prani@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=cota@braap.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 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).