aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2008-07-15 17:14:36 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-18 16:03:00 -0400
commit77586c2bdad0798cb24e35de5a878e7c6b200574 (patch)
treeba400aecb986671fb70d2fb0c80140ac2fdedfb5 /include
parent4755b9291204982ac908e069674d6e5eb45815b3 (diff)
cpumask: Provide a generic set of CPUMASK_ALLOC macros
* Provide a generic set of CPUMASK_ALLOC macros patterned after the SCHED_CPUMASK_ALLOC macros. This is used where multiple cpumask_t variables are declared on the stack to reduce the amount of stack space required. Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r--include/linux/cpumask.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 2dbd9a287e77..72f9c32c12b0 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -75,6 +75,17 @@
75 * CPU_MASK_NONE Initializer - no bits set 75 * CPU_MASK_NONE Initializer - no bits set
76 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask 76 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
77 * 77 *
78 *if NR_CPUS > BITS_PER_LONG
79 * CPUMASK_ALLOC(m) Declares and allocates struct m *m =
80 * (struct m *)kmalloc(sizeof(*m), ...)
81 * CPUMASK_FREE(m) Macro for kfree(v)
82 *else
83 * CPUMASK_ALLOC(m) Declares struct m _m, *m = &_m
84 * CPUMASK_FREE(m) Nop
85 *endif
86 * CPUMASK_VAR(v, m) Declares cpumask_t *v =
87 * m + offset(struct m, v)
88 *
78 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing 89 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
79 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask 90 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask
80 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing 91 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
@@ -311,6 +322,16 @@ extern cpumask_t cpu_mask_all;
311 322
312#define cpus_addr(src) ((src).bits) 323#define cpus_addr(src) ((src).bits)
313 324
325#if NR_CPUS > BITS_PER_LONG
326#define CPUMASK_ALLOC(m) struct m *m = kmalloc(sizeof(*m), GFP_KERNEL)
327#define CPUMASK_FREE(m) kfree(m)
328#else
329#define CPUMASK_ALLOC(m) struct allmasks _m, *m = &_m
330#define CPUMASK_FREE(m)
331#endif
332#define CPUMASK_VAR(v, m) cpumask_t *v = (cpumask_t *) \
333 ((unsigned long)(m) + offsetof(struct m, v))
334
314#define cpumask_scnprintf(buf, len, src) \ 335#define cpumask_scnprintf(buf, len, src) \
315 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS) 336 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS)
316static inline int __cpumask_scnprintf(char *buf, int len, 337static inline int __cpumask_scnprintf(char *buf, int len,