diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-13 11:22:43 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-13 11:22:43 -0400 |
| commit | d811f236d90e58c67092eaadacab609e76c38749 (patch) | |
| tree | 52b7d911948cf6a50f9a54abb6b91890ff9a8a72 /include/linux | |
| parent | 29a1e26febf4bd6eecab2a17a056c177d3627788 (diff) | |
| parent | 066123a535927b3f17cac2305258cc71abdb0d92 (diff) | |
Merge branch 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
percpu: unbreak alpha percpu
mutex: have non-spinning mutexes on s390 by default
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/percpu.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index ee5615d65211..cfda2d5ad319 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
| @@ -168,4 +168,56 @@ static inline void free_percpu(void *p) | |||
| 168 | #define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \ | 168 | #define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \ |
| 169 | __alignof__(type)) | 169 | __alignof__(type)) |
| 170 | 170 | ||
| 171 | /* | ||
| 172 | * Optional methods for optimized non-lvalue per-cpu variable access. | ||
| 173 | * | ||
| 174 | * @var can be a percpu variable or a field of it and its size should | ||
| 175 | * equal char, int or long. percpu_read() evaluates to a lvalue and | ||
| 176 | * all others to void. | ||
| 177 | * | ||
| 178 | * These operations are guaranteed to be atomic w.r.t. preemption. | ||
| 179 | * The generic versions use plain get/put_cpu_var(). Archs are | ||
| 180 | * encouraged to implement single-instruction alternatives which don't | ||
| 181 | * require preemption protection. | ||
| 182 | */ | ||
| 183 | #ifndef percpu_read | ||
| 184 | # define percpu_read(var) \ | ||
| 185 | ({ \ | ||
| 186 | typeof(per_cpu_var(var)) __tmp_var__; \ | ||
| 187 | __tmp_var__ = get_cpu_var(var); \ | ||
| 188 | put_cpu_var(var); \ | ||
| 189 | __tmp_var__; \ | ||
| 190 | }) | ||
| 191 | #endif | ||
| 192 | |||
| 193 | #define __percpu_generic_to_op(var, val, op) \ | ||
| 194 | do { \ | ||
| 195 | get_cpu_var(var) op val; \ | ||
| 196 | put_cpu_var(var); \ | ||
| 197 | } while (0) | ||
| 198 | |||
| 199 | #ifndef percpu_write | ||
| 200 | # define percpu_write(var, val) __percpu_generic_to_op(var, (val), =) | ||
| 201 | #endif | ||
| 202 | |||
| 203 | #ifndef percpu_add | ||
| 204 | # define percpu_add(var, val) __percpu_generic_to_op(var, (val), +=) | ||
| 205 | #endif | ||
| 206 | |||
| 207 | #ifndef percpu_sub | ||
| 208 | # define percpu_sub(var, val) __percpu_generic_to_op(var, (val), -=) | ||
| 209 | #endif | ||
| 210 | |||
| 211 | #ifndef percpu_and | ||
| 212 | # define percpu_and(var, val) __percpu_generic_to_op(var, (val), &=) | ||
| 213 | #endif | ||
| 214 | |||
| 215 | #ifndef percpu_or | ||
| 216 | # define percpu_or(var, val) __percpu_generic_to_op(var, (val), |=) | ||
| 217 | #endif | ||
| 218 | |||
| 219 | #ifndef percpu_xor | ||
| 220 | # define percpu_xor(var, val) __percpu_generic_to_op(var, (val), ^=) | ||
| 221 | #endif | ||
| 222 | |||
| 171 | #endif /* __LINUX_PERCPU_H */ | 223 | #endif /* __LINUX_PERCPU_H */ |
