summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2008-10-27 11:03:14 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2008-10-27 11:03:14 +1100
commit8c4e41fd93f59bd7f0ad34d34940b1d2627bdd47 (patch)
treeabf539ddcec68d2960200860b873542b3c17a1f7 /lib
parent293125755a4d6c522bb6a80afb7b297dc24fdfff (diff)
cpumask:cpumask_var_t
We want to move cpumasks off the stack: no local decls, no passing by copy. Linus suggested we use the array-or-pointer trick for on-stack vars; we introduce a new cpumask_var_t for this. Rather than pick an arbitrary limit, I chose a new config option so arch maintainers can decide where their threshold is. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Mike Travis <travis@sgi.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/cpumask.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 080d1219b073..d131e5fed1ae 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -43,3 +43,34 @@ int __any_online_cpu(const cpumask_t *mask)
return cpu;
}
EXPORT_SYMBOL(__any_online_cpu);
+
+/* These are not inline because of header tangles. */
+#ifdef CONFIG_CPUMASK_OFFSTACK
+bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
+{
+ if (likely(slab_is_available()))
+ *mask = kmalloc(cpumask_size(), flags);
+ else {
+#ifdef CONFIG_DEBUG_PER_CPU_MAPS
+ printk(KERN_ERR
+ "=> alloc_cpumask_var: kmalloc not available!\n");
+ dump_stack();
+#endif
+ *mask = NULL;
+ }
+#ifdef CONFIG_DEBUG_PER_CPU_MAPS
+ if (!*mask) {
+ printk(KERN_ERR "=> alloc_cpumask_var: failed!\n");
+ dump_stack();
+ }
+#endif
+ return *mask != NULL;
+}
+EXPORT_SYMBOL(alloc_cpumask_var);
+
+void free_cpumask_var(cpumask_var_t mask)
+{
+ kfree(mask);
+}
+EXPORT_SYMBOL(free_cpumask_var);
+#endif