aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2008-07-18 21:11:33 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-20 04:21:12 -0400
commit80422d3431cc990b967da129f9eb8e3e9989f841 (patch)
tree4c8424e7c22433caa39192e6273b7859545f7be1
parentb38868aabeeb9c0c76a41ac5fa98c24bf0096f2a (diff)
cpumask: Provide a generic set of CPUMASK_ALLOC macros, FIXUP
* Rename CPUMASK_VAR --> CPUMASK_PTR (and simplify) * Fix a semantic error in CPUMASK_ALLOC * Add a bit of commentry to cpumask.h Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--include/linux/cpumask.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 72f9c32c12b0..30d59d1d0626 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -75,16 +75,36 @@
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 * CPUMASK_ALLOC kmalloc's a structure that is a composite of many cpumask_t
79 * variables, and CPUMASK_PTR provides pointers to each field.
80 *
81 * The structure should be defined something like this:
82 * struct my_cpumasks {
83 * cpumask_t mask1;
84 * cpumask_t mask2;
85 * };
86 *
87 * Usage is then:
88 * CPUMASK_ALLOC(my_cpumasks);
89 * CPUMASK_PTR(mask1, my_cpumasks);
90 * CPUMASK_PTR(mask2, my_cpumasks);
91 *
92 * --- DO NOT reference cpumask_t pointers until this check ---
93 * if (my_cpumasks == NULL)
94 * "kmalloc failed"...
95 *
96 * References are now pointers to the cpumask_t variables (*mask1, ...)
97 *
78 *if NR_CPUS > BITS_PER_LONG 98 *if NR_CPUS > BITS_PER_LONG
79 * CPUMASK_ALLOC(m) Declares and allocates struct m *m = 99 * CPUMASK_ALLOC(m) Declares and allocates struct m *m =
80 * (struct m *)kmalloc(sizeof(*m), ...) 100 * kmalloc(sizeof(*m), GFP_KERNEL)
81 * CPUMASK_FREE(m) Macro for kfree(v) 101 * CPUMASK_FREE(m) Macro for kfree(m)
82 *else 102 *else
83 * CPUMASK_ALLOC(m) Declares struct m _m, *m = &_m 103 * CPUMASK_ALLOC(m) Declares struct m _m, *m = &_m
84 * CPUMASK_FREE(m) Nop 104 * CPUMASK_FREE(m) Nop
85 *endif 105 *endif
86 * CPUMASK_VAR(v, m) Declares cpumask_t *v = 106 * CPUMASK_PTR(v, m) Declares cpumask_t *v = &(m->v)
87 * m + offset(struct m, v) 107 * ------------------------------------------------------------------------
88 * 108 *
89 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing 109 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
90 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask 110 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask
@@ -326,11 +346,10 @@ extern cpumask_t cpu_mask_all;
326#define CPUMASK_ALLOC(m) struct m *m = kmalloc(sizeof(*m), GFP_KERNEL) 346#define CPUMASK_ALLOC(m) struct m *m = kmalloc(sizeof(*m), GFP_KERNEL)
327#define CPUMASK_FREE(m) kfree(m) 347#define CPUMASK_FREE(m) kfree(m)
328#else 348#else
329#define CPUMASK_ALLOC(m) struct allmasks _m, *m = &_m 349#define CPUMASK_ALLOC(m) struct m _m, *m = &_m
330#define CPUMASK_FREE(m) 350#define CPUMASK_FREE(m)
331#endif 351#endif
332#define CPUMASK_VAR(v, m) cpumask_t *v = (cpumask_t *) \ 352#define CPUMASK_PTR(v, m) cpumask_t *v = &(m->v)
333 ((unsigned long)(m) + offsetof(struct m, v))
334 353
335#define cpumask_scnprintf(buf, len, src) \ 354#define cpumask_scnprintf(buf, len, src) \
336 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS) 355 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS)