perf record: Fix binding of AIO user space buffers to nodes
Correct maxnode parameter value passed to mbind() syscall to be the
amount of node mask bits to analyze plus 1. Dynamically allocate node
mask memory depending on the index of node of cpu being profiled.
Fixes: c44a8b44ca
("perf record: Bind the AIO user space buffers to nodes")
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/c7ea8ffe-1357-bf9e-3a89-1da1d8e9b75b@linux.intel.com
[ Remove leftover nr_bits + 1 comment in mbind() call ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
67439d555f
commit
44d462acc0
|
@ -98,20 +98,29 @@ static int perf_mmap__aio_bind(struct mmap *map, int idx, int cpu, int affinity)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
size_t mmap_len;
|
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) {
|
if (affinity != PERF_AFFINITY_SYS && cpu__max_node() > 1) {
|
||||||
data = map->aio.data[idx];
|
data = map->aio.data[idx];
|
||||||
mmap_len = mmap__mmap_len(map);
|
mmap_len = mmap__mmap_len(map);
|
||||||
node_mask = 1UL << cpu__get_node(cpu);
|
node_index = cpu__get_node(cpu);
|
||||||
if (mbind(data, mmap_len, MPOL_BIND, &node_mask, 1, 0)) {
|
node_mask = bitmap_alloc(node_index + 1);
|
||||||
pr_err("Failed to bind [%p-%p] AIO buffer to node %d: error %m\n",
|
if (!node_mask) {
|
||||||
data, data + mmap_len, cpu__get_node(cpu));
|
pr_err("Failed to allocate node mask for mbind: error %m\n");
|
||||||
return -1;
|
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 */
|
#else /* !HAVE_LIBNUMA_SUPPORT */
|
||||||
static int perf_mmap__aio_alloc(struct mmap *map, int idx)
|
static int perf_mmap__aio_alloc(struct mmap *map, int idx)
|
||||||
|
|
Loading…
Reference in New Issue