Skip to contentSkip to conversation

atomic.h: Use __atomic_load_n() for acquire

PATCH In review Pranith Kumar 2 participants 3 messages Nov 1, 2016 Atomic infrastructure

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 atomic.h: Use __atomic_load_n() for acquire

We can use __atomic_load_n() saving a store and load from the _val.

---
 include/qemu/atomic.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/qemu/atomic.h +1 -3
index 878fa07..6775603 100644
@@ -144,9 +144,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 {              \
Signature · 1 line
2.10.2
#1 lore raw
Quoted 13 lines · Pranith Kumar

We can use __atomic_load_n() saving a store and load from the _val.

---
 include/qemu/atomic.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/qemu/atomic.h +0 -0
index 878fa07..6775603 100644

include/qemu/atomic.h line 150

Quoted 10 lines
include/qemu/atomic.h +1 -3
@@ -144,9 +144,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 {              \

Can you do the same for atomic_rcu_read__nocheck (both implementations)?

Thanks,

Paolo

#2 lore raw
Quoted 3 lines · Paolo Bonzini

Can you do the same for atomic_rcu_read__nocheck (both implementations)?

Sure, will send an updated patch.

Signature · 1 line
Pranith