]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
[S390] Improve code generated by atomic operations.
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 7 Dec 2009 11:52:05 +0000 (12:52 +0100)
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>
Mon, 7 Dec 2009 11:51:36 +0000 (12:51 +0100)
Git commit ea435467500612636f8f4fb639ff6e76b2496e4b changed the
definition of atomic_t and atomic64_t for s390 by adding the volatile
modifier to the counter field. This has an unfortunate side effect
with newer versions of the gcc. The typeof operator now picks up the
volatile modifier from the expression. This causes the compiler to
think that it has to store the two temporary variable old_val and
new_val in the __CS_LOOP for the different atomic operations to the
stack as the variables are now volatile. Both stores are superfluous.

The hack to replace typeof(ptr->counter) with int in __CS_LOOP and
and long long in __CSG_LOOP avoids the two stores. A better solution
would be to drop the volatile from the counter field of the atomic_t
and atomic64_t definition. But that is a touchy subject ..

Cc: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/atomic.h

index ae7c8f9f94a5132933a4afff6efc0142adbe292c..2a113d6a7dfd1fe95d63ba1c73edd49449f8c4e0 100644 (file)
@@ -21,7 +21,7 @@
 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
 
 #define __CS_LOOP(ptr, op_val, op_string) ({                           \
-       typeof(ptr->counter) old_val, new_val;                          \
+       int old_val, new_val;                                           \
        asm volatile(                                                   \
                "       l       %0,%2\n"                                \
                "0:     lr      %1,%0\n"                                \
@@ -38,7 +38,7 @@
 #else /* __GNUC__ */
 
 #define __CS_LOOP(ptr, op_val, op_string) ({                           \
-       typeof(ptr->counter) old_val, new_val;                          \
+       int old_val, new_val;                                           \
        asm volatile(                                                   \
                "       l       %0,0(%3)\n"                             \
                "0:     lr      %1,%0\n"                                \
@@ -143,7 +143,7 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
 
 #define __CSG_LOOP(ptr, op_val, op_string) ({                          \
-       typeof(ptr->counter) old_val, new_val;                          \
+       long long old_val, new_val;                                     \
        asm volatile(                                                   \
                "       lg      %0,%2\n"                                \
                "0:     lgr     %1,%0\n"                                \
@@ -160,7 +160,7 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
 #else /* __GNUC__ */
 
 #define __CSG_LOOP(ptr, op_val, op_string) ({                          \
-       typeof(ptr->counter) old_val, new_val;                          \
+       long long old_val, new_val;                                     \
        asm volatile(                                                   \
                "       lg      %0,0(%3)\n"                             \
                "0:     lgr     %1,%0\n"                                \