Messages in this thread Patch in this message | | | Date | Thu, 2 Dec 2010 16:06:15 -0600 (CST) | From | Christoph Lameter <> | Subject | [rfc: cpuops adv V1 2/8] Fallback to atomic xchg, cmpxchg |
| |
Sorry this should have been:
Subject: this_cpu_xchg/cmpxchg: Fall back to atomic xchg, cmpxchg
It may be better if we fall back to the full operation instead of simulation through irq disable etc.
Signed-off-by: Christoph Lameter <cl@linux.com>
--- include/linux/percpu.h | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-)
Index: linux-2.6/include/linux/percpu.h =================================================================== --- linux-2.6.orig/include/linux/percpu.h 2010-12-02 12:17:14.000000000 -0600 +++ linux-2.6/include/linux/percpu.h 2010-12-02 12:17:30.000000000 -0600 @@ -361,14 +361,7 @@ do { \ # define __this_cpu_xchg(pcp, nval) __pcpu_size_call_return2(__this_cpu_xchg_, (pcp), nval) #endif
-#define _this_cpu_generic_xchg(pcp, nval) \ -({ typeof(pcp) ret__; \ - preempt_disable(); \ - ret__ = __this_cpu_read(pcp); \ - __this_cpu_write(pcp, nval); \ - preempt_enable(); \ - ret__; \ -}) +#define _this_cpu_generic_xchg(pcp, nval) xchg(__this_cpu_ptr(&(pcp)), nval)
#ifndef this_cpu_xchg # ifndef this_cpu_xchg_1 @@ -386,15 +379,7 @@ do { \ # define this_cpu_xchg(pcp, nval) __pcpu_size_call_return2(this_cpu_xchg_, (pcp), nval) #endif
-#define _this_cpu_generic_cmpxchg(pcp, oval, nval) \ -({ typeof(pcp) ret__; \ - preempt_disable(); \ - ret__ = __this_cpu_read(pcp); \ - if (ret__ == (oval)) \ - __this_cpu_write(pcp, nval); \ - preempt_enable(); \ - ret__; \ -}) +#define _this_cpu_generic_cmpxchg(pcp, oval, nval) cmpxchg(__this_cpu_ptr(&(pcp)), oval, nval);
#ifndef this_cpu_cmpxchg # ifndef this_cpu_cmpxchg_1 @@ -892,17 +877,7 @@ do { \ # define irqsafe_cpu_xor(pcp, val) __pcpu_size_call(irqsafe_cpu_xor_, (val)) #endif
-#define irqsafe_cpu_generic_cmpxchg(pcp, oval, nval) \ -({ \ - typeof(pcp) ret__; \ - unsigned long flags; \ - local_irq_save(flags); \ - ret__ = __this_cpu_read(pcp); \ - if (ret__ == (oval)) \ - __this_cpu_write(pcp, nval); \ - local_irq_restore(flags); \ - ret__; \ -}) +#define irqsafe_cpu_generic_cmpxchg(pcp, oval, nval) cmpxchg(__this_cpu_ptr(&(pcp), oval, nval)
#ifndef irqsafe_cpu_cmpxchg # ifndef irqsafe_cpu_cmpxchg_1
| |