diff options
Diffstat (limited to 'include/linux/percpu.h')
-rw-r--r-- | include/linux/percpu.h | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 3577ffd90d45..c80cfe1260ec 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
@@ -81,23 +81,13 @@ struct percpu_data { | |||
81 | }; | 81 | }; |
82 | 82 | ||
83 | #define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata) | 83 | #define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata) |
84 | /* | ||
85 | * Use this to get to a cpu's version of the per-cpu object dynamically | ||
86 | * allocated. Non-atomic access to the current CPU's version should | ||
87 | * probably be combined with get_cpu()/put_cpu(). | ||
88 | */ | ||
89 | #define percpu_ptr(ptr, cpu) \ | ||
90 | ({ \ | ||
91 | struct percpu_data *__p = __percpu_disguise(ptr); \ | ||
92 | (__typeof__(ptr))__p->ptrs[(cpu)]; \ | ||
93 | }) | ||
94 | 84 | ||
95 | extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask); | 85 | extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask); |
96 | extern void percpu_free(void *__pdata); | 86 | extern void percpu_free(void *__pdata); |
97 | 87 | ||
98 | #else /* CONFIG_SMP */ | 88 | #else /* CONFIG_SMP */ |
99 | 89 | ||
100 | #define percpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) | 90 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) |
101 | 91 | ||
102 | static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask) | 92 | static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask) |
103 | { | 93 | { |
@@ -122,6 +112,15 @@ static inline void percpu_free(void *__pdata) | |||
122 | cpu_possible_map) | 112 | cpu_possible_map) |
123 | #define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type)) | 113 | #define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type)) |
124 | #define free_percpu(ptr) percpu_free((ptr)) | 114 | #define free_percpu(ptr) percpu_free((ptr)) |
125 | #define per_cpu_ptr(ptr, cpu) percpu_ptr((ptr), (cpu)) | 115 | /* |
116 | * Use this to get to a cpu's version of the per-cpu object dynamically | ||
117 | * allocated. Non-atomic access to the current CPU's version should | ||
118 | * probably be combined with get_cpu()/put_cpu(). | ||
119 | */ | ||
120 | #define per_cpu_ptr(ptr, cpu) \ | ||
121 | ({ \ | ||
122 | struct percpu_data *__p = __percpu_disguise(ptr); \ | ||
123 | (__typeof__(ptr))__p->ptrs[(cpu)]; \ | ||
124 | }) | ||
126 | 125 | ||
127 | #endif /* __LINUX_PERCPU_H */ | 126 | #endif /* __LINUX_PERCPU_H */ |