diff mbox

atomic.h: Use __atomic_load_n() primitive

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

Commit Message

Pranith Kumar Nov. 1, 2016, 8:39 p.m. UTC
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(-)

Comments

no-reply@patchew.org Nov. 1, 2016, 8:42 p.m. UTC | #1
Hi,

Your series seems to have some coding style problems. See output below for
more information:

Type: series
Subject: [Qemu-devel] [PATCH] atomic.h: Use __atomic_load_n() primitive
Message-id: 20161101203953.18065-1-bobby.prani@gmail.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/1478022256-7089-1-git-send-email-wei.liu2@citrix.com -> patchew/1478022256-7089-1-git-send-email-wei.liu2@citrix.com
 - [tag update]      patchew/20161101171927.25684-1-sw@weilnetz.de -> patchew/20161101171927.25684-1-sw@weilnetz.de
 * [new tag]         patchew/20161101203953.18065-1-bobby.prani@gmail.com -> patchew/20161101203953.18065-1-bobby.prani@gmail.com
Switched to a new branch 'test'
587647b atomic.h: Use __atomic_load_n() primitive

=== OUTPUT BEGIN ===
fatal: unrecognized argument: --no-patch
Checking PATCH 1/1: ...
ERROR: memory barrier without comment
#32: FILE: include/qemu/atomic.h:130:
+    smp_read_barrier_depends();                       \

total: 1 errors, 0 warnings, 40 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
diff mbox

Patch

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 {              \