Skip to content

Commit 677243d

Browse files
Brian Gersthtejun
authored andcommitted
percpu: Optimize __get_cpu_var()
Redefine __get_cpu_var() using this_cpu_ptr() which can be arch-optimized. Signed-off-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent db7829c commit 677243d

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎include/asm-generic/percpu.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
5555
*/
5656
#define per_cpu(var, cpu) \
5757
(*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu)))
58-
#define __get_cpu_var(var) \
59-
(*SHIFT_PERCPU_PTR(&(var), my_cpu_offset))
60-
#define __raw_get_cpu_var(var) \
61-
(*SHIFT_PERCPU_PTR(&(var), __my_cpu_offset))
6258

6359
#ifndef __this_cpu_ptr
6460
#define __this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
@@ -69,6 +65,9 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
6965
#define this_cpu_ptr(ptr) __this_cpu_ptr(ptr)
7066
#endif
7167

68+
#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
69+
#define __raw_get_cpu_var(var) (*__this_cpu_ptr(&(var)))
70+
7271
#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
7372
extern void setup_per_cpu_areas(void);
7473
#endif

0 commit comments

Comments
 (0)