summaryrefslogtreecommitdiffstats
path: root/include/asm-generic/percpu.h
diff options
context:
space:
mode:
authorBrian Gerst <brgerst@gmail.com>2010-09-09 18:17:26 +0200
committerTejun Heo <tj@kernel.org>2010-09-10 10:56:47 +0200
commitdb7829c6cc32f3c0c9a324118d743acb1abff081 (patch)
treedd40c271aeda63843819072c753af74fefc1413c /include/asm-generic/percpu.h
parentpercpu: clear memory allocated with the km allocator (diff)
downloadlinux-db7829c6cc32f3c0c9a324118d743acb1abff081.tar.xz
linux-db7829c6cc32f3c0c9a324118d743acb1abff081.zip
x86, percpu: Optimize this_cpu_ptr
Allow arches to implement __this_cpu_ptr, and provide an x86 version. Before: movq $foo, %rax movq %gs:this_cpu_off, %rdx addq %rdx, %rax After: movq $foo, %rax addq %gs:this_cpu_off, %rax The benefit is doing it in one less instruction and not clobbering a temporary register. tj: * Beefed up the comment a bit and renamed in-macro temp variable to match neighboring macros. * Folded fix for const pointer case found in linux-next. * Fixed sparse notation. Signed-off-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/asm-generic/percpu.h')
-rw-r--r--include/asm-generic/percpu.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 08923b684768..ec643115bb56 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -60,9 +60,14 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
#define __raw_get_cpu_var(var) \
(*SHIFT_PERCPU_PTR(&(var), __my_cpu_offset))
-#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset)
+#ifndef __this_cpu_ptr
#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
-
+#endif
+#ifdef CONFIG_DEBUG_PREEMPT
+#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset)
+#else
+#define this_cpu_ptr(ptr) __this_cpu_ptr(ptr)
+#endif
#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
extern void setup_per_cpu_areas(void);