diff options
Diffstat (limited to 'include/linux/cpumask.h')
-rw-r--r-- | include/linux/cpumask.h | 71 |
1 files changed, 24 insertions, 47 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index b950e9d6008b..086549a665e2 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -22,6 +22,14 @@ typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t; | |||
22 | */ | 22 | */ |
23 | #define cpumask_bits(maskp) ((maskp)->bits) | 23 | #define cpumask_bits(maskp) ((maskp)->bits) |
24 | 24 | ||
25 | /** | ||
26 | * cpumask_pr_args - printf args to output a cpumask | ||
27 | * @maskp: cpumask to be printed | ||
28 | * | ||
29 | * Can be used to provide arguments for '%*pb[l]' when printing a cpumask. | ||
30 | */ | ||
31 | #define cpumask_pr_args(maskp) nr_cpu_ids, cpumask_bits(maskp) | ||
32 | |||
25 | #if NR_CPUS == 1 | 33 | #if NR_CPUS == 1 |
26 | #define nr_cpu_ids 1 | 34 | #define nr_cpu_ids 1 |
27 | #else | 35 | #else |
@@ -539,21 +547,6 @@ static inline void cpumask_copy(struct cpumask *dstp, | |||
539 | #define cpumask_of(cpu) (get_cpu_mask(cpu)) | 547 | #define cpumask_of(cpu) (get_cpu_mask(cpu)) |
540 | 548 | ||
541 | /** | 549 | /** |
542 | * cpumask_scnprintf - print a cpumask into a string as comma-separated hex | ||
543 | * @buf: the buffer to sprintf into | ||
544 | * @len: the length of the buffer | ||
545 | * @srcp: the cpumask to print | ||
546 | * | ||
547 | * If len is zero, returns zero. Otherwise returns the length of the | ||
548 | * (nul-terminated) @buf string. | ||
549 | */ | ||
550 | static inline int cpumask_scnprintf(char *buf, int len, | ||
551 | const struct cpumask *srcp) | ||
552 | { | ||
553 | return bitmap_scnprintf(buf, len, cpumask_bits(srcp), nr_cpumask_bits); | ||
554 | } | ||
555 | |||
556 | /** | ||
557 | * cpumask_parse_user - extract a cpumask from a user string | 550 | * cpumask_parse_user - extract a cpumask from a user string |
558 | * @buf: the buffer to extract from | 551 | * @buf: the buffer to extract from |
559 | * @len: the length of the buffer | 552 | * @len: the length of the buffer |
@@ -564,7 +557,7 @@ static inline int cpumask_scnprintf(char *buf, int len, | |||
564 | static inline int cpumask_parse_user(const char __user *buf, int len, | 557 | static inline int cpumask_parse_user(const char __user *buf, int len, |
565 | struct cpumask *dstp) | 558 | struct cpumask *dstp) |
566 | { | 559 | { |
567 | return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpumask_bits); | 560 | return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpu_ids); |
568 | } | 561 | } |
569 | 562 | ||
570 | /** | 563 | /** |
@@ -579,23 +572,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len, | |||
579 | struct cpumask *dstp) | 572 | struct cpumask *dstp) |
580 | { | 573 | { |
581 | return bitmap_parselist_user(buf, len, cpumask_bits(dstp), | 574 | return bitmap_parselist_user(buf, len, cpumask_bits(dstp), |
582 | nr_cpumask_bits); | 575 | nr_cpu_ids); |
583 | } | ||
584 | |||
585 | /** | ||
586 | * cpulist_scnprintf - print a cpumask into a string as comma-separated list | ||
587 | * @buf: the buffer to sprintf into | ||
588 | * @len: the length of the buffer | ||
589 | * @srcp: the cpumask to print | ||
590 | * | ||
591 | * If len is zero, returns zero. Otherwise returns the length of the | ||
592 | * (nul-terminated) @buf string. | ||
593 | */ | ||
594 | static inline int cpulist_scnprintf(char *buf, int len, | ||
595 | const struct cpumask *srcp) | ||
596 | { | ||
597 | return bitmap_scnlistprintf(buf, len, cpumask_bits(srcp), | ||
598 | nr_cpumask_bits); | ||
599 | } | 576 | } |
600 | 577 | ||
601 | /** | 578 | /** |
@@ -610,7 +587,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp) | |||
610 | char *nl = strchr(buf, '\n'); | 587 | char *nl = strchr(buf, '\n'); |
611 | unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf); | 588 | unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf); |
612 | 589 | ||
613 | return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits); | 590 | return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpu_ids); |
614 | } | 591 | } |
615 | 592 | ||
616 | /** | 593 | /** |
@@ -622,7 +599,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp) | |||
622 | */ | 599 | */ |
623 | static inline int cpulist_parse(const char *buf, struct cpumask *dstp) | 600 | static inline int cpulist_parse(const char *buf, struct cpumask *dstp) |
624 | { | 601 | { |
625 | return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits); | 602 | return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpu_ids); |
626 | } | 603 | } |
627 | 604 | ||
628 | /** | 605 | /** |
@@ -817,7 +794,7 @@ static inline ssize_t | |||
817 | cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) | 794 | cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) |
818 | { | 795 | { |
819 | return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask), | 796 | return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask), |
820 | nr_cpumask_bits); | 797 | nr_cpu_ids); |
821 | } | 798 | } |
822 | 799 | ||
823 | /* | 800 | /* |
@@ -905,13 +882,13 @@ static inline void __cpu_clear(int cpu, volatile cpumask_t *dstp) | |||
905 | } | 882 | } |
906 | 883 | ||
907 | #define cpus_setall(dst) __cpus_setall(&(dst), NR_CPUS) | 884 | #define cpus_setall(dst) __cpus_setall(&(dst), NR_CPUS) |
908 | static inline void __cpus_setall(cpumask_t *dstp, int nbits) | 885 | static inline void __cpus_setall(cpumask_t *dstp, unsigned int nbits) |
909 | { | 886 | { |
910 | bitmap_fill(dstp->bits, nbits); | 887 | bitmap_fill(dstp->bits, nbits); |
911 | } | 888 | } |
912 | 889 | ||
913 | #define cpus_clear(dst) __cpus_clear(&(dst), NR_CPUS) | 890 | #define cpus_clear(dst) __cpus_clear(&(dst), NR_CPUS) |
914 | static inline void __cpus_clear(cpumask_t *dstp, int nbits) | 891 | static inline void __cpus_clear(cpumask_t *dstp, unsigned int nbits) |
915 | { | 892 | { |
916 | bitmap_zero(dstp->bits, nbits); | 893 | bitmap_zero(dstp->bits, nbits); |
917 | } | 894 | } |
@@ -927,21 +904,21 @@ static inline int __cpu_test_and_set(int cpu, cpumask_t *addr) | |||
927 | 904 | ||
928 | #define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS) | 905 | #define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS) |
929 | static inline int __cpus_and(cpumask_t *dstp, const cpumask_t *src1p, | 906 | static inline int __cpus_and(cpumask_t *dstp, const cpumask_t *src1p, |
930 | const cpumask_t *src2p, int nbits) | 907 | const cpumask_t *src2p, unsigned int nbits) |
931 | { | 908 | { |
932 | return bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits); | 909 | return bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits); |
933 | } | 910 | } |
934 | 911 | ||
935 | #define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS) | 912 | #define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS) |
936 | static inline void __cpus_or(cpumask_t *dstp, const cpumask_t *src1p, | 913 | static inline void __cpus_or(cpumask_t *dstp, const cpumask_t *src1p, |
937 | const cpumask_t *src2p, int nbits) | 914 | const cpumask_t *src2p, unsigned int nbits) |
938 | { | 915 | { |
939 | bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits); | 916 | bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits); |
940 | } | 917 | } |
941 | 918 | ||
942 | #define cpus_xor(dst, src1, src2) __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS) | 919 | #define cpus_xor(dst, src1, src2) __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS) |
943 | static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p, | 920 | static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p, |
944 | const cpumask_t *src2p, int nbits) | 921 | const cpumask_t *src2p, unsigned int nbits) |
945 | { | 922 | { |
946 | bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits); | 923 | bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits); |
947 | } | 924 | } |
@@ -949,40 +926,40 @@ static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p, | |||
949 | #define cpus_andnot(dst, src1, src2) \ | 926 | #define cpus_andnot(dst, src1, src2) \ |
950 | __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS) | 927 | __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS) |
951 | static inline int __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p, | 928 | static inline int __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p, |
952 | const cpumask_t *src2p, int nbits) | 929 | const cpumask_t *src2p, unsigned int nbits) |
953 | { | 930 | { |
954 | return bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits); | 931 | return bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits); |
955 | } | 932 | } |
956 | 933 | ||
957 | #define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS) | 934 | #define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS) |
958 | static inline int __cpus_equal(const cpumask_t *src1p, | 935 | static inline int __cpus_equal(const cpumask_t *src1p, |
959 | const cpumask_t *src2p, int nbits) | 936 | const cpumask_t *src2p, unsigned int nbits) |
960 | { | 937 | { |
961 | return bitmap_equal(src1p->bits, src2p->bits, nbits); | 938 | return bitmap_equal(src1p->bits, src2p->bits, nbits); |
962 | } | 939 | } |
963 | 940 | ||
964 | #define cpus_intersects(src1, src2) __cpus_intersects(&(src1), &(src2), NR_CPUS) | 941 | #define cpus_intersects(src1, src2) __cpus_intersects(&(src1), &(src2), NR_CPUS) |
965 | static inline int __cpus_intersects(const cpumask_t *src1p, | 942 | static inline int __cpus_intersects(const cpumask_t *src1p, |
966 | const cpumask_t *src2p, int nbits) | 943 | const cpumask_t *src2p, unsigned int nbits) |
967 | { | 944 | { |
968 | return bitmap_intersects(src1p->bits, src2p->bits, nbits); | 945 | return bitmap_intersects(src1p->bits, src2p->bits, nbits); |
969 | } | 946 | } |
970 | 947 | ||
971 | #define cpus_subset(src1, src2) __cpus_subset(&(src1), &(src2), NR_CPUS) | 948 | #define cpus_subset(src1, src2) __cpus_subset(&(src1), &(src2), NR_CPUS) |
972 | static inline int __cpus_subset(const cpumask_t *src1p, | 949 | static inline int __cpus_subset(const cpumask_t *src1p, |
973 | const cpumask_t *src2p, int nbits) | 950 | const cpumask_t *src2p, unsigned int nbits) |
974 | { | 951 | { |
975 | return bitmap_subset(src1p->bits, src2p->bits, nbits); | 952 | return bitmap_subset(src1p->bits, src2p->bits, nbits); |
976 | } | 953 | } |
977 | 954 | ||
978 | #define cpus_empty(src) __cpus_empty(&(src), NR_CPUS) | 955 | #define cpus_empty(src) __cpus_empty(&(src), NR_CPUS) |
979 | static inline int __cpus_empty(const cpumask_t *srcp, int nbits) | 956 | static inline int __cpus_empty(const cpumask_t *srcp, unsigned int nbits) |
980 | { | 957 | { |
981 | return bitmap_empty(srcp->bits, nbits); | 958 | return bitmap_empty(srcp->bits, nbits); |
982 | } | 959 | } |
983 | 960 | ||
984 | #define cpus_weight(cpumask) __cpus_weight(&(cpumask), NR_CPUS) | 961 | #define cpus_weight(cpumask) __cpus_weight(&(cpumask), NR_CPUS) |
985 | static inline int __cpus_weight(const cpumask_t *srcp, int nbits) | 962 | static inline int __cpus_weight(const cpumask_t *srcp, unsigned int nbits) |
986 | { | 963 | { |
987 | return bitmap_weight(srcp->bits, nbits); | 964 | return bitmap_weight(srcp->bits, nbits); |
988 | } | 965 | } |