tools: rename bitmap_alloc() to bitmap_zalloc()
[linux-2.6-microblaze.git] / tools / perf / util / mmap.c
index 3b664fa..512dc8b 100644 (file)
@@ -98,20 +98,29 @@ static int perf_mmap__aio_bind(struct mmap *map, int idx, int cpu, int affinity)
 {
        void *data;
        size_t mmap_len;
-       unsigned long node_mask;
+       unsigned long *node_mask;
+       unsigned long node_index;
+       int err = 0;
 
        if (affinity != PERF_AFFINITY_SYS && cpu__max_node() > 1) {
                data = map->aio.data[idx];
                mmap_len = mmap__mmap_len(map);
-               node_mask = 1UL << cpu__get_node(cpu);
-               if (mbind(data, mmap_len, MPOL_BIND, &node_mask, 1, 0)) {
-                       pr_err("Failed to bind [%p-%p] AIO buffer to node %d: error %m\n",
-                               data, data + mmap_len, cpu__get_node(cpu));
+               node_index = cpu__get_node(cpu);
+               node_mask = bitmap_zalloc(node_index + 1);
+               if (!node_mask) {
+                       pr_err("Failed to allocate node mask for mbind: error %m\n");
                        return -1;
                }
+               set_bit(node_index, node_mask);
+               if (mbind(data, mmap_len, MPOL_BIND, node_mask, node_index + 1 + 1, 0)) {
+                       pr_err("Failed to bind [%p-%p] AIO buffer to node %lu: error %m\n",
+                               data, data + mmap_len, node_index);
+                       err = -1;
+               }
+               bitmap_free(node_mask);
        }
 
-       return 0;
+       return err;
 }
 #else /* !HAVE_LIBNUMA_SUPPORT */
 static int perf_mmap__aio_alloc(struct mmap *map, int idx)
@@ -249,7 +258,7 @@ static void build_node_mask(int node, struct mmap_cpu_mask *mask)
 static int perf_mmap__setup_affinity_mask(struct mmap *map, struct mmap_params *mp)
 {
        map->affinity_mask.nbits = cpu__max_cpu();
-       map->affinity_mask.bits = bitmap_alloc(map->affinity_mask.nbits);
+       map->affinity_mask.bits = bitmap_zalloc(map->affinity_mask.nbits);
        if (!map->affinity_mask.bits)
                return -1;