aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 21:14:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 21:14:11 -0400
commit94a8d5caba74211ec76dac80fc6e2d5c391530df (patch)
tree21d17d214a354ae00ae27217d82b67bfc5bff3a3 /include
parent2bcd57ab61e7cabed626226a3771617981c11ce1 (diff)
parent6ba2ef7baac23a5d9bb85e28b882d16b439a2293 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: (39 commits) cpumask: Move deprecated functions to end of header. cpumask: remove unused deprecated functions, avoid accusations of insanity cpumask: use new-style cpumask ops in mm/quicklist. cpumask: use mm_cpumask() wrapper: x86 cpumask: use mm_cpumask() wrapper: um cpumask: use mm_cpumask() wrapper: mips cpumask: use mm_cpumask() wrapper: mn10300 cpumask: use mm_cpumask() wrapper: m32r cpumask: use mm_cpumask() wrapper: arm cpumask: Use accessors for cpu_*_mask: um cpumask: Use accessors for cpu_*_mask: powerpc cpumask: Use accessors for cpu_*_mask: mips cpumask: Use accessors for cpu_*_mask: m32r cpumask: remove arch_send_call_function_ipi cpumask: arch_send_call_function_ipi_mask: s390 cpumask: arch_send_call_function_ipi_mask: powerpc cpumask: arch_send_call_function_ipi_mask: mips cpumask: arch_send_call_function_ipi_mask: m32r cpumask: arch_send_call_function_ipi_mask: alpha cpumask: remove obsolete topology_core_siblings and topology_thread_siblings: ia64 ...
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/topology.h17
-rw-r--r--include/linux/cpumask.h709
-rw-r--r--include/linux/interrupt.h2
-rw-r--r--include/linux/sched.h3
-rw-r--r--include/linux/smp.h11
-rw-r--r--include/linux/topology.h6
6 files changed, 255 insertions, 493 deletions
diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index 88bada2ebc4b..510df36dd5d4 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -37,9 +37,6 @@
37#ifndef parent_node 37#ifndef parent_node
38#define parent_node(node) ((void)(node),0) 38#define parent_node(node) ((void)(node),0)
39#endif 39#endif
40#ifndef node_to_cpumask
41#define node_to_cpumask(node) ((void)node, cpu_online_map)
42#endif
43#ifndef cpumask_of_node 40#ifndef cpumask_of_node
44#define cpumask_of_node(node) ((void)node, cpu_online_mask) 41#define cpumask_of_node(node) ((void)node, cpu_online_mask)
45#endif 42#endif
@@ -55,18 +52,4 @@
55 52
56#endif /* CONFIG_NUMA */ 53#endif /* CONFIG_NUMA */
57 54
58/*
59 * returns pointer to cpumask for specified node
60 * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"
61 */
62#ifndef node_to_cpumask_ptr
63
64#define node_to_cpumask_ptr(v, node) \
65 cpumask_t _##v = node_to_cpumask(node); \
66 const cpumask_t *v = &_##v
67
68#define node_to_cpumask_ptr_next(v, node) \
69 _##v = node_to_cpumask(node)
70#endif
71
72#endif /* _ASM_GENERIC_TOPOLOGY_H */ 55#endif /* _ASM_GENERIC_TOPOLOGY_H */
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 9b1d458aac6e..789cf5f920ce 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -3,444 +3,37 @@
3 3
4/* 4/*
5 * Cpumasks provide a bitmap suitable for representing the 5 * Cpumasks provide a bitmap suitable for representing the
6 * set of CPU's in a system, one bit position per CPU number. 6 * set of CPU's in a system, one bit position per CPU number. In general,
7 * 7 * only nr_cpu_ids (<= NR_CPUS) bits are valid.
8 * The new cpumask_ ops take a "struct cpumask *"; the old ones
9 * use cpumask_t.
10 *
11 * See detailed comments in the file linux/bitmap.h describing the
12 * data type on which these cpumasks are based.
13 *
14 * For details of cpumask_scnprintf() and cpumask_parse_user(),
15 * see bitmap_scnprintf() and bitmap_parse_user() in lib/bitmap.c.
16 * For details of cpulist_scnprintf() and cpulist_parse(), see
17 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
18 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c
19 * For details of cpus_remap(), see bitmap_remap in lib/bitmap.c.
20 * For details of cpus_onto(), see bitmap_onto in lib/bitmap.c.
21 * For details of cpus_fold(), see bitmap_fold in lib/bitmap.c.
22 *
23 * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24 * Note: The alternate operations with the suffix "_nr" are used
25 * to limit the range of the loop to nr_cpu_ids instead of
26 * NR_CPUS when NR_CPUS > 64 for performance reasons.
27 * If NR_CPUS is <= 64 then most assembler bitmask
28 * operators execute faster with a constant range, so
29 * the operator will continue to use NR_CPUS.
30 *
31 * Another consideration is that nr_cpu_ids is initialized
32 * to NR_CPUS and isn't lowered until the possible cpus are
33 * discovered (including any disabled cpus). So early uses
34 * will span the entire range of NR_CPUS.
35 * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36 *
37 * The obsolescent cpumask operations are:
38 *
39 * void cpu_set(cpu, mask) turn on bit 'cpu' in mask
40 * void cpu_clear(cpu, mask) turn off bit 'cpu' in mask
41 * void cpus_setall(mask) set all bits
42 * void cpus_clear(mask) clear all bits
43 * int cpu_isset(cpu, mask) true iff bit 'cpu' set in mask
44 * int cpu_test_and_set(cpu, mask) test and set bit 'cpu' in mask
45 *
46 * int cpus_and(dst, src1, src2) dst = src1 & src2 [intersection]
47 * void cpus_or(dst, src1, src2) dst = src1 | src2 [union]
48 * void cpus_xor(dst, src1, src2) dst = src1 ^ src2
49 * int cpus_andnot(dst, src1, src2) dst = src1 & ~src2
50 * void cpus_complement(dst, src) dst = ~src
51 *
52 * int cpus_equal(mask1, mask2) Does mask1 == mask2?
53 * int cpus_intersects(mask1, mask2) Do mask1 and mask2 intersect?
54 * int cpus_subset(mask1, mask2) Is mask1 a subset of mask2?
55 * int cpus_empty(mask) Is mask empty (no bits sets)?
56 * int cpus_full(mask) Is mask full (all bits sets)?
57 * int cpus_weight(mask) Hamming weigh - number of set bits
58 * int cpus_weight_nr(mask) Same using nr_cpu_ids instead of NR_CPUS
59 *
60 * void cpus_shift_right(dst, src, n) Shift right
61 * void cpus_shift_left(dst, src, n) Shift left
62 *
63 * int first_cpu(mask) Number lowest set bit, or NR_CPUS
64 * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
65 * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
66 *
67 * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
68 * (can be used as an lvalue)
69 * CPU_MASK_ALL Initializer - all bits set
70 * CPU_MASK_NONE Initializer - no bits set
71 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
72 *
73 * CPUMASK_ALLOC kmalloc's a structure that is a composite of many cpumask_t
74 * variables, and CPUMASK_PTR provides pointers to each field.
75 *
76 * The structure should be defined something like this:
77 * struct my_cpumasks {
78 * cpumask_t mask1;
79 * cpumask_t mask2;
80 * };
81 *
82 * Usage is then:
83 * CPUMASK_ALLOC(my_cpumasks);
84 * CPUMASK_PTR(mask1, my_cpumasks);
85 * CPUMASK_PTR(mask2, my_cpumasks);
86 *
87 * --- DO NOT reference cpumask_t pointers until this check ---
88 * if (my_cpumasks == NULL)
89 * "kmalloc failed"...
90 *
91 * References are now pointers to the cpumask_t variables (*mask1, ...)
92 *
93 *if NR_CPUS > BITS_PER_LONG
94 * CPUMASK_ALLOC(m) Declares and allocates struct m *m =
95 * kmalloc(sizeof(*m), GFP_KERNEL)
96 * CPUMASK_FREE(m) Macro for kfree(m)
97 *else
98 * CPUMASK_ALLOC(m) Declares struct m _m, *m = &_m
99 * CPUMASK_FREE(m) Nop
100 *endif
101 * CPUMASK_PTR(v, m) Declares cpumask_t *v = &(m->v)
102 * ------------------------------------------------------------------------
103 *
104 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
105 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask
106 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
107 * int cpulist_parse(buf, map) Parse ascii string as cpulist
108 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
109 * void cpus_remap(dst, src, old, new) *dst = map(old, new)(src)
110 * void cpus_onto(dst, orig, relmap) *dst = orig relative to relmap
111 * void cpus_fold(dst, orig, sz) dst bits = orig bits mod sz
112 *
113 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask using NR_CPUS
114 * for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids
115 *
116 * int num_online_cpus() Number of online CPUs
117 * int num_possible_cpus() Number of all possible CPUs
118 * int num_present_cpus() Number of present CPUs
119 *
120 * int cpu_online(cpu) Is some cpu online?
121 * int cpu_possible(cpu) Is some cpu possible?
122 * int cpu_present(cpu) Is some cpu present (can schedule)?
123 *
124 * int any_online_cpu(mask) First online cpu in mask
125 *
126 * for_each_possible_cpu(cpu) for-loop cpu over cpu_possible_map
127 * for_each_online_cpu(cpu) for-loop cpu over cpu_online_map
128 * for_each_present_cpu(cpu) for-loop cpu over cpu_present_map
129 *
130 * Subtlety:
131 * 1) The 'type-checked' form of cpu_isset() causes gcc (3.3.2, anyway)
132 * to generate slightly worse code. Note for example the additional
133 * 40 lines of assembly code compiling the "for each possible cpu"
134 * loops buried in the disk_stat_read() macros calls when compiling
135 * drivers/block/genhd.c (arch i386, CONFIG_SMP=y). So use a simple
136 * one-line #define for cpu_isset(), instead of wrapping an inline
137 * inside a macro, the way we do the other calls.
138 */ 8 */
139
140#include <linux/kernel.h> 9#include <linux/kernel.h>
141#include <linux/threads.h> 10#include <linux/threads.h>
142#include <linux/bitmap.h> 11#include <linux/bitmap.h>
143 12
144typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t; 13typedef 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/* No static inline type checking - see Subtlety (1) above. */
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 int __cpus_and(cpumask_t *dstp, const cpumask_t *src1p,
183 const cpumask_t *src2p, int nbits)
184{
185 return 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 int __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p,
205 const cpumask_t *src2p, int nbits)
206{
207 return 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 /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
272 14
273/** 15/**
274 * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask * 16 * cpumask_bits - get the bits in a cpumask
275 * @bitmap: the bitmap 17 * @maskp: the struct cpumask *
276 *
277 * There are a few places where cpumask_var_t isn't appropriate and
278 * static cpumasks must be used (eg. very early boot), yet we don't
279 * expose the definition of 'struct cpumask'.
280 *
281 * This does the conversion, and can be used as a constant initializer.
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 * Special-case data structure for "single bit set only" constant CPU masks.
294 * 18 *
295 * We pre-generate all the 64 (or 32) possible bit positions, with enough 19 * You should only assume nr_cpu_ids bits of this mask are valid. This is
296 * padding to the left and the right, and return the constant pointer 20 * a macro so it's const-correct.
297 * appropriately offset.
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 * In cases where we take the address of the cpumask immediately,
312 * gcc optimizes it out (it's a constant) and there's no huge stack
313 * variable created:
314 */ 21 */
315#define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu)) 22#define cpumask_bits(maskp) ((maskp)->bits)
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/* cpu_mask_all is in init/main.c */
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 /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
396 23
397#if NR_CPUS == 1 24#if NR_CPUS == 1
398
399#define nr_cpu_ids 1 25#define nr_cpu_ids 1
400#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS 26#else
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 /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
407#else /* NR_CPUS > 1 */
408
409extern int nr_cpu_ids; 27extern 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 /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
423#endif 28#endif
424 29
425#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS 30#ifdef CONFIG_CPUMASK_OFFSTACK
426#if NR_CPUS <= 64 31/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,
427 32 * not all bits may be allocated. */
428#define next_cpu_nr(n, src) next_cpu(n, src) 33#define nr_cpumask_bits nr_cpu_ids
429#define cpus_weight_nr(cpumask) cpus_weight(cpumask) 34#else
430#define for_each_cpu_mask_nr(cpu, mask) for_each_cpu_mask(cpu, mask) 35#define nr_cpumask_bits NR_CPUS
431 36#endif
432#else /* NR_CPUS > 64 */
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 /* NR_CPUS > 64 */
443#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
444 37
445/* 38/*
446 * The following particular system cpumasks and operations manage 39 * The following particular system cpumasks and operations manage
@@ -487,12 +80,6 @@ extern const struct cpumask *const cpu_online_mask;
487extern const struct cpumask *const cpu_present_mask; 80extern const struct cpumask *const cpu_present_mask;
488extern const struct cpumask *const cpu_active_mask; 81extern const struct cpumask *const cpu_active_mask;
489 82
490/* These strip const, as traditionally they weren't const. */
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 83#if NR_CPUS > 1
497#define num_online_cpus() cpumask_weight(cpu_online_mask) 84#define num_online_cpus() cpumask_weight(cpu_online_mask)
498#define num_possible_cpus() cpumask_weight(cpu_possible_mask) 85#define num_possible_cpus() cpumask_weight(cpu_possible_mask)
@@ -511,35 +98,6 @@ extern const struct cpumask *const cpu_active_mask;
511#define cpu_active(cpu) ((cpu) == 0) 98#define cpu_active(cpu) ((cpu) == 0)
512#endif 99#endif
513 100
514#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
515
516/* These are the new versions of the cpumask operators: passed by pointer.
517 * The older versions will be implemented in terms of these, then deleted. */
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 /* NR_CPUS > BITS_PER_LONG */
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 /* NR_CPUS > BITS_PER_LONG */
534
535#ifdef CONFIG_CPUMASK_OFFSTACK
536/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,
537 * not all bits may be allocated. */
538#define nr_cpumask_bits nr_cpu_ids
539#else
540#define nr_cpumask_bits NR_CPUS
541#endif
542
543/* verify cpu argument to cpumask_* operators */ 101/* verify cpu argument to cpumask_* operators */
544static inline unsigned int cpumask_check(unsigned int cpu) 102static inline unsigned int cpumask_check(unsigned int cpu)
545{ 103{
@@ -1100,4 +658,241 @@ void set_cpu_active(unsigned int cpu, bool active);
1100void init_cpu_present(const struct cpumask *src); 658void init_cpu_present(const struct cpumask *src);
1101void init_cpu_possible(const struct cpumask *src); 659void init_cpu_possible(const struct cpumask *src);
1102void init_cpu_online(const struct cpumask *src); 660void init_cpu_online(const struct cpumask *src);
661
662/**
663 * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask *
664 * @bitmap: the bitmap
665 *
666 * There are a few places where cpumask_var_t isn't appropriate and
667 * static cpumasks must be used (eg. very early boot), yet we don't
668 * expose the definition of 'struct cpumask'.
669 *
670 * This does the conversion, and can be used as a constant initializer.
671 */
672#define to_cpumask(bitmap) \
673 ((struct cpumask *)(1 ? (bitmap) \
674 : (void *)sizeof(__check_is_bitmap(bitmap))))
675
676static inline int __check_is_bitmap(const unsigned long *bitmap)
677{
678 return 1;
679}
680
681/*
682 * Special-case data structure for "single bit set only" constant CPU masks.
683 *
684 * We pre-generate all the 64 (or 32) possible bit positions, with enough
685 * padding to the left and the right, and return the constant pointer
686 * appropriately offset.
687 */
688extern const unsigned long
689 cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
690
691static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
692{
693 const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
694 p -= cpu / BITS_PER_LONG;
695 return to_cpumask(p);
696}
697
698#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
699
700#if NR_CPUS <= BITS_PER_LONG
701#define CPU_BITS_ALL \
702{ \
703 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
704}
705
706#else /* NR_CPUS > BITS_PER_LONG */
707
708#define CPU_BITS_ALL \
709{ \
710 [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
711 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
712}
713#endif /* NR_CPUS > BITS_PER_LONG */
714
715/*
716 *
717 * From here down, all obsolete. Use cpumask_ variants!
718 *
719 */
720#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
721/* These strip const, as traditionally they weren't const. */
722#define cpu_possible_map (*(cpumask_t *)cpu_possible_mask)
723#define cpu_online_map (*(cpumask_t *)cpu_online_mask)
724#define cpu_present_map (*(cpumask_t *)cpu_present_mask)
725#define cpu_active_map (*(cpumask_t *)cpu_active_mask)
726
727#define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
728
729#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
730
731#if NR_CPUS <= BITS_PER_LONG
732
733#define CPU_MASK_ALL \
734(cpumask_t) { { \
735 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
736} }
737
738#else
739
740#define CPU_MASK_ALL \
741(cpumask_t) { { \
742 [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \
743 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
744} }
745
746#endif
747
748#define CPU_MASK_NONE \
749(cpumask_t) { { \
750 [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
751} }
752
753#define CPU_MASK_CPU0 \
754(cpumask_t) { { \
755 [0] = 1UL \
756} }
757
758#if NR_CPUS == 1
759#define first_cpu(src) ({ (void)(src); 0; })
760#define next_cpu(n, src) ({ (void)(src); 1; })
761#define any_online_cpu(mask) 0
762#define for_each_cpu_mask(cpu, mask) \
763 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
764#else /* NR_CPUS > 1 */
765int __first_cpu(const cpumask_t *srcp);
766int __next_cpu(int n, const cpumask_t *srcp);
767int __any_online_cpu(const cpumask_t *mask);
768
769#define first_cpu(src) __first_cpu(&(src))
770#define next_cpu(n, src) __next_cpu((n), &(src))
771#define any_online_cpu(mask) __any_online_cpu(&(mask))
772#define for_each_cpu_mask(cpu, mask) \
773 for ((cpu) = -1; \
774 (cpu) = next_cpu((cpu), (mask)), \
775 (cpu) < NR_CPUS; )
776#endif /* SMP */
777
778#if NR_CPUS <= 64
779
780#define for_each_cpu_mask_nr(cpu, mask) for_each_cpu_mask(cpu, mask)
781
782#else /* NR_CPUS > 64 */
783
784int __next_cpu_nr(int n, const cpumask_t *srcp);
785#define for_each_cpu_mask_nr(cpu, mask) \
786 for ((cpu) = -1; \
787 (cpu) = __next_cpu_nr((cpu), &(mask)), \
788 (cpu) < nr_cpu_ids; )
789
790#endif /* NR_CPUS > 64 */
791
792#define cpus_addr(src) ((src).bits)
793
794#define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
795static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
796{
797 set_bit(cpu, dstp->bits);
798}
799
800#define cpu_clear(cpu, dst) __cpu_clear((cpu), &(dst))
801static inline void __cpu_clear(int cpu, volatile cpumask_t *dstp)
802{
803 clear_bit(cpu, dstp->bits);
804}
805
806#define cpus_setall(dst) __cpus_setall(&(dst), NR_CPUS)
807static inline void __cpus_setall(cpumask_t *dstp, int nbits)
808{
809 bitmap_fill(dstp->bits, nbits);
810}
811
812#define cpus_clear(dst) __cpus_clear(&(dst), NR_CPUS)
813static inline void __cpus_clear(cpumask_t *dstp, int nbits)
814{
815 bitmap_zero(dstp->bits, nbits);
816}
817
818/* No static inline type checking - see Subtlety (1) above. */
819#define cpu_isset(cpu, cpumask) test_bit((cpu), (cpumask).bits)
820
821#define cpu_test_and_set(cpu, cpumask) __cpu_test_and_set((cpu), &(cpumask))
822static inline int __cpu_test_and_set(int cpu, cpumask_t *addr)
823{
824 return test_and_set_bit(cpu, addr->bits);
825}
826
827#define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)
828static inline int __cpus_and(cpumask_t *dstp, const cpumask_t *src1p,
829 const cpumask_t *src2p, int nbits)
830{
831 return bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
832}
833
834#define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)
835static inline void __cpus_or(cpumask_t *dstp, const cpumask_t *src1p,
836 const cpumask_t *src2p, int nbits)
837{
838 bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
839}
840
841#define cpus_xor(dst, src1, src2) __cpus_xor(&(dst), &(src1), &(src2), NR_CPUS)
842static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p,
843 const cpumask_t *src2p, int nbits)
844{
845 bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
846}
847
848#define cpus_andnot(dst, src1, src2) \
849 __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)
850static inline int __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p,
851 const cpumask_t *src2p, int nbits)
852{
853 return bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
854}
855
856#define cpus_equal(src1, src2) __cpus_equal(&(src1), &(src2), NR_CPUS)
857static inline int __cpus_equal(const cpumask_t *src1p,
858 const cpumask_t *src2p, int nbits)
859{
860 return bitmap_equal(src1p->bits, src2p->bits, nbits);
861}
862
863#define cpus_intersects(src1, src2) __cpus_intersects(&(src1), &(src2), NR_CPUS)
864static inline int __cpus_intersects(const cpumask_t *src1p,
865 const cpumask_t *src2p, int nbits)
866{
867 return bitmap_intersects(src1p->bits, src2p->bits, nbits);
868}
869
870#define cpus_subset(src1, src2) __cpus_subset(&(src1), &(src2), NR_CPUS)
871static inline int __cpus_subset(const cpumask_t *src1p,
872 const cpumask_t *src2p, int nbits)
873{
874 return bitmap_subset(src1p->bits, src2p->bits, nbits);
875}
876
877#define cpus_empty(src) __cpus_empty(&(src), NR_CPUS)
878static inline int __cpus_empty(const cpumask_t *srcp, int nbits)
879{
880 return bitmap_empty(srcp->bits, nbits);
881}
882
883#define cpus_weight(cpumask) __cpus_weight(&(cpumask), NR_CPUS)
884static inline int __cpus_weight(const cpumask_t *srcp, int nbits)
885{
886 return bitmap_weight(srcp->bits, nbits);
887}
888
889#define cpus_shift_left(dst, src, n) \
890 __cpus_shift_left(&(dst), &(src), (n), NR_CPUS)
891static inline void __cpus_shift_left(cpumask_t *dstp,
892 const cpumask_t *srcp, int n, int nbits)
893{
894 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
895}
896#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
897
1103#endif /* __LINUX_CPUMASK_H */ 898#endif /* __LINUX_CPUMASK_H */
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 8e9e151f811e..b78cf8194957 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -84,7 +84,6 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
84 * struct irqaction - per interrupt action descriptor 84 * struct irqaction - per interrupt action descriptor
85 * @handler: interrupt handler function 85 * @handler: interrupt handler function
86 * @flags: flags (see IRQF_* above) 86 * @flags: flags (see IRQF_* above)
87 * @mask: no comment as it is useless and about to be removed
88 * @name: name of the device 87 * @name: name of the device
89 * @dev_id: cookie to identify the device 88 * @dev_id: cookie to identify the device
90 * @next: pointer to the next irqaction for shared interrupts 89 * @next: pointer to the next irqaction for shared interrupts
@@ -97,7 +96,6 @@ typedef irqreturn_t (*irq_handler_t)(int, void *);
97struct irqaction { 96struct irqaction {
98 irq_handler_t handler; 97 irq_handler_t handler;
99 unsigned long flags; 98 unsigned long flags;
100 cpumask_t mask;
101 const char *name; 99 const char *name;
102 void *dev_id; 100 void *dev_id;
103 struct irqaction *next; 101 struct irqaction *next;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index cbf2a3b46280..848d1f20086e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1817,10 +1817,13 @@ static inline int set_cpus_allowed_ptr(struct task_struct *p,
1817 return 0; 1817 return 0;
1818} 1818}
1819#endif 1819#endif
1820
1821#ifndef CONFIG_CPUMASK_OFFSTACK
1820static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask) 1822static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
1821{ 1823{
1822 return set_cpus_allowed_ptr(p, &new_mask); 1824 return set_cpus_allowed_ptr(p, &new_mask);
1823} 1825}
1826#endif
1824 1827
1825/* 1828/*
1826 * Architectures can set this to 1 if they have specified 1829 * Architectures can set this to 1 if they have specified
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 9e3d8af09207..39c64bae776d 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -73,15 +73,6 @@ int smp_call_function(void(*func)(void *info), void *info, int wait);
73void smp_call_function_many(const struct cpumask *mask, 73void smp_call_function_many(const struct cpumask *mask,
74 void (*func)(void *info), void *info, bool wait); 74 void (*func)(void *info), void *info, bool wait);
75 75
76/* Deprecated: Use smp_call_function_many which takes a pointer to the mask. */
77static inline int
78smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
79 int wait)
80{
81 smp_call_function_many(&mask, func, info, wait);
82 return 0;
83}
84
85void __smp_call_function_single(int cpuid, struct call_single_data *data, 76void __smp_call_function_single(int cpuid, struct call_single_data *data,
86 int wait); 77 int wait);
87 78
@@ -144,8 +135,6 @@ static inline int up_smp_call_function(void (*func)(void *), void *info)
144static inline void smp_send_reschedule(int cpu) { } 135static inline void smp_send_reschedule(int cpu) { }
145#define num_booting_cpus() 1 136#define num_booting_cpus() 1
146#define smp_prepare_boot_cpu() do {} while (0) 137#define smp_prepare_boot_cpu() do {} while (0)
147#define smp_call_function_mask(mask, func, info, wait) \
148 (up_smp_call_function(func, info))
149#define smp_call_function_many(mask, func, info, wait) \ 138#define smp_call_function_many(mask, func, info, wait) \
150 (up_smp_call_function(func, info)) 139 (up_smp_call_function(func, info))
151static inline void init_call_single_data(void) 140static inline void init_call_single_data(void)
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 809b26c07090..fc0bf3edeb67 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -211,12 +211,6 @@ int arch_update_cpu_topology(void);
211#ifndef topology_core_id 211#ifndef topology_core_id
212#define topology_core_id(cpu) ((void)(cpu), 0) 212#define topology_core_id(cpu) ((void)(cpu), 0)
213#endif 213#endif
214#ifndef topology_thread_siblings
215#define topology_thread_siblings(cpu) cpumask_of_cpu(cpu)
216#endif
217#ifndef topology_core_siblings
218#define topology_core_siblings(cpu) cpumask_of_cpu(cpu)
219#endif
220#ifndef topology_thread_cpumask 214#ifndef topology_thread_cpumask
221#define topology_thread_cpumask(cpu) cpumask_of(cpu) 215#define topology_thread_cpumask(cpu) cpumask_of(cpu)
222#endif 216#endif