cpumask.h 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  1. #ifndef __LINUX_CPUMASK_H
  2. #define __LINUX_CPUMASK_H
  3. /*
  4. * Cpumasks provide a bitmap suitable for representing the
  5. * set of CPU's in a system, one bit position per CPU number.
  6. *
  7. * The new cpumask_ ops take a "struct cpumask *"; the old ones
  8. * use cpumask_t.
  9. *
  10. * See detailed comments in the file linux/bitmap.h describing the
  11. * data type on which these cpumasks are based.
  12. *
  13. * For details of cpumask_scnprintf() and cpumask_parse_user(),
  14. * see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c.
  15. * For details of cpulist_scnprintf() and cpulist_parse(), see
  16. * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
  17. * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c
  18. * For details of cpus_remap(), see bitmap_remap in lib/bitmap.c.
  19. * For details of cpus_onto(), see bitmap_onto in lib/bitmap.c.
  20. * For details of cpus_fold(), see bitmap_fold in lib/bitmap.c.
  21. *
  22. * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  23. * Note: The alternate operations with the suffix "_nr" are used
  24. * to limit the range of the loop to nr_cpu_ids instead of
  25. * NR_CPUS when NR_CPUS > 64 for performance reasons.
  26. * If NR_CPUS is <= 64 then most assembler bitmask
  27. * operators execute faster with a constant range, so
  28. * the operator will continue to use NR_CPUS.
  29. *
  30. * Another consideration is that nr_cpu_ids is initialized
  31. * to NR_CPUS and isn't lowered until the possible cpus are
  32. * discovered (including any disabled cpus). So early uses
  33. * will span the entire range of NR_CPUS.
  34. * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  35. *
  36. * The obsolescent cpumask operations are:
  37. *
  38. * void cpu_set(cpu, mask) turn on bit 'cpu' in mask
  39. * void cpu_clear(cpu, mask) turn off bit 'cpu' in mask
  40. * void cpus_setall(mask) set all bits
  41. * void cpus_clear(mask) clear all bits
  42. * int cpu_isset(cpu, mask) true iff bit 'cpu' set in mask
  43. * int cpu_test_and_set(cpu, mask) test and set bit 'cpu' in mask
  44. *
  45. * void cpus_and(dst, src1, src2) dst = src1 & src2 [intersection]
  46. * void cpus_or(dst, src1, src2) dst = src1 | src2 [union]
  47. * void cpus_xor(dst, src1, src2) dst = src1 ^ src2
  48. * void cpus_andnot(dst, src1, src2) dst = src1 & ~src2
  49. * void cpus_complement(dst, src) dst = ~src
  50. *
  51. * int cpus_equal(mask1, mask2) Does mask1 == mask2?
  52. * int cpus_intersects(mask1, mask2) Do mask1 and mask2 intersect?
  53. * int cpus_subset(mask1, mask2) Is mask1 a subset of mask2?
  54. * int cpus_empty(mask) Is mask empty (no bits sets)?
  55. * int cpus_full(mask) Is mask full (all bits sets)?
  56. * int cpus_weight(mask) Hamming weigh - number of set bits
  57. * int cpus_weight_nr(mask) Same using nr_cpu_ids instead of NR_CPUS
  58. *
  59. * void cpus_shift_right(dst, src, n) Shift right
  60. * void cpus_shift_left(dst, src, n) Shift left
  61. *
  62. * int first_cpu(mask) Number lowest set bit, or NR_CPUS
  63. * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
  64. * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
  65. *
  66. * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
  67. * (can be used as an lvalue)
  68. * CPU_MASK_ALL Initializer - all bits set
  69. * CPU_MASK_NONE Initializer - no bits set
  70. * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
  71. *
  72. * CPUMASK_ALLOC kmalloc's a structure that is a composite of many cpumask_t
  73. * variables, and CPUMASK_PTR provides pointers to each field.
  74. *
  75. * The structure should be defined something like this:
  76. * struct my_cpumasks {
  77. * cpumask_t mask1;
  78. * cpumask_t mask2;
  79. * };
  80. *
  81. * Usage is then:
  82. * CPUMASK_ALLOC(my_cpumasks);
  83. * CPUMASK_PTR(mask1, my_cpumasks);
  84. * CPUMASK_PTR(mask2, my_cpumasks);
  85. *
  86. * --- DO NOT reference cpumask_t pointers until this check ---
  87. * if (my_cpumasks == NULL)
  88. * "kmalloc failed"...
  89. *
  90. * References are now pointers to the cpumask_t variables (*mask1, ...)
  91. *
  92. *if NR_CPUS > BITS_PER_LONG
  93. * CPUMASK_ALLOC(m) Declares and allocates struct m *m =
  94. * kmalloc(sizeof(*m), GFP_KERNEL)
  95. * CPUMASK_FREE(m) Macro for kfree(m)
  96. *else
  97. * CPUMASK_ALLOC(m) Declares struct m _m, *m = &_m
  98. * CPUMASK_FREE(m) Nop
  99. *endif
  100. * CPUMASK_PTR(v, m) Declares cpumask_t *v = &(m->v)
  101. * ------------------------------------------------------------------------
  102. *
  103. * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
  104. * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask
  105. * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
  106. * int cpulist_parse(buf, map) Parse ascii string as cpulist
  107. * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
  108. * void cpus_remap(dst, src, old, new) *dst = map(old, new)(src)
  109. * void cpus_onto(dst, orig, relmap) *dst = orig relative to relmap
  110. * void cpus_fold(dst, orig, sz) dst bits = orig bits mod sz
  111. *
  112. * for_each_cpu_mask(cpu, mask) for-loop cpu over mask using NR_CPUS
  113. * for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids
  114. *
  115. * int num_online_cpus() Number of online CPUs
  116. * int num_possible_cpus() Number of all possible CPUs
  117. * int num_present_cpus() Number of present CPUs
  118. *
  119. * int cpu_online(cpu) Is some cpu online?
  120. * int cpu_possible(cpu) Is some cpu possible?
  121. * int cpu_present(cpu) Is some cpu present (can schedule)?
  122. *
  123. * int any_online_cpu(mask) First online cpu in mask
  124. *
  125. * for_each_possible_cpu(cpu) for-loop cpu over cpu_possible_map
  126. * for_each_online_cpu(cpu) for-loop cpu over cpu_online_map
  127. * for_each_present_cpu(cpu) for-loop cpu over cpu_present_map
  128. *
  129. * Subtlety:
  130. * 1) The 'type-checked' form of cpu_isset() causes gcc (3.3.2, anyway)
  131. * to generate slightly worse code. Note for example the additional
  132. * 40 lines of assembly code compiling the "for each possible cpu"
  133. * loops buried in the disk_stat_read() macros calls when compiling
  134. * drivers/block/genhd.c (arch i386, CONFIG_SMP=y). So use a simple
  135. * one-line #define for cpu_isset(), instead of wrapping an inline
  136. * inside a macro, the way we do the other calls.
  137. */
  138. #include <linux/kernel.h>
  139. #include <linux/threads.h>
  140. #include <linux/bitmap.h>
  141. typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
  142. extern cpumask_t _unused_cpumask_arg_;
  143. #define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
  144. static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
  145. {
  146. set_bit(cpu, dstp->bits);
  147. }
  148. #define cpu_clear(cpu, dst) __cpu_clear((cpu), &(dst))
  149. static inline void __cpu_clear(int cpu, volatile cpumask_t *dstp)
  150. {
  151. clear_bit(cpu, dstp->bits);
  152. }
  153. #define cpus_setall(dst) __cpus_setall(&(dst), NR_CPUS)
  154. static inline void __cpus_setall(cpumask_t *dstp, int nbits)
  155. {
  156. bitmap_fill(dstp->bits, nbits);
  157. }
  158. #define cpus_clear(dst) __cpus_clear(&(dst), NR_CPUS)
  159. static inline void __cpus_clear(cpumask_t *dstp, int nbits)
  160. {
  161. bitmap_zero(dstp->bits, nbits);
  162. }
  163. /* No static inline type checking - see Subtlety (1) above. */
  164. #define cpu_isset(cpu, cpumask) test_bit((cpu), (cpumask).bits)
  165. #define cpu_test_and_set(cpu, cpumask) __cpu_test_and_set((cpu), &(cpumask))
  166. static inline int __cpu_test_and_set(int cpu, cpumask_t *addr)
  167. {
  168. return test_and_set_bit(cpu, addr->bits);
  169. }
  170. #define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)
  171. static inline void __cpus_and(cpumask_t *dstp, const cpumask_t *src1p,
  172. const cpumask_t *src2p, int nbits)
  173. {
  174. bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
  175. }
  176. #define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)
  177. static inline void __cpus_or(cpumask_t *dstp, const cpumask_t *src1p,
  178. const cpumask_t *src2p, int nbits)
  179. {
  180. bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
  181. }
  182. #define cpus_xor(dst, src1, src2) __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS)
  183. static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p,
  184. const cpumask_t *src2p, int nbits)
  185. {
  186. bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
  187. }
  188. #define cpus_andnot(dst, src1, src2) \
  189. __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)
  190. static inline void __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p,
  191. const cpumask_t *src2p, int nbits)
  192. {
  193. bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
  194. }
  195. #define cpus_complement(dst, src) __cpus_complement(&(dst), &(src), NR_CPUS)
  196. static inline void __cpus_complement(cpumask_t *dstp,
  197. const cpumask_t *srcp, int nbits)
  198. {
  199. bitmap_complement(dstp->bits, srcp->bits, nbits);
  200. }
  201. #define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS)
  202. static inline int __cpus_equal(const cpumask_t *src1p,
  203. const cpumask_t *src2p, int nbits)
  204. {
  205. return bitmap_equal(src1p->bits, src2p->bits, nbits);
  206. }
  207. #define cpus_intersects(src1, src2) __cpus_intersects(&(src1), &(src2), NR_CPUS)
  208. static inline int __cpus_intersects(const cpumask_t *src1p,
  209. const cpumask_t *src2p, int nbits)
  210. {
  211. return bitmap_intersects(src1p->bits, src2p->bits, nbits);
  212. }
  213. #define cpus_subset(src1, src2) __cpus_subset(&(src1), &(src2), NR_CPUS)
  214. static inline int __cpus_subset(const cpumask_t *src1p,
  215. const cpumask_t *src2p, int nbits)
  216. {
  217. return bitmap_subset(src1p->bits, src2p->bits, nbits);
  218. }
  219. #define cpus_empty(src) __cpus_empty(&(src), NR_CPUS)
  220. static inline int __cpus_empty(const cpumask_t *srcp, int nbits)
  221. {
  222. return bitmap_empty(srcp->bits, nbits);
  223. }
  224. #define cpus_full(cpumask) __cpus_full(&(cpumask), NR_CPUS)
  225. static inline int __cpus_full(const cpumask_t *srcp, int nbits)
  226. {
  227. return bitmap_full(srcp->bits, nbits);
  228. }
  229. #define cpus_weight(cpumask) __cpus_weight(&(cpumask), NR_CPUS)
  230. static inline int __cpus_weight(const cpumask_t *srcp, int nbits)
  231. {
  232. return bitmap_weight(srcp->bits, nbits);
  233. }
  234. #define cpus_shift_right(dst, src, n) \
  235. __cpus_shift_right(&(dst), &(src), (n), NR_CPUS)
  236. static inline void __cpus_shift_right(cpumask_t *dstp,
  237. const cpumask_t *srcp, int n, int nbits)
  238. {
  239. bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
  240. }
  241. #define cpus_shift_left(dst, src, n) \
  242. __cpus_shift_left(&(dst), &(src), (n), NR_CPUS)
  243. static inline void __cpus_shift_left(cpumask_t *dstp,
  244. const cpumask_t *srcp, int n, int nbits)
  245. {
  246. bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
  247. }
  248. /*
  249. * Special-case data structure for "single bit set only" constant CPU masks.
  250. *
  251. * We pre-generate all the 64 (or 32) possible bit positions, with enough
  252. * padding to the left and the right, and return the constant pointer
  253. * appropriately offset.
  254. */
  255. extern const unsigned long
  256. cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
  257. static inline const cpumask_t *get_cpu_mask(unsigned int cpu)
  258. {
  259. const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
  260. p -= cpu / BITS_PER_LONG;
  261. return (const cpumask_t *)p;
  262. }
  263. /*
  264. * In cases where we take the address of the cpumask immediately,
  265. * gcc optimizes it out (it's a constant) and there's no huge stack
  266. * variable created:
  267. */
  268. #define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
  269. #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
  270. #if NR_CPUS <= BITS_PER_LONG
  271. #define CPU_MASK_ALL \
  272. (cpumask_t) { { \
  273. [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
  274. } }
  275. #define CPU_MASK_ALL_PTR (&CPU_MASK_ALL)
  276. #else
  277. #define CPU_MASK_ALL \
  278. (cpumask_t) { { \
  279. [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
  280. [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
  281. } }
  282. /* cpu_mask_all is in init/main.c */
  283. extern cpumask_t cpu_mask_all;
  284. #define CPU_MASK_ALL_PTR (&cpu_mask_all)
  285. #endif
  286. #define CPU_MASK_NONE \
  287. (cpumask_t) { { \
  288. [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
  289. } }
  290. #define CPU_MASK_CPU0 \
  291. (cpumask_t) { { \
  292. [0] = 1UL \
  293. } }
  294. #define cpus_addr(src) ((src).bits)
  295. #if NR_CPUS > BITS_PER_LONG
  296. #define CPUMASK_ALLOC(m) struct m *m = kmalloc(sizeof(*m), GFP_KERNEL)
  297. #define CPUMASK_FREE(m) kfree(m)
  298. #else
  299. #define CPUMASK_ALLOC(m) struct m _m, *m = &_m
  300. #define CPUMASK_FREE(m)
  301. #endif
  302. #define CPUMASK_PTR(v, m) cpumask_t *v = &(m->v)
  303. #define cpumask_scnprintf(buf, len, src) \
  304. __cpumask_scnprintf((buf), (len), &(src), NR_CPUS)
  305. static inline int __cpumask_scnprintf(char *buf, int len,
  306. const cpumask_t *srcp, int nbits)
  307. {
  308. return bitmap_scnprintf(buf, len, srcp->bits, nbits);
  309. }
  310. #define cpumask_parse_user(ubuf, ulen, dst) \
  311. __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS)
  312. static inline int __cpumask_parse_user(const char __user *buf, int len,
  313. cpumask_t *dstp, int nbits)
  314. {
  315. return bitmap_parse_user(buf, len, dstp->bits, nbits);
  316. }
  317. #define cpulist_scnprintf(buf, len, src) \
  318. __cpulist_scnprintf((buf), (len), &(src), NR_CPUS)
  319. static inline int __cpulist_scnprintf(char *buf, int len,
  320. const cpumask_t *srcp, int nbits)
  321. {
  322. return bitmap_scnlistprintf(buf, len, srcp->bits, nbits);
  323. }
  324. #define cpulist_parse(buf, dst) __cpulist_parse((buf), &(dst), NR_CPUS)
  325. static inline int __cpulist_parse(const char *buf, cpumask_t *dstp, int nbits)
  326. {
  327. return bitmap_parselist(buf, dstp->bits, nbits);
  328. }
  329. #define cpu_remap(oldbit, old, new) \
  330. __cpu_remap((oldbit), &(old), &(new), NR_CPUS)
  331. static inline int __cpu_remap(int oldbit,
  332. const cpumask_t *oldp, const cpumask_t *newp, int nbits)
  333. {
  334. return bitmap_bitremap(oldbit, oldp->bits, newp->bits, nbits);
  335. }
  336. #define cpus_remap(dst, src, old, new) \
  337. __cpus_remap(&(dst), &(src), &(old), &(new), NR_CPUS)
  338. static inline void __cpus_remap(cpumask_t *dstp, const cpumask_t *srcp,
  339. const cpumask_t *oldp, const cpumask_t *newp, int nbits)
  340. {
  341. bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
  342. }
  343. #define cpus_onto(dst, orig, relmap) \
  344. __cpus_onto(&(dst), &(orig), &(relmap), NR_CPUS)
  345. static inline void __cpus_onto(cpumask_t *dstp, const cpumask_t *origp,
  346. const cpumask_t *relmapp, int nbits)
  347. {
  348. bitmap_onto(dstp->bits, origp->bits, relmapp->bits, nbits);
  349. }
  350. #define cpus_fold(dst, orig, sz) \
  351. __cpus_fold(&(dst), &(orig), sz, NR_CPUS)
  352. static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,
  353. int sz, int nbits)
  354. {
  355. bitmap_fold(dstp->bits, origp->bits, sz, nbits);
  356. }
  357. #if NR_CPUS == 1
  358. #define nr_cpu_ids 1
  359. #define first_cpu(src) ({ (void)(src); 0; })
  360. #define next_cpu(n, src) ({ (void)(src); 1; })
  361. #define any_online_cpu(mask) 0
  362. #define for_each_cpu_mask(cpu, mask) \
  363. for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
  364. #else /* NR_CPUS > 1 */
  365. extern int nr_cpu_ids;
  366. int __first_cpu(const cpumask_t *srcp);
  367. int __next_cpu(int n, const cpumask_t *srcp);
  368. int __any_online_cpu(const cpumask_t *mask);
  369. #define first_cpu(src) __first_cpu(&(src))
  370. #define next_cpu(n, src) __next_cpu((n), &(src))
  371. #define any_online_cpu(mask) __any_online_cpu(&(mask))
  372. #define for_each_cpu_mask(cpu, mask) \
  373. for ((cpu) = -1; \
  374. (cpu) = next_cpu((cpu), (mask)), \
  375. (cpu) < NR_CPUS; )
  376. #endif
  377. #if NR_CPUS <= 64
  378. #define next_cpu_nr(n, src) next_cpu(n, src)
  379. #define cpus_weight_nr(cpumask) cpus_weight(cpumask)
  380. #define for_each_cpu_mask_nr(cpu, mask) for_each_cpu_mask(cpu, mask)
  381. #else /* NR_CPUS > 64 */
  382. int __next_cpu_nr(int n, const cpumask_t *srcp);
  383. #define next_cpu_nr(n, src) __next_cpu_nr((n), &(src))
  384. #define cpus_weight_nr(cpumask) __cpus_weight(&(cpumask), nr_cpu_ids)
  385. #define for_each_cpu_mask_nr(cpu, mask) \
  386. for ((cpu) = -1; \
  387. (cpu) = next_cpu_nr((cpu), (mask)), \
  388. (cpu) < nr_cpu_ids; )
  389. #endif /* NR_CPUS > 64 */
  390. /*
  391. * The following particular system cpumasks and operations manage
  392. * possible, present, active and online cpus. Each of them is a fixed size
  393. * bitmap of size NR_CPUS.
  394. *
  395. * #ifdef CONFIG_HOTPLUG_CPU
  396. * cpu_possible_map - has bit 'cpu' set iff cpu is populatable
  397. * cpu_present_map - has bit 'cpu' set iff cpu is populated
  398. * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler
  399. * cpu_active_map - has bit 'cpu' set iff cpu available to migration
  400. * #else
  401. * cpu_possible_map - has bit 'cpu' set iff cpu is populated
  402. * cpu_present_map - copy of cpu_possible_map
  403. * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler
  404. * #endif
  405. *
  406. * In either case, NR_CPUS is fixed at compile time, as the static
  407. * size of these bitmaps. The cpu_possible_map is fixed at boot
  408. * time, as the set of CPU id's that it is possible might ever
  409. * be plugged in at anytime during the life of that system boot.
  410. * The cpu_present_map is dynamic(*), representing which CPUs
  411. * are currently plugged in. And cpu_online_map is the dynamic
  412. * subset of cpu_present_map, indicating those CPUs available
  413. * for scheduling.
  414. *
  415. * If HOTPLUG is enabled, then cpu_possible_map is forced to have
  416. * all NR_CPUS bits set, otherwise it is just the set of CPUs that
  417. * ACPI reports present at boot.
  418. *
  419. * If HOTPLUG is enabled, then cpu_present_map varies dynamically,
  420. * depending on what ACPI reports as currently plugged in, otherwise
  421. * cpu_present_map is just a copy of cpu_possible_map.
  422. *
  423. * (*) Well, cpu_present_map is dynamic in the hotplug case. If not
  424. * hotplug, it's a copy of cpu_possible_map, hence fixed at boot.
  425. *
  426. * Subtleties:
  427. * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode
  428. * assumption that their single CPU is online. The UP
  429. * cpu_{online,possible,present}_maps are placebos. Changing them
  430. * will have no useful affect on the following num_*_cpus()
  431. * and cpu_*() macros in the UP case. This ugliness is a UP
  432. * optimization - don't waste any instructions or memory references
  433. * asking if you're online or how many CPUs there are if there is
  434. * only one CPU.
  435. * 2) Most SMP arch's #define some of these maps to be some
  436. * other map specific to that arch. Therefore, the following
  437. * must be #define macros, not inlines. To see why, examine
  438. * the assembly code produced by the following. Note that
  439. * set1() writes phys_x_map, but set2() writes x_map:
  440. * int x_map, phys_x_map;
  441. * #define set1(a) x_map = a
  442. * inline void set2(int a) { x_map = a; }
  443. * #define x_map phys_x_map
  444. * main(){ set1(3); set2(5); }
  445. */
  446. extern cpumask_t cpu_possible_map;
  447. extern cpumask_t cpu_online_map;
  448. extern cpumask_t cpu_present_map;
  449. extern cpumask_t cpu_active_map;
  450. #if NR_CPUS > 1
  451. #define num_online_cpus() cpus_weight_nr(cpu_online_map)
  452. #define num_possible_cpus() cpus_weight_nr(cpu_possible_map)
  453. #define num_present_cpus() cpus_weight_nr(cpu_present_map)
  454. #define cpu_online(cpu) cpu_isset((cpu), cpu_online_map)
  455. #define cpu_possible(cpu) cpu_isset((cpu), cpu_possible_map)
  456. #define cpu_present(cpu) cpu_isset((cpu), cpu_present_map)
  457. #define cpu_active(cpu) cpu_isset((cpu), cpu_active_map)
  458. #else
  459. #define num_online_cpus() 1
  460. #define num_possible_cpus() 1
  461. #define num_present_cpus() 1
  462. #define cpu_online(cpu) ((cpu) == 0)
  463. #define cpu_possible(cpu) ((cpu) == 0)
  464. #define cpu_present(cpu) ((cpu) == 0)
  465. #define cpu_active(cpu) ((cpu) == 0)
  466. #endif
  467. #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
  468. #define for_each_possible_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_possible_map)
  469. #define for_each_online_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_online_map)
  470. #define for_each_present_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_present_map)
  471. /* These are the new versions of the cpumask operators: passed by pointer.
  472. * The older versions will be implemented in terms of these, then deleted. */
  473. #define cpumask_bits(maskp) ((maskp)->bits)
  474. #if NR_CPUS <= BITS_PER_LONG
  475. #define CPU_BITS_ALL \
  476. { \
  477. [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
  478. }
  479. /* This produces more efficient code. */
  480. #define nr_cpumask_bits NR_CPUS
  481. #else /* NR_CPUS > BITS_PER_LONG */
  482. #define CPU_BITS_ALL \
  483. { \
  484. [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
  485. [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
  486. }
  487. #define nr_cpumask_bits nr_cpu_ids
  488. #endif /* NR_CPUS > BITS_PER_LONG */
  489. /* verify cpu argument to cpumask_* operators */
  490. static inline unsigned int cpumask_check(unsigned int cpu)
  491. {
  492. #ifdef CONFIG_DEBUG_PER_CPU_MAPS
  493. WARN_ON_ONCE(cpu >= nr_cpumask_bits);
  494. #endif /* CONFIG_DEBUG_PER_CPU_MAPS */
  495. return cpu;
  496. }
  497. #if NR_CPUS == 1
  498. /* Uniprocessor. Assume all masks are "1". */
  499. static inline unsigned int cpumask_first(const struct cpumask *srcp)
  500. {
  501. return 0;
  502. }
  503. /* Valid inputs for n are -1 and 0. */
  504. static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
  505. {
  506. return n+1;
  507. }
  508. static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
  509. {
  510. return n+1;
  511. }
  512. static inline unsigned int cpumask_next_and(int n,
  513. const struct cpumask *srcp,
  514. const struct cpumask *andp)
  515. {
  516. return n+1;
  517. }
  518. /* cpu must be a valid cpu, ie 0, so there's no other choice. */
  519. static inline unsigned int cpumask_any_but(const struct cpumask *mask,
  520. unsigned int cpu)
  521. {
  522. return 1;
  523. }
  524. #define for_each_cpu(cpu, mask) \
  525. for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
  526. #define for_each_cpu_and(cpu, mask, and) \
  527. for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask, (void)and)
  528. #else
  529. /**
  530. * cpumask_first - get the first cpu in a cpumask
  531. * @srcp: the cpumask pointer
  532. *
  533. * Returns >= nr_cpu_ids if no cpus set.
  534. */
  535. static inline unsigned int cpumask_first(const struct cpumask *srcp)
  536. {
  537. return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits);
  538. }
  539. /**
  540. * cpumask_next - get the next cpu in a cpumask
  541. * @n: the cpu prior to the place to search (ie. return will be > @n)
  542. * @srcp: the cpumask pointer
  543. *
  544. * Returns >= nr_cpu_ids if no further cpus set.
  545. */
  546. static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
  547. {
  548. /* -1 is a legal arg here. */
  549. if (n != -1)
  550. cpumask_check(n);
  551. return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
  552. }
  553. /**
  554. * cpumask_next_zero - get the next unset cpu in a cpumask
  555. * @n: the cpu prior to the place to search (ie. return will be > @n)
  556. * @srcp: the cpumask pointer
  557. *
  558. * Returns >= nr_cpu_ids if no further cpus unset.
  559. */
  560. static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
  561. {
  562. /* -1 is a legal arg here. */
  563. if (n != -1)
  564. cpumask_check(n);
  565. return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
  566. }
  567. int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
  568. int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
  569. /**
  570. * for_each_cpu - iterate over every cpu in a mask
  571. * @cpu: the (optionally unsigned) integer iterator
  572. * @mask: the cpumask pointer
  573. *
  574. * After the loop, cpu is >= nr_cpu_ids.
  575. */
  576. #define for_each_cpu(cpu, mask) \
  577. for ((cpu) = -1; \
  578. (cpu) = cpumask_next((cpu), (mask)), \
  579. (cpu) < nr_cpu_ids;)
  580. /**
  581. * for_each_cpu_and - iterate over every cpu in both masks
  582. * @cpu: the (optionally unsigned) integer iterator
  583. * @mask: the first cpumask pointer
  584. * @and: the second cpumask pointer
  585. *
  586. * This saves a temporary CPU mask in many places. It is equivalent to:
  587. * struct cpumask tmp;
  588. * cpumask_and(&tmp, &mask, &and);
  589. * for_each_cpu(cpu, &tmp)
  590. * ...
  591. *
  592. * After the loop, cpu is >= nr_cpu_ids.
  593. */
  594. #define for_each_cpu_and(cpu, mask, and) \
  595. for ((cpu) = -1; \
  596. (cpu) = cpumask_next_and((cpu), (mask), (and)), \
  597. (cpu) < nr_cpu_ids;)
  598. #endif /* SMP */
  599. #define CPU_BITS_NONE \
  600. { \
  601. [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
  602. }
  603. #define CPU_BITS_CPU0 \
  604. { \
  605. [0] = 1UL \
  606. }
  607. /**
  608. * cpumask_set_cpu - set a cpu in a cpumask
  609. * @cpu: cpu number (< nr_cpu_ids)
  610. * @dstp: the cpumask pointer
  611. */
  612. static inline void cpumask_set_cpu(unsigned int cpu, struct cpumask *dstp)
  613. {
  614. set_bit(cpumask_check(cpu), cpumask_bits(dstp));
  615. }
  616. /**
  617. * cpumask_clear_cpu - clear a cpu in a cpumask
  618. * @cpu: cpu number (< nr_cpu_ids)
  619. * @dstp: the cpumask pointer
  620. */
  621. static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp)
  622. {
  623. clear_bit(cpumask_check(cpu), cpumask_bits(dstp));
  624. }
  625. /**
  626. * cpumask_test_cpu - test for a cpu in a cpumask
  627. * @cpu: cpu number (< nr_cpu_ids)
  628. * @cpumask: the cpumask pointer
  629. *
  630. * No static inline type checking - see Subtlety (1) above.
  631. */
  632. #define cpumask_test_cpu(cpu, cpumask) \
  633. test_bit(cpumask_check(cpu), (cpumask)->bits)
  634. /**
  635. * cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask
  636. * @cpu: cpu number (< nr_cpu_ids)
  637. * @cpumask: the cpumask pointer
  638. *
  639. * test_and_set_bit wrapper for cpumasks.
  640. */
  641. static inline int cpumask_test_and_set_cpu(int cpu, struct cpumask *cpumask)
  642. {
  643. return test_and_set_bit(cpumask_check(cpu), cpumask_bits(cpumask));
  644. }
  645. /**
  646. * cpumask_setall - set all cpus (< nr_cpu_ids) in a cpumask
  647. * @dstp: the cpumask pointer
  648. */
  649. static inline void cpumask_setall(struct cpumask *dstp)
  650. {
  651. bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits);
  652. }
  653. /**
  654. * cpumask_clear - clear all cpus (< nr_cpu_ids) in a cpumask
  655. * @dstp: the cpumask pointer
  656. */
  657. static inline void cpumask_clear(struct cpumask *dstp)
  658. {
  659. bitmap_zero(cpumask_bits(dstp), nr_cpumask_bits);
  660. }
  661. /**
  662. * cpumask_and - *dstp = *src1p & *src2p
  663. * @dstp: the cpumask result
  664. * @src1p: the first input
  665. * @src2p: the second input
  666. */
  667. static inline void cpumask_and(struct cpumask *dstp,
  668. const struct cpumask *src1p,
  669. const struct cpumask *src2p)
  670. {
  671. bitmap_and(cpumask_bits(dstp), cpumask_bits(src1p),
  672. cpumask_bits(src2p), nr_cpumask_bits);
  673. }
  674. /**
  675. * cpumask_or - *dstp = *src1p | *src2p
  676. * @dstp: the cpumask result
  677. * @src1p: the first input
  678. * @src2p: the second input
  679. */
  680. static inline void cpumask_or(struct cpumask *dstp, const struct cpumask *src1p,
  681. const struct cpumask *src2p)
  682. {
  683. bitmap_or(cpumask_bits(dstp), cpumask_bits(src1p),
  684. cpumask_bits(src2p), nr_cpumask_bits);
  685. }
  686. /**
  687. * cpumask_xor - *dstp = *src1p ^ *src2p
  688. * @dstp: the cpumask result
  689. * @src1p: the first input
  690. * @src2p: the second input
  691. */
  692. static inline void cpumask_xor(struct cpumask *dstp,
  693. const struct cpumask *src1p,
  694. const struct cpumask *src2p)
  695. {
  696. bitmap_xor(cpumask_bits(dstp), cpumask_bits(src1p),
  697. cpumask_bits(src2p), nr_cpumask_bits);
  698. }
  699. /**
  700. * cpumask_andnot - *dstp = *src1p & ~*src2p
  701. * @dstp: the cpumask result
  702. * @src1p: the first input
  703. * @src2p: the second input
  704. */
  705. static inline void cpumask_andnot(struct cpumask *dstp,
  706. const struct cpumask *src1p,
  707. const struct cpumask *src2p)
  708. {
  709. bitmap_andnot(cpumask_bits(dstp), cpumask_bits(src1p),
  710. cpumask_bits(src2p), nr_cpumask_bits);
  711. }
  712. /**
  713. * cpumask_complement - *dstp = ~*srcp
  714. * @dstp: the cpumask result
  715. * @srcp: the input to invert
  716. */
  717. static inline void cpumask_complement(struct cpumask *dstp,
  718. const struct cpumask *srcp)
  719. {
  720. bitmap_complement(cpumask_bits(dstp), cpumask_bits(srcp),
  721. nr_cpumask_bits);
  722. }
  723. /**
  724. * cpumask_equal - *src1p == *src2p
  725. * @src1p: the first input
  726. * @src2p: the second input
  727. */
  728. static inline bool cpumask_equal(const struct cpumask *src1p,
  729. const struct cpumask *src2p)
  730. {
  731. return bitmap_equal(cpumask_bits(src1p), cpumask_bits(src2p),
  732. nr_cpumask_bits);
  733. }
  734. /**
  735. * cpumask_intersects - (*src1p & *src2p) != 0
  736. * @src1p: the first input
  737. * @src2p: the second input
  738. */
  739. static inline bool cpumask_intersects(const struct cpumask *src1p,
  740. const struct cpumask *src2p)
  741. {
  742. return bitmap_intersects(cpumask_bits(src1p), cpumask_bits(src2p),
  743. nr_cpumask_bits);
  744. }
  745. /**
  746. * cpumask_subset - (*src1p & ~*src2p) == 0
  747. * @src1p: the first input
  748. * @src2p: the second input
  749. */
  750. static inline int cpumask_subset(const struct cpumask *src1p,
  751. const struct cpumask *src2p)
  752. {
  753. return bitmap_subset(cpumask_bits(src1p), cpumask_bits(src2p),
  754. nr_cpumask_bits);
  755. }
  756. /**
  757. * cpumask_empty - *srcp == 0
  758. * @srcp: the cpumask to that all cpus < nr_cpu_ids are clear.
  759. */
  760. static inline bool cpumask_empty(const struct cpumask *srcp)
  761. {
  762. return bitmap_empty(cpumask_bits(srcp), nr_cpumask_bits);
  763. }
  764. /**
  765. * cpumask_full - *srcp == 0xFFFFFFFF...
  766. * @srcp: the cpumask to that all cpus < nr_cpu_ids are set.
  767. */
  768. static inline bool cpumask_full(const struct cpumask *srcp)
  769. {
  770. return bitmap_full(cpumask_bits(srcp), nr_cpumask_bits);
  771. }
  772. /**
  773. * cpumask_weight - Count of bits in *srcp
  774. * @srcp: the cpumask to count bits (< nr_cpu_ids) in.
  775. */
  776. static inline unsigned int cpumask_weight(const struct cpumask *srcp)
  777. {
  778. return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits);
  779. }
  780. /**
  781. * cpumask_shift_right - *dstp = *srcp >> n
  782. * @dstp: the cpumask result
  783. * @srcp: the input to shift
  784. * @n: the number of bits to shift by
  785. */
  786. static inline void cpumask_shift_right(struct cpumask *dstp,
  787. const struct cpumask *srcp, int n)
  788. {
  789. bitmap_shift_right(cpumask_bits(dstp), cpumask_bits(srcp), n,
  790. nr_cpumask_bits);
  791. }
  792. /**
  793. * cpumask_shift_left - *dstp = *srcp << n
  794. * @dstp: the cpumask result
  795. * @srcp: the input to shift
  796. * @n: the number of bits to shift by
  797. */
  798. static inline void cpumask_shift_left(struct cpumask *dstp,
  799. const struct cpumask *srcp, int n)
  800. {
  801. bitmap_shift_left(cpumask_bits(dstp), cpumask_bits(srcp), n,
  802. nr_cpumask_bits);
  803. }
  804. /**
  805. * cpumask_copy - *dstp = *srcp
  806. * @dstp: the result
  807. * @srcp: the input cpumask
  808. */
  809. static inline void cpumask_copy(struct cpumask *dstp,
  810. const struct cpumask *srcp)
  811. {
  812. bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), nr_cpumask_bits);
  813. }
  814. /**
  815. * cpumask_any - pick a "random" cpu from *srcp
  816. * @srcp: the input cpumask
  817. *
  818. * Returns >= nr_cpu_ids if no cpus set.
  819. */
  820. #define cpumask_any(srcp) cpumask_first(srcp)
  821. /**
  822. * cpumask_first_and - return the first cpu from *srcp1 & *srcp2
  823. * @src1p: the first input
  824. * @src2p: the second input
  825. *
  826. * Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and().
  827. */
  828. #define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p))
  829. /**
  830. * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2
  831. * @mask1: the first input cpumask
  832. * @mask2: the second input cpumask
  833. *
  834. * Returns >= nr_cpu_ids if no cpus set.
  835. */
  836. #define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))
  837. /**
  838. * cpumask_of - the cpumask containing just a given cpu
  839. * @cpu: the cpu (<= nr_cpu_ids)
  840. */
  841. #define cpumask_of(cpu) (get_cpu_mask(cpu))
  842. /**
  843. * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask *
  844. * @bitmap: the bitmap
  845. *
  846. * There are a few places where cpumask_var_t isn't appropriate and
  847. * static cpumasks must be used (eg. very early boot), yet we don't
  848. * expose the definition of 'struct cpumask'.
  849. *
  850. * This does the conversion, and can be used as a constant initializer.
  851. */
  852. #define to_cpumask(bitmap) \
  853. ((struct cpumask *)(1 ? (bitmap) \
  854. : (void *)sizeof(__check_is_bitmap(bitmap))))
  855. static inline int __check_is_bitmap(const unsigned long *bitmap)
  856. {
  857. return 1;
  858. }
  859. /**
  860. * cpumask_size - size to allocate for a 'struct cpumask' in bytes
  861. *
  862. * This will eventually be a runtime variable, depending on nr_cpu_ids.
  863. */
  864. static inline size_t cpumask_size(void)
  865. {
  866. /* FIXME: Once all cpumask assignments are eliminated, this
  867. * can be nr_cpumask_bits */
  868. return BITS_TO_LONGS(NR_CPUS) * sizeof(long);
  869. }
  870. /*
  871. * cpumask_var_t: struct cpumask for stack usage.
  872. *
  873. * Oh, the wicked games we play! In order to make kernel coding a
  874. * little more difficult, we typedef cpumask_var_t to an array or a
  875. * pointer: doing &mask on an array is a noop, so it still works.
  876. *
  877. * ie.
  878. * cpumask_var_t tmpmask;
  879. * if (!alloc_cpumask_var(&tmpmask, GFP_KERNEL))
  880. * return -ENOMEM;
  881. *
  882. * ... use 'tmpmask' like a normal struct cpumask * ...
  883. *
  884. * free_cpumask_var(tmpmask);
  885. */
  886. #ifdef CONFIG_CPUMASK_OFFSTACK
  887. typedef struct cpumask *cpumask_var_t;
  888. bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags);
  889. void alloc_bootmem_cpumask_var(cpumask_var_t *mask);
  890. void free_cpumask_var(cpumask_var_t mask);
  891. void free_bootmem_cpumask_var(cpumask_var_t mask);
  892. #else
  893. typedef struct cpumask cpumask_var_t[1];
  894. static inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
  895. {
  896. return true;
  897. }
  898. static inline void alloc_bootmem_cpumask_var(cpumask_var_t *mask)
  899. {
  900. }
  901. static inline void free_cpumask_var(cpumask_var_t mask)
  902. {
  903. }
  904. static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
  905. {
  906. }
  907. #endif /* CONFIG_CPUMASK_OFFSTACK */
  908. /* The pointer versions of the maps, these will become the primary versions. */
  909. #define cpu_possible_mask ((const struct cpumask *)&cpu_possible_map)
  910. #define cpu_online_mask ((const struct cpumask *)&cpu_online_map)
  911. #define cpu_present_mask ((const struct cpumask *)&cpu_present_map)
  912. #define cpu_active_mask ((const struct cpumask *)&cpu_active_map)
  913. /* It's common to want to use cpu_all_mask in struct member initializers,
  914. * so it has to refer to an address rather than a pointer. */
  915. extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS);
  916. #define cpu_all_mask to_cpumask(cpu_all_bits)
  917. /* First bits of cpu_bit_bitmap are in fact unset. */
  918. #define cpu_none_mask to_cpumask(cpu_bit_bitmap[0])
  919. /* Wrappers for arch boot code to manipulate normally-constant masks */
  920. static inline void set_cpu_possible(unsigned int cpu, bool possible)
  921. {
  922. if (possible)
  923. cpumask_set_cpu(cpu, &cpu_possible_map);
  924. else
  925. cpumask_clear_cpu(cpu, &cpu_possible_map);
  926. }
  927. static inline void set_cpu_present(unsigned int cpu, bool present)
  928. {
  929. if (present)
  930. cpumask_set_cpu(cpu, &cpu_present_map);
  931. else
  932. cpumask_clear_cpu(cpu, &cpu_present_map);
  933. }
  934. static inline void set_cpu_online(unsigned int cpu, bool online)
  935. {
  936. if (online)
  937. cpumask_set_cpu(cpu, &cpu_online_map);
  938. else
  939. cpumask_clear_cpu(cpu, &cpu_online_map);
  940. }
  941. static inline void set_cpu_active(unsigned int cpu, bool active)
  942. {
  943. if (active)
  944. cpumask_set_cpu(cpu, &cpu_active_map);
  945. else
  946. cpumask_clear_cpu(cpu, &cpu_active_map);
  947. }
  948. static inline void init_cpu_present(const struct cpumask *src)
  949. {
  950. cpumask_copy(&cpu_present_map, src);
  951. }
  952. static inline void init_cpu_possible(const struct cpumask *src)
  953. {
  954. cpumask_copy(&cpu_possible_map, src);
  955. }
  956. static inline void init_cpu_online(const struct cpumask *src)
  957. {
  958. cpumask_copy(&cpu_online_map, src);
  959. }
  960. #endif /* __LINUX_CPUMASK_H */