1#ifndef __LINUX_CPUMASK_H
2#define __LINUX_CPUMASK_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140#include <linux/kernel.h>
141#include <linux/threads.h>
142#include <linux/bitmap.h>
143
144typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
145extern cpumask_t _unused_cpumask_arg_;
146
147#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
148#define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
149static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
150{
151 set_bit(cpu, dstp->bits);
152}
153
154#define cpu_clear(cpu, dst) __cpu_clear((cpu), &(dst))
155static inline void __cpu_clear(int cpu, volatile cpumask_t *dstp)
156{
157 clear_bit(cpu, dstp->bits);
158}
159
160#define cpus_setall(dst) __cpus_setall(&(dst), NR_CPUS)
161static inline void __cpus_setall(cpumask_t *dstp, int nbits)
162{
163 bitmap_fill(dstp->bits, nbits);
164}
165
166#define cpus_clear(dst) __cpus_clear(&(dst), NR_CPUS)
167static inline void __cpus_clear(cpumask_t *dstp, int nbits)
168{
169 bitmap_zero(dstp->bits, nbits);
170}
171
172
173#define cpu_isset(cpu, cpumask) test_bit((cpu), (cpumask).bits)
174
175#define cpu_test_and_set(cpu, cpumask) __cpu_test_and_set((cpu), &(cpumask))
176static inline int __cpu_test_and_set(int cpu, cpumask_t *addr)
177{
178 return test_and_set_bit(cpu, addr->bits);
179}
180
181#define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)
182static inline void __cpus_and(cpumask_t *dstp, const cpumask_t *src1p,
183 const cpumask_t *src2p, int nbits)
184{
185 bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
186}
187
188#define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)
189static inline void __cpus_or(cpumask_t *dstp, const cpumask_t *src1p,
190 const cpumask_t *src2p, int nbits)
191{
192 bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
193}
194
195#define cpus_xor(dst, src1, src2) __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS)
196static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p,
197 const cpumask_t *src2p, int nbits)
198{
199 bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
200}
201
202#define cpus_andnot(dst, src1, src2) \
203 __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)
204static inline void __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p,
205 const cpumask_t *src2p, int nbits)
206{
207 bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
208}
209
210#define cpus_complement(dst, src) __cpus_complement(&(dst), &(src), NR_CPUS)
211static inline void __cpus_complement(cpumask_t *dstp,
212 const cpumask_t *srcp, int nbits)
213{
214 bitmap_complement(dstp->bits, srcp->bits, nbits);
215}
216
217#define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS)
218static inline int __cpus_equal(const cpumask_t *src1p,
219 const cpumask_t *src2p, int nbits)
220{
221 return bitmap_equal(src1p->bits, src2p->bits, nbits);
222}
223
224#define cpus_intersects(src1, src2) __cpus_intersects(&(src1), &(src2), NR_CPUS)
225static inline int __cpus_intersects(const cpumask_t *src1p,
226 const cpumask_t *src2p, int nbits)
227{
228 return bitmap_intersects(src1p->bits, src2p->bits, nbits);
229}
230
231#define cpus_subset(src1, src2) __cpus_subset(&(src1), &(src2), NR_CPUS)
232static inline int __cpus_subset(const cpumask_t *src1p,
233 const cpumask_t *src2p, int nbits)
234{
235 return bitmap_subset(src1p->bits, src2p->bits, nbits);
236}
237
238#define cpus_empty(src) __cpus_empty(&(src), NR_CPUS)
239static inline int __cpus_empty(const cpumask_t *srcp, int nbits)
240{
241 return bitmap_empty(srcp->bits, nbits);
242}
243
244#define cpus_full(cpumask) __cpus_full(&(cpumask), NR_CPUS)
245static inline int __cpus_full(const cpumask_t *srcp, int nbits)
246{
247 return bitmap_full(srcp->bits, nbits);
248}
249
250#define cpus_weight(cpumask) __cpus_weight(&(cpumask), NR_CPUS)
251static inline int __cpus_weight(const cpumask_t *srcp, int nbits)
252{
253 return bitmap_weight(srcp->bits, nbits);
254}
255
256#define cpus_shift_right(dst, src, n) \
257 __cpus_shift_right(&(dst), &(src), (n), NR_CPUS)
258static inline void __cpus_shift_right(cpumask_t *dstp,
259 const cpumask_t *srcp, int n, int nbits)
260{
261 bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
262}
263
264#define cpus_shift_left(dst, src, n) \
265 __cpus_shift_left(&(dst), &(src), (n), NR_CPUS)
266static inline void __cpus_shift_left(cpumask_t *dstp,
267 const cpumask_t *srcp, int n, int nbits)
268{
269 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
270}
271#endif
272
273
274
275
276
277
278
279
280
281
282
283#define to_cpumask(bitmap) \
284 ((struct cpumask *)(1 ? (bitmap) \
285 : (void *)sizeof(__check_is_bitmap(bitmap))))
286
287static inline int __check_is_bitmap(const unsigned long *bitmap)
288{
289 return 1;
290}
291
292
293
294
295
296
297
298
299extern const unsigned long
300 cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
301
302static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
303{
304 const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
305 p -= cpu / BITS_PER_LONG;
306 return to_cpumask(p);
307}
308
309#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
310
311
312
313
314
315#define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
316
317
318#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
319
320#if NR_CPUS <= BITS_PER_LONG
321
322#define CPU_MASK_ALL \
323(cpumask_t) { { \
324 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
325} }
326
327#define CPU_MASK_ALL_PTR (&CPU_MASK_ALL)
328
329#else
330
331#define CPU_MASK_ALL \
332(cpumask_t) { { \
333 [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
334 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
335} }
336
337
338extern cpumask_t cpu_mask_all;
339#define CPU_MASK_ALL_PTR (&cpu_mask_all)
340
341#endif
342
343#define CPU_MASK_NONE \
344(cpumask_t) { { \
345 [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
346} }
347
348#define CPU_MASK_CPU0 \
349(cpumask_t) { { \
350 [0] = 1UL \
351} }
352
353#define cpus_addr(src) ((src).bits)
354
355#if NR_CPUS > BITS_PER_LONG
356#define CPUMASK_ALLOC(m) struct m *m = kmalloc(sizeof(*m), GFP_KERNEL)
357#define CPUMASK_FREE(m) kfree(m)
358#else
359#define CPUMASK_ALLOC(m) struct m _m, *m = &_m
360#define CPUMASK_FREE(m)
361#endif
362#define CPUMASK_PTR(v, m) cpumask_t *v = &(m->v)
363
364#define cpu_remap(oldbit, old, new) \
365 __cpu_remap((oldbit), &(old), &(new), NR_CPUS)
366static inline int __cpu_remap(int oldbit,
367 const cpumask_t *oldp, const cpumask_t *newp, int nbits)
368{
369 return bitmap_bitremap(oldbit, oldp->bits, newp->bits, nbits);
370}
371
372#define cpus_remap(dst, src, old, new) \
373 __cpus_remap(&(dst), &(src), &(old), &(new), NR_CPUS)
374static inline void __cpus_remap(cpumask_t *dstp, const cpumask_t *srcp,
375 const cpumask_t *oldp, const cpumask_t *newp, int nbits)
376{
377 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
378}
379
380#define cpus_onto(dst, orig, relmap) \
381 __cpus_onto(&(dst), &(orig), &(relmap), NR_CPUS)
382static inline void __cpus_onto(cpumask_t *dstp, const cpumask_t *origp,
383 const cpumask_t *relmapp, int nbits)
384{
385 bitmap_onto(dstp->bits, origp->bits, relmapp->bits, nbits);
386}
387
388#define cpus_fold(dst, orig, sz) \
389 __cpus_fold(&(dst), &(orig), sz, NR_CPUS)
390static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,
391 int sz, int nbits)
392{
393 bitmap_fold(dstp->bits, origp->bits, sz, nbits);
394}
395#endif
396
397#if NR_CPUS == 1
398
399#define nr_cpu_ids 1
400#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
401#define first_cpu(src) ({ (void)(src); 0; })
402#define next_cpu(n, src) ({ (void)(src); 1; })
403#define any_online_cpu(mask) 0
404#define for_each_cpu_mask(cpu, mask) \
405 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
406#endif
407#else
408
409extern int nr_cpu_ids;
410#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
411int __first_cpu(const cpumask_t *srcp);
412int __next_cpu(int n, const cpumask_t *srcp);
413int __any_online_cpu(const cpumask_t *mask);
414
415#define first_cpu(src) __first_cpu(&(src))
416#define next_cpu(n, src) __next_cpu((n), &(src))
417#define any_online_cpu(mask) __any_online_cpu(&(mask))
418#define for_each_cpu_mask(cpu, mask) \
419 for ((cpu) = -1; \
420 (cpu) = next_cpu((cpu), (mask)), \
421 (cpu) < NR_CPUS; )
422#endif
423#endif
424
425#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
426#if NR_CPUS <= 64
427
428#define next_cpu_nr(n, src) next_cpu(n, src)
429#define cpus_weight_nr(cpumask) cpus_weight(cpumask)
430#define for_each_cpu_mask_nr(cpu, mask) for_each_cpu_mask(cpu, mask)
431
432#else
433
434int __next_cpu_nr(int n, const cpumask_t *srcp);
435#define next_cpu_nr(n, src) __next_cpu_nr((n), &(src))
436#define cpus_weight_nr(cpumask) __cpus_weight(&(cpumask), nr_cpu_ids)
437#define for_each_cpu_mask_nr(cpu, mask) \
438 for ((cpu) = -1; \
439 (cpu) = next_cpu_nr((cpu), (mask)), \
440 (cpu) < nr_cpu_ids; )
441
442#endif
443#endif
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485extern const struct cpumask *const cpu_possible_mask;
486extern const struct cpumask *const cpu_online_mask;
487extern const struct cpumask *const cpu_present_mask;
488extern const struct cpumask *const cpu_active_mask;
489
490
491#define cpu_possible_map (*(cpumask_t *)cpu_possible_mask)
492#define cpu_online_map (*(cpumask_t *)cpu_online_mask)
493#define cpu_present_map (*(cpumask_t *)cpu_present_mask)
494#define cpu_active_map (*(cpumask_t *)cpu_active_mask)
495
496#if NR_CPUS > 1
497#define num_online_cpus() cpumask_weight(cpu_online_mask)
498#define num_possible_cpus() cpumask_weight(cpu_possible_mask)
499#define num_present_cpus() cpumask_weight(cpu_present_mask)
500#define cpu_online(cpu) cpumask_test_cpu((cpu), cpu_online_mask)
501#define cpu_possible(cpu) cpumask_test_cpu((cpu), cpu_possible_mask)
502#define cpu_present(cpu) cpumask_test_cpu((cpu), cpu_present_mask)
503#define cpu_active(cpu) cpumask_test_cpu((cpu), cpu_active_mask)
504#else
505#define num_online_cpus() 1
506#define num_possible_cpus() 1
507#define num_present_cpus() 1
508#define cpu_online(cpu) ((cpu) == 0)
509#define cpu_possible(cpu) ((cpu) == 0)
510#define cpu_present(cpu) ((cpu) == 0)
511#define cpu_active(cpu) ((cpu) == 0)
512#endif
513
514#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
515
516
517
518#define cpumask_bits(maskp) ((maskp)->bits)
519
520#if NR_CPUS <= BITS_PER_LONG
521#define CPU_BITS_ALL \
522{ \
523 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
524}
525
526#else
527
528#define CPU_BITS_ALL \
529{ \
530 [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
531 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
532}
533#endif
534
535#ifdef CONFIG_CPUMASK_OFFSTACK
536
537
538#define nr_cpumask_bits nr_cpu_ids
539#else
540#define nr_cpumask_bits NR_CPUS
541#endif
542
543
544static inline unsigned int cpumask_check(unsigned int cpu)
545{
546#ifdef CONFIG_DEBUG_PER_CPU_MAPS
547 WARN_ON_ONCE(cpu >= nr_cpumask_bits);
548#endif
549 return cpu;
550}
551
552#if NR_CPUS == 1
553
554static inline unsigned int cpumask_first(const struct cpumask *srcp)
555{
556 return 0;
557}
558
559
560static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
561{
562 return n+1;
563}
564
565static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
566{
567 return n+1;
568}
569
570static inline unsigned int cpumask_next_and(int n,
571 const struct cpumask *srcp,
572 const struct cpumask *andp)
573{
574 return n+1;
575}
576
577
578static inline unsigned int cpumask_any_but(const struct cpumask *mask,
579 unsigned int cpu)
580{
581 return 1;
582}
583
584#define for_each_cpu(cpu, mask) \
585 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
586#define for_each_cpu_and(cpu, mask, and) \
587 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)
588#else
589
590
591
592
593
594
595static inline unsigned int cpumask_first(const struct cpumask *srcp)
596{
597 return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits);
598}
599
600
601
602
603
604
605
606
607static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
608{
609
610 if (n != -1)
611 cpumask_check(n);
612 return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
613}
614
615
616
617
618
619
620
621
622static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
623{
624
625 if (n != -1)
626 cpumask_check(n);
627 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
628}
629
630int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
631int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
632
633
634
635
636
637
638
639
640#define for_each_cpu(cpu, mask) \
641 for ((cpu) = -1; \
642 (cpu) = cpumask_next((cpu), (mask)), \
643 (cpu) < nr_cpu_ids;)
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659#define for_each_cpu_and(cpu, mask, and) \
660 for ((cpu) = -1; \
661 (cpu) = cpumask_next_and((cpu), (mask), (and)), \
662 (cpu) < nr_cpu_ids;)
663#endif
664
665#define CPU_BITS_NONE \
666{ \
667 [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
668}
669
670#define CPU_BITS_CPU0 \
671{ \
672 [0] = 1UL \
673}
674
675
676
677
678
679
680static inline void cpumask_set_cpu(unsigned int cpu, struct cpumask *dstp)
681{
682 set_bit(cpumask_check(cpu), cpumask_bits(dstp));
683}
684
685
686
687
688
689
690static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp)
691{
692 clear_bit(cpumask_check(cpu), cpumask_bits(dstp));
693}
694
695
696
697
698
699
700
701
702#define cpumask_test_cpu(cpu, cpumask) \
703 test_bit(cpumask_check(cpu), cpumask_bits((cpumask)))
704
705
706
707
708
709
710
711
712static inline int cpumask_test_and_set_cpu(int cpu, struct cpumask *cpumask)
713{
714 return test_and_set_bit(cpumask_check(cpu), cpumask_bits(cpumask));
715}
716
717
718
719
720
721static inline void cpumask_setall(struct cpumask *dstp)
722{
723 bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits);
724}
725
726
727
728
729
730static inline void cpumask_clear(struct cpumask *dstp)
731{
732 bitmap_zero(cpumask_bits(dstp), nr_cpumask_bits);
733}
734
735
736
737
738
739
740
741static inline void cpumask_and(struct cpumask *dstp,
742 const struct cpumask *src1p,
743 const struct cpumask *src2p)
744{
745 bitmap_and(cpumask_bits(dstp), cpumask_bits(src1p),
746 cpumask_bits(src2p), nr_cpumask_bits);
747}
748
749
750
751
752
753
754
755static inline void cpumask_or(struct cpumask *dstp, const struct cpumask *src1p,
756 const struct cpumask *src2p)
757{
758 bitmap_or(cpumask_bits(dstp), cpumask_bits(src1p),
759 cpumask_bits(src2p), nr_cpumask_bits);
760}
761
762
763
764
765
766
767
768static inline void cpumask_xor(struct cpumask *dstp,
769 const struct cpumask *src1p,
770 const struct cpumask *src2p)
771{
772 bitmap_xor(cpumask_bits(dstp), cpumask_bits(src1p),
773 cpumask_bits(src2p), nr_cpumask_bits);
774}
775
776
777
778
779
780
781
782static inline void cpumask_andnot(struct cpumask *dstp,
783 const struct cpumask *src1p,
784 const struct cpumask *src2p)
785{
786 bitmap_andnot(cpumask_bits(dstp), cpumask_bits(src1p),
787 cpumask_bits(src2p), nr_cpumask_bits);
788}
789
790
791
792
793
794
795static inline void cpumask_complement(struct cpumask *dstp,
796 const struct cpumask *srcp)
797{
798 bitmap_complement(cpumask_bits(dstp), cpumask_bits(srcp),
799 nr_cpumask_bits);
800}
801
802
803
804
805
806
807static inline bool cpumask_equal(const struct cpumask *src1p,
808 const struct cpumask *src2p)
809{
810 return bitmap_equal(cpumask_bits(src1p), cpumask_bits(src2p),
811 nr_cpumask_bits);
812}
813
814
815
816
817
818
819static inline bool cpumask_intersects(const struct cpumask *src1p,
820 const struct cpumask *src2p)
821{
822 return bitmap_intersects(cpumask_bits(src1p), cpumask_bits(src2p),
823 nr_cpumask_bits);
824}
825
826
827
828
829
830
831static inline int cpumask_subset(const struct cpumask *src1p,
832 const struct cpumask *src2p)
833{
834 return bitmap_subset(cpumask_bits(src1p), cpumask_bits(src2p),
835 nr_cpumask_bits);
836}
837
838
839
840
841
842static inline bool cpumask_empty(const struct cpumask *srcp)
843{
844 return bitmap_empty(cpumask_bits(srcp), nr_cpumask_bits);
845}
846
847
848
849
850
851static inline bool cpumask_full(const struct cpumask *srcp)
852{
853 return bitmap_full(cpumask_bits(srcp), nr_cpumask_bits);
854}
855
856
857
858
859
860static inline unsigned int cpumask_weight(const struct cpumask *srcp)
861{
862 return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits);
863}
864
865
866
867
868
869
870
871static inline void cpumask_shift_right(struct cpumask *dstp,
872 const struct cpumask *srcp, int n)
873{
874 bitmap_shift_right(cpumask_bits(dstp), cpumask_bits(srcp), n,
875 nr_cpumask_bits);
876}
877
878
879
880
881
882
883
884static inline void cpumask_shift_left(struct cpumask *dstp,
885 const struct cpumask *srcp, int n)
886{
887 bitmap_shift_left(cpumask_bits(dstp), cpumask_bits(srcp), n,
888 nr_cpumask_bits);
889}
890
891
892
893
894
895
896static inline void cpumask_copy(struct cpumask *dstp,
897 const struct cpumask *srcp)
898{
899 bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), nr_cpumask_bits);
900}
901
902
903
904
905
906
907
908#define cpumask_any(srcp) cpumask_first(srcp)
909
910
911
912
913
914
915
916
917#define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p))
918
919
920
921
922
923
924
925
926#define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))
927
928
929
930
931
932#define cpumask_of(cpu) (get_cpu_mask(cpu))
933
934
935
936
937
938
939
940
941
942
943static inline int cpumask_scnprintf(char *buf, int len,
944 const struct cpumask *srcp)
945{
946 return bitmap_scnprintf(buf, len, cpumask_bits(srcp), nr_cpumask_bits);
947}
948
949
950
951
952
953
954
955
956
957static inline int cpumask_parse_user(const char __user *buf, int len,
958 struct cpumask *dstp)
959{
960 return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
961}
962
963
964
965
966
967
968
969
970
971
972static inline int cpulist_scnprintf(char *buf, int len,
973 const struct cpumask *srcp)
974{
975 return bitmap_scnlistprintf(buf, len, cpumask_bits(srcp),
976 nr_cpumask_bits);
977}
978
979
980
981
982
983
984
985
986
987static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
988{
989 return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits);
990}
991
992
993
994
995
996
997static inline size_t cpumask_size(void)
998{
999
1000
1001 return BITS_TO_LONGS(NR_CPUS) * sizeof(long);
1002}
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020#ifdef CONFIG_CPUMASK_OFFSTACK
1021typedef struct cpumask *cpumask_var_t;
1022
1023bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node);
1024bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags);
1025void alloc_bootmem_cpumask_var(cpumask_var_t *mask);
1026void free_cpumask_var(cpumask_var_t mask);
1027void free_bootmem_cpumask_var(cpumask_var_t mask);
1028
1029#else
1030typedef struct cpumask cpumask_var_t[1];
1031
1032static inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
1033{
1034 return true;
1035}
1036
1037static inline bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags,
1038 int node)
1039{
1040 return true;
1041}
1042
1043static inline void alloc_bootmem_cpumask_var(cpumask_var_t *mask)
1044{
1045}
1046
1047static inline void free_cpumask_var(cpumask_var_t mask)
1048{
1049}
1050
1051static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
1052{
1053}
1054#endif
1055
1056
1057
1058extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS);
1059#define cpu_all_mask to_cpumask(cpu_all_bits)
1060
1061
1062#define cpu_none_mask to_cpumask(cpu_bit_bitmap[0])
1063
1064#define for_each_possible_cpu(cpu) for_each_cpu((cpu), cpu_possible_mask)
1065#define for_each_online_cpu(cpu) for_each_cpu((cpu), cpu_online_mask)
1066#define for_each_present_cpu(cpu) for_each_cpu((cpu), cpu_present_mask)
1067
1068
1069void set_cpu_possible(unsigned int cpu, bool possible);
1070void set_cpu_present(unsigned int cpu, bool present);
1071void set_cpu_online(unsigned int cpu, bool online);
1072void set_cpu_active(unsigned int cpu, bool active);
1073void init_cpu_present(const struct cpumask *src);
1074void init_cpu_possible(const struct cpumask *src);
1075void init_cpu_online(const struct cpumask *src);
1076#endif
1077