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.h98
1 files changed, 64 insertions, 34 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 21e1dd43e52a..d4bf52603e6b 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -339,36 +339,6 @@ extern cpumask_t cpu_mask_all;
339#endif 339#endif
340#define CPUMASK_PTR(v, m) cpumask_t *v = &(m->v) 340#define CPUMASK_PTR(v, m) cpumask_t *v = &(m->v)
341 341
342#define cpumask_scnprintf(buf, len, src) \
343 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS)
344static inline int __cpumask_scnprintf(char *buf, int len,
345 const cpumask_t *srcp, int nbits)
346{
347 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
348}
349
350#define cpumask_parse_user(ubuf, ulen, dst) \
351 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS)
352static inline int __cpumask_parse_user(const char __user *buf, int len,
353 cpumask_t *dstp, int nbits)
354{
355 return bitmap_parse_user(buf, len, dstp->bits, nbits);
356}
357
358#define cpulist_scnprintf(buf, len, src) \
359 __cpulist_scnprintf((buf), (len), &(src), NR_CPUS)
360static inline int __cpulist_scnprintf(char *buf, int len,
361 const cpumask_t *srcp, int nbits)
362{
363 return bitmap_scnlistprintf(buf, len, srcp->bits, nbits);
364}
365
366#define cpulist_parse(buf, dst) __cpulist_parse((buf), &(dst), NR_CPUS)
367static inline int __cpulist_parse(const char *buf, cpumask_t *dstp, int nbits)
368{
369 return bitmap_parselist(buf, dstp->bits, nbits);
370}
371
372#define cpu_remap(oldbit, old, new) \ 342#define cpu_remap(oldbit, old, new) \
373 __cpu_remap((oldbit), &(old), &(new), NR_CPUS) 343 __cpu_remap((oldbit), &(old), &(new), NR_CPUS)
374static inline int __cpu_remap(int oldbit, 344static inline int __cpu_remap(int oldbit,
@@ -540,9 +510,6 @@ extern cpumask_t cpu_active_map;
540 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ 510 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
541} 511}
542 512
543/* This produces more efficient code. */
544#define nr_cpumask_bits NR_CPUS
545
546#else /* NR_CPUS > BITS_PER_LONG */ 513#else /* NR_CPUS > BITS_PER_LONG */
547 514
548#define CPU_BITS_ALL \ 515#define CPU_BITS_ALL \
@@ -550,9 +517,15 @@ extern cpumask_t cpu_active_map;
550 [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \ 517 [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
551 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ 518 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
552} 519}
520#endif /* NR_CPUS > BITS_PER_LONG */
553 521
522#ifdef CONFIG_CPUMASK_OFFSTACK
523/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,
524 * not all bits may be allocated. */
554#define nr_cpumask_bits nr_cpu_ids 525#define nr_cpumask_bits nr_cpu_ids
555#endif /* NR_CPUS > BITS_PER_LONG */ 526#else
527#define nr_cpumask_bits NR_CPUS
528#endif
556 529
557/* verify cpu argument to cpumask_* operators */ 530/* verify cpu argument to cpumask_* operators */
558static inline unsigned int cpumask_check(unsigned int cpu) 531static inline unsigned int cpumask_check(unsigned int cpu)
@@ -946,6 +919,63 @@ static inline void cpumask_copy(struct cpumask *dstp,
946#define cpumask_of(cpu) (get_cpu_mask(cpu)) 919#define cpumask_of(cpu) (get_cpu_mask(cpu))
947 920
948/** 921/**
922 * cpumask_scnprintf - print a cpumask into a string as comma-separated hex
923 * @buf: the buffer to sprintf into
924 * @len: the length of the buffer
925 * @srcp: the cpumask to print
926 *
927 * If len is zero, returns zero. Otherwise returns the length of the
928 * (nul-terminated) @buf string.
929 */
930static inline int cpumask_scnprintf(char *buf, int len,
931 const struct cpumask *srcp)
932{
933 return bitmap_scnprintf(buf, len, srcp->bits, nr_cpumask_bits);
934}
935
936/**
937 * cpumask_parse_user - extract a cpumask from a user string
938 * @buf: the buffer to extract from
939 * @len: the length of the buffer
940 * @dstp: the cpumask to set.
941 *
942 * Returns -errno, or 0 for success.
943 */
944static inline int cpumask_parse_user(const char __user *buf, int len,
945 struct cpumask *dstp)
946{
947 return bitmap_parse_user(buf, len, dstp->bits, nr_cpumask_bits);
948}
949
950/**
951 * cpulist_scnprintf - print a cpumask into a string as comma-separated list
952 * @buf: the buffer to sprintf into
953 * @len: the length of the buffer
954 * @srcp: the cpumask to print
955 *
956 * If len is zero, returns zero. Otherwise returns the length of the
957 * (nul-terminated) @buf string.
958 */
959static inline int cpulist_scnprintf(char *buf, int len,
960 const struct cpumask *srcp)
961{
962 return bitmap_scnlistprintf(buf, len, srcp->bits, nr_cpumask_bits);
963}
964
965/**
966 * cpulist_parse_user - extract a cpumask from a user string of ranges
967 * @buf: the buffer to extract from
968 * @len: the length of the buffer
969 * @dstp: the cpumask to set.
970 *
971 * Returns -errno, or 0 for success.
972 */
973static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
974{
975 return bitmap_parselist(buf, dstp->bits, nr_cpumask_bits);
976}
977
978/**
949 * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask * 979 * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask *
950 * @bitmap: the bitmap 980 * @bitmap: the bitmap
951 * 981 *