diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cpumask.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 8fa3b6d4a320..96d0509fb8d8 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -265,10 +265,30 @@ static inline void __cpus_shift_left(cpumask_t *dstp, | |||
265 | bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); | 265 | bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); |
266 | } | 266 | } |
267 | 267 | ||
268 | /* | ||
269 | * Special-case data structure for "single bit set only" constant CPU masks. | ||
270 | * | ||
271 | * We pre-generate all the 64 (or 32) possible bit positions, with enough | ||
272 | * padding to the left and the right, and return the constant pointer | ||
273 | * appropriately offset. | ||
274 | */ | ||
275 | extern const unsigned long | ||
276 | cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)]; | ||
277 | |||
278 | static inline const cpumask_t *get_cpu_mask(unsigned int cpu) | ||
279 | { | ||
280 | const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG]; | ||
281 | p -= cpu / BITS_PER_LONG; | ||
282 | return (const cpumask_t *)p; | ||
283 | } | ||
284 | |||
285 | /* | ||
286 | * In cases where we take the address of the cpumask immediately, | ||
287 | * gcc optimizes it out (it's a constant) and there's no huge stack | ||
288 | * variable created: | ||
289 | */ | ||
290 | #define cpumask_of_cpu(cpu) ({ *get_cpu_mask(cpu); }) | ||
268 | 291 | ||
269 | /* cpumask_of_cpu_map[] is in kernel/cpu.c */ | ||
270 | extern const cpumask_t *cpumask_of_cpu_map; | ||
271 | #define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu]) | ||
272 | 292 | ||
273 | #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) | 293 | #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) |
274 | 294 | ||