Commit 18cb2aef91b37dbce2bec2f39bb1dddd0e9dd838
Committed by
Tejun Heo
1 parent
4a386c3e17
Exists in
master
and in
7 other branches
percpu: handle __percpu notations in UP accessors
UP accessors didn't take care of __percpu notations leading to a lot of spurious sparse warnings on UP configurations. Fix it. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Showing 2 changed files with 11 additions and 6 deletions Side-by-side Diff
include/asm-generic/percpu.h
... | ... | @@ -70,11 +70,16 @@ |
70 | 70 | |
71 | 71 | #else /* ! SMP */ |
72 | 72 | |
73 | -#define per_cpu(var, cpu) (*((void)(cpu), &(var))) | |
74 | -#define __get_cpu_var(var) (var) | |
75 | -#define __raw_get_cpu_var(var) (var) | |
76 | -#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | |
77 | -#define __this_cpu_ptr(ptr) this_cpu_ptr(ptr) | |
73 | +#define VERIFY_PERCPU_PTR(__p) ({ \ | |
74 | + __verify_pcpu_ptr((__p)); \ | |
75 | + (typeof(*(__p)) __kernel __force *)(__p); \ | |
76 | +}) | |
77 | + | |
78 | +#define per_cpu(var, cpu) (*((void)(cpu), VERIFY_PERCPU_PTR(&(var)))) | |
79 | +#define __get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var))) | |
80 | +#define __raw_get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var))) | |
81 | +#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | |
82 | +#define __this_cpu_ptr(ptr) this_cpu_ptr(ptr) | |
78 | 83 | |
79 | 84 | #endif /* SMP */ |
80 | 85 |
include/linux/percpu.h
... | ... | @@ -149,7 +149,7 @@ |
149 | 149 | |
150 | 150 | #else /* CONFIG_SMP */ |
151 | 151 | |
152 | -#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) | |
152 | +#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); }) | |
153 | 153 | |
154 | 154 | /* can't distinguish from other static vars, always false */ |
155 | 155 | static inline bool is_kernel_percpu_address(unsigned long addr) |