[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48466BFB.40004@goop.org>
Date: Wed, 04 Jun 2008 11:18:35 +0100
From: Jeremy Fitzhardinge <jeremy@...p.org>
To: Mike Travis <travis@....com>
CC: Ingo Molnar <mingo@...e.hu>,
Andrew Morton <akpm@...ux-foundation.org>,
Christoph Lameter <clameter@....com>,
David Miller <davem@...emloft.net>,
Eric Dumazet <dada1@...mosbay.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] x86: collapse the various size-dependent percpu accessors
together
We can use gcc's %z modifier to emit the appropriate size suffix for
an instruction, so we don't need to duplicate the asm statement for
each size.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
---
include/asm-x86/percpu.h | 56 +++-------------------------------------------
1 file changed, 4 insertions(+), 52 deletions(-)
===================================================================
--- a/include/asm-x86/percpu.h
+++ b/include/asm-x86/percpu.h
@@ -75,22 +75,10 @@
} \
switch (sizeof(var)) { \
case 1: \
- asm(op "b %1,"__percpu_seg"%0" \
- : "+m" (var) \
- : "ri" ((T__)val)); \
- break; \
case 2: \
- asm(op "w %1,"__percpu_seg"%0" \
- : "+m" (var) \
- : "ri" ((T__)val)); \
- break; \
case 4: \
- asm(op "l %1,"__percpu_seg"%0" \
- : "+m" (var) \
- : "ri" ((T__)val)); \
- break; \
case 8: \
- asm(op "q %1,"__percpu_seg"%0" \
+ asm(op "%z0 %1,"__percpu_seg"%0" \
: "+m" (var) \
: "ri" ((T__)val)); \
break; \
@@ -103,22 +91,10 @@
typeof(var) ret__; \
switch (sizeof(var)) { \
case 1: \
- asm(op "b "__percpu_seg"%1,%0" \
- : "=r" (ret__) \
- : "m" (var)); \
- break; \
case 2: \
- asm(op "w "__percpu_seg"%1,%0" \
- : "=r" (ret__) \
- : "m" (var)); \
- break; \
case 4: \
- asm(op "l "__percpu_seg"%1,%0" \
- : "=r" (ret__) \
- : "m" (var)); \
- break; \
case 8: \
- asm(op "q "__percpu_seg"%1,%0" \
+ asm(op "%z1 "__percpu_seg"%1,%0" \
: "=r" (ret__) \
: "m" (var)); \
break; \
@@ -131,19 +107,10 @@
({ \
switch (sizeof(var)) { \
case 1: \
- asm(op "b "__percpu_seg"%0" \
- : : "m"(var)); \
- break; \
case 2: \
- asm(op "w "__percpu_seg"%0" \
- : : "m"(var)); \
- break; \
case 4: \
- asm(op "l "__percpu_seg"%0" \
- : : "m"(var)); \
- break; \
case 8: \
- asm(op "q "__percpu_seg"%0" \
+ asm(op "%z0 "__percpu_seg"%0" \
: : "m"(var)); \
break; \
default: __bad_percpu_size(); \
@@ -155,25 +122,10 @@
typeof(var) prev; \
switch (sizeof(var)) { \
case 1: \
- asm("cmpxchgb %b1, "__percpu_seg"%2" \
- : "=a"(prev) \
- : "q"(new), "m"(var), "0"(old) \
- : "memory"); \
- break; \
case 2: \
- asm("cmpxchgw %w1, "__percpu_seg"%2" \
- : "=a"(prev) \
- : "r"(new), "m"(var), "0"(old) \
- : "memory"); \
- break; \
case 4: \
- asm("cmpxchgl %k1, "__percpu_seg"%2" \
- : "=a"(prev) \
- : "r"(new), "m"(var), "0"(old) \
- : "memory"); \
- break; \
case 8: \
- asm("cmpxchgq %1, "__percpu_seg"%2" \
+ asm("cmpxchg%z1 %1, "__percpu_seg"%2" \
: "=a"(prev) \
: "r"(new), "m"(var), "0"(old) \
: "memory"); \
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists