Skip to content

Commit 18cb2ae

Browse files
namhyunghtejun
authored andcommitted
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>
1 parent 4a386c3 commit 18cb2ae

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎include/asm-generic/percpu.h‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ extern void setup_per_cpu_areas(void);
7070

7171
#else /* ! SMP */
7272

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)
7883

7984
#endif /* SMP */
8085

‎include/linux/percpu.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ extern void __init percpu_init_late(void);
149149

150150
#else /* CONFIG_SMP */
151151

152-
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
152+
#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); })
153153

154154
/* can't distinguish from other static vars, always false */
155155
static inline bool is_kernel_percpu_address(unsigned long addr)

0 commit comments

Comments
 (0)