aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-06-17 19:12:34 -0400
committerTejun Heo <tj@kernel.org>2014-06-17 19:12:34 -0400
commit62fde54123fb64879326c8b71c3f92cc5db1c452 (patch)
tree18a08129d3d2360e60af18d091c079f52c73b421 /include/asm-generic
parentbbc344e1e3aef3034a0edc79f7f64a912517926b (diff)
percpu: include/asm-generic/percpu.h should contain only arch-overridable parts
The roles of the various percpu header files has become unclear. There are four header files involved. include/linux/percpu-defs.h include/linux/percpu.h include/asm-generic/percpu.h arch/*/include/asm/percpu.h The original intention for include/asm-generic/percpu.h is providing generic definitions for arch-overridable parts; however, it now hosts various stuff which can't be overridden by archs. Also, include/linux/percpu-defs.h was initially added to contain section and percpu variable definition macros so that arch header files can make use of them without worrying about introducing cyclic inclusion dependency by including include/linux/percpu.h; however, arch headers sometimes need to access percpu variables too and this is one of the reasons why some accessors were implemented in include/linux/asm-generic/percpu.h. Let's clear up the situation by making include/asm-generic/percpu.h contain only arch-overridable parts and moving accessors and operations into include/linux/percpu-defs. Note that this patch only moves things from include/asm-generic/percpu.h. include/linux/percpu.h will be taken care of by later patches. This patch moves the followings. * SHIFT_PERCPU_PTR() / VERIFY_PERCPU_PTR() * per_cpu() * raw_cpu_ptr() * this_cpu_ptr() * __get_cpu_var() * __raw_get_cpu_var() * __this_cpu_ptr() * PER_CPU_[SHARED_]ALIGNED_SECTION * PER_CPU_[SHARED_]ALIGNED_SECTION * PER_CPU_FIRST_SECTION This patch is pure reorganization. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Christoph Lameter <cl@linux.com>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/percpu.h64
1 files changed, 0 insertions, 64 deletions
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index a247d80b6630..e5ace4d49084 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -36,24 +36,6 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
36#endif 36#endif
37 37
38/* 38/*
39 * Add an offset to a pointer but keep the pointer as-is. Use RELOC_HIDE()
40 * to prevent the compiler from making incorrect assumptions about the
41 * pointer value. The weird cast keeps both GCC and sparse happy.
42 */
43#define SHIFT_PERCPU_PTR(__p, __offset) ({ \
44 __verify_pcpu_ptr((__p)); \
45 RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset)); \
46})
47
48/*
49 * A percpu variable may point to a discarded regions. The following are
50 * established ways to produce a usable pointer from the percpu variable
51 * offset.
52 */
53#define per_cpu(var, cpu) \
54 (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu)))
55
56/*
57 * Arch may define arch_raw_cpu_ptr() to provide more efficient address 39 * Arch may define arch_raw_cpu_ptr() to provide more efficient address
58 * translations for raw_cpu_ptr(). 40 * translations for raw_cpu_ptr().
59 */ 41 */
@@ -61,34 +43,10 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
61#define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset) 43#define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
62#endif 44#endif
63 45
64#define raw_cpu_ptr(ptr) arch_raw_cpu_ptr(ptr)
65
66#ifdef CONFIG_DEBUG_PREEMPT
67#define this_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, my_cpu_offset)
68#else
69#define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
70#endif
71
72#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
73#define __raw_get_cpu_var(var) (*raw_cpu_ptr(&(var)))
74
75#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA 46#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
76extern void setup_per_cpu_areas(void); 47extern void setup_per_cpu_areas(void);
77#endif 48#endif
78 49
79#else /* ! SMP */
80
81#define VERIFY_PERCPU_PTR(__p) ({ \
82 __verify_pcpu_ptr((__p)); \
83 (typeof(*(__p)) __kernel __force *)(__p); \
84})
85
86#define per_cpu(var, cpu) (*((void)(cpu), VERIFY_PERCPU_PTR(&(var))))
87#define __get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var)))
88#define __raw_get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var)))
89#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
90#define raw_cpu_ptr(ptr) this_cpu_ptr(ptr)
91
92#endif /* SMP */ 50#endif /* SMP */
93 51
94#ifndef PER_CPU_BASE_SECTION 52#ifndef PER_CPU_BASE_SECTION
@@ -99,25 +57,6 @@ extern void setup_per_cpu_areas(void);
99#endif 57#endif
100#endif 58#endif
101 59
102#ifdef CONFIG_SMP
103
104#ifdef MODULE
105#define PER_CPU_SHARED_ALIGNED_SECTION ""
106#define PER_CPU_ALIGNED_SECTION ""
107#else
108#define PER_CPU_SHARED_ALIGNED_SECTION "..shared_aligned"
109#define PER_CPU_ALIGNED_SECTION "..shared_aligned"
110#endif
111#define PER_CPU_FIRST_SECTION "..first"
112
113#else
114
115#define PER_CPU_SHARED_ALIGNED_SECTION ""
116#define PER_CPU_ALIGNED_SECTION "..shared_aligned"
117#define PER_CPU_FIRST_SECTION ""
118
119#endif
120
121#ifndef PER_CPU_ATTRIBUTES 60#ifndef PER_CPU_ATTRIBUTES
122#define PER_CPU_ATTRIBUTES 61#define PER_CPU_ATTRIBUTES
123#endif 62#endif
@@ -126,7 +65,4 @@ extern void setup_per_cpu_areas(void);
126#define PER_CPU_DEF_ATTRIBUTES 65#define PER_CPU_DEF_ATTRIBUTES
127#endif 66#endif
128 67
129/* Keep until we have removed all uses of __this_cpu_ptr */
130#define __this_cpu_ptr raw_cpu_ptr
131
132#endif /* _ASM_GENERIC_PERCPU_H_ */ 68#endif /* _ASM_GENERIC_PERCPU_H_ */