diff mbox

atomic.h: Use __atomic_load_n() for acquire

Message ID 20161101143303.19657-1-bobby.prani@gmail.com
State New
Headers show

Commit Message

Pranith Kumar Nov. 1, 2016, 2:33 p.m. UTC
We can use __atomic_load_n() saving a store and load from the _val.

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

Comments

Paolo Bonzini Nov. 1, 2016, 2:44 p.m. UTC | #1
On 01/11/2016 15:33, Pranith Kumar wrote:
> We can use __atomic_load_n() saving a store and load from the _val.
> 
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
> ---
>  include/qemu/atomic.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
> index 878fa07..6775603 100644
> --- a/include/qemu/atomic.h
> +++ b/include/qemu/atomic.h
> @@ -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
Pranith Kumar Nov. 1, 2016, 2:45 p.m. UTC | #2
On Tue, Nov 1, 2016 at 10:44 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:

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

Sure, will send an updated patch.
diff mbox

Patch

diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 878fa07..6775603 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -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 {              \