aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cpumask.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cpumask.h')
-rw-r--r--include/linux/cpumask.h47
1 files changed, 43 insertions, 4 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 7047f58306a7..9650806fe2ea 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -14,6 +14,8 @@
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c 15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c
16 * For details of cpus_remap(), see bitmap_remap in lib/bitmap.c. 16 * For details of cpus_remap(), see bitmap_remap in lib/bitmap.c.
17 * For details of cpus_onto(), see bitmap_onto in lib/bitmap.c.
18 * For details of cpus_fold(), see bitmap_fold in lib/bitmap.c.
17 * 19 *
18 * The available cpumask operations are: 20 * The available cpumask operations are:
19 * 21 *
@@ -53,7 +55,9 @@
53 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing 55 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
54 * int cpulist_parse(buf, map) Parse ascii string as cpulist 56 * int cpulist_parse(buf, map) Parse ascii string as cpulist
55 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 57 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
56 * int cpus_remap(dst, src, old, new) *dst = map(old, new)(src) 58 * void cpus_remap(dst, src, old, new) *dst = map(old, new)(src)
59 * void cpus_onto(dst, orig, relmap) *dst = orig relative to relmap
60 * void cpus_fold(dst, orig, sz) dst bits = orig bits mod sz
57 * 61 *
58 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask 62 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask
59 * 63 *
@@ -222,8 +226,13 @@ int __next_cpu(int n, const cpumask_t *srcp);
222#define next_cpu(n, src) ({ (void)(src); 1; }) 226#define next_cpu(n, src) ({ (void)(src); 1; })
223#endif 227#endif
224 228
229#ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP
230extern cpumask_t *cpumask_of_cpu_map;
231#define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu])
232
233#else
225#define cpumask_of_cpu(cpu) \ 234#define cpumask_of_cpu(cpu) \
226({ \ 235(*({ \
227 typeof(_unused_cpumask_arg_) m; \ 236 typeof(_unused_cpumask_arg_) m; \
228 if (sizeof(m) == sizeof(unsigned long)) { \ 237 if (sizeof(m) == sizeof(unsigned long)) { \
229 m.bits[0] = 1UL<<(cpu); \ 238 m.bits[0] = 1UL<<(cpu); \
@@ -231,8 +240,9 @@ int __next_cpu(int n, const cpumask_t *srcp);
231 cpus_clear(m); \ 240 cpus_clear(m); \
232 cpu_set((cpu), m); \ 241 cpu_set((cpu), m); \
233 } \ 242 } \
234 m; \ 243 &m; \
235}) 244}))
245#endif
236 246
237#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) 247#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
238 248
@@ -243,6 +253,8 @@ int __next_cpu(int n, const cpumask_t *srcp);
243 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ 253 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
244} } 254} }
245 255
256#define CPU_MASK_ALL_PTR (&CPU_MASK_ALL)
257
246#else 258#else
247 259
248#define CPU_MASK_ALL \ 260#define CPU_MASK_ALL \
@@ -251,6 +263,10 @@ int __next_cpu(int n, const cpumask_t *srcp);
251 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ 263 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
252} } 264} }
253 265
266/* cpu_mask_all is in init/main.c */
267extern cpumask_t cpu_mask_all;
268#define CPU_MASK_ALL_PTR (&cpu_mask_all)
269
254#endif 270#endif
255 271
256#define CPU_MASK_NONE \ 272#define CPU_MASK_NONE \
@@ -273,6 +289,13 @@ static inline int __cpumask_scnprintf(char *buf, int len,
273 return bitmap_scnprintf(buf, len, srcp->bits, nbits); 289 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
274} 290}
275 291
292#define cpumask_scnprintf_len(len) \
293 __cpumask_scnprintf_len((len))
294static inline int __cpumask_scnprintf_len(int len)
295{
296 return bitmap_scnprintf_len(len);
297}
298
276#define cpumask_parse_user(ubuf, ulen, dst) \ 299#define cpumask_parse_user(ubuf, ulen, dst) \
277 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS) 300 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS)
278static inline int __cpumask_parse_user(const char __user *buf, int len, 301static inline int __cpumask_parse_user(const char __user *buf, int len,
@@ -311,6 +334,22 @@ static inline void __cpus_remap(cpumask_t *dstp, const cpumask_t *srcp,
311 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits); 334 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
312} 335}
313 336
337#define cpus_onto(dst, orig, relmap) \
338 __cpus_onto(&(dst), &(orig), &(relmap), NR_CPUS)
339static inline void __cpus_onto(cpumask_t *dstp, const cpumask_t *origp,
340 const cpumask_t *relmapp, int nbits)
341{
342 bitmap_onto(dstp->bits, origp->bits, relmapp->bits, nbits);
343}
344
345#define cpus_fold(dst, orig, sz) \
346 __cpus_fold(&(dst), &(orig), sz, NR_CPUS)
347static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,
348 int sz, int nbits)
349{
350 bitmap_fold(dstp->bits, origp->bits, sz, nbits);
351}
352
314#if NR_CPUS > 1 353#if NR_CPUS > 1
315#define for_each_cpu_mask(cpu, mask) \ 354#define for_each_cpu_mask(cpu, mask) \
316 for ((cpu) = first_cpu(mask); \ 355 for ((cpu) = first_cpu(mask); \