Update to 3.4-final.
[linux-flexiantxendom0-3.2.10.git] / lib / cpumask.c
index 8e1496c..402a54a 100644 (file)
@@ -1,7 +1,8 @@
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
 #include <linux/cpumask.h>
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/bootmem.h>
 
 int __first_cpu(const cpumask_t *srcp)
@@ -25,18 +26,6 @@ int __next_cpu_nr(int n, const cpumask_t *srcp)
 EXPORT_SYMBOL(__next_cpu_nr);
 #endif
 
-int __any_online_cpu(const cpumask_t *mask)
-{
-       int cpu;
-
-       for_each_cpu_mask(cpu, *mask) {
-               if (cpu_online(cpu))
-                       break;
-       }
-       return cpu;
-}
-EXPORT_SYMBOL(__any_online_cpu);
-
 /**
  * cpumask_next_and - get the next cpu in *src1p & *src2p
  * @n: the cpu prior to the place to search (ie. return will be > @n)
@@ -92,25 +81,32 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
  */
 bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
 {
-       if (likely(slab_is_available()))
-               *mask = kmalloc_node(cpumask_size(), flags, node);
-       else {
-#ifdef CONFIG_DEBUG_PER_CPU_MAPS
-               printk(KERN_ERR
-                       "=> alloc_cpumask_var: kmalloc not available!\n");
-#endif
-               *mask = NULL;
-       }
+       *mask = kmalloc_node(cpumask_size(), flags, node);
+
 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
        if (!*mask) {
                printk(KERN_ERR "=> alloc_cpumask_var: failed!\n");
                dump_stack();
        }
 #endif
+       /* FIXME: Bandaid to save us from old primitives which go to NR_CPUS. */
+       if (*mask) {
+               unsigned char *ptr = (unsigned char *)cpumask_bits(*mask);
+               unsigned int tail;
+               tail = BITS_TO_LONGS(NR_CPUS - nr_cpumask_bits) * sizeof(long);
+               memset(ptr + cpumask_size() - tail, 0, tail);
+       }
+
        return *mask != NULL;
 }
 EXPORT_SYMBOL(alloc_cpumask_var_node);
 
+bool zalloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
+{
+       return alloc_cpumask_var_node(mask, flags | __GFP_ZERO, node);
+}
+EXPORT_SYMBOL(zalloc_cpumask_var_node);
+
 /**
  * alloc_cpumask_var - allocate a struct cpumask
  * @mask: pointer to cpumask_var_t where the cpumask is returned
@@ -123,10 +119,16 @@ EXPORT_SYMBOL(alloc_cpumask_var_node);
  */
 bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
 {
-       return alloc_cpumask_var_node(mask, flags, numa_node_id());
+       return alloc_cpumask_var_node(mask, flags, NUMA_NO_NODE);
 }
 EXPORT_SYMBOL(alloc_cpumask_var);
 
+bool zalloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
+{
+       return alloc_cpumask_var(mask, flags | __GFP_ZERO);
+}
+EXPORT_SYMBOL(zalloc_cpumask_var);
+
 /**
  * alloc_bootmem_cpumask_var - allocate a struct cpumask from the bootmem arena.
  * @mask: pointer to cpumask_var_t where the cpumask is returned