perf record: Adapt affinity to machines with #CPUs > 1K
Use struct mmap_cpu_mask type for the tool's thread and mmap data buffers to overcome current 1024 CPUs mask size limitation of cpu_set_t type. Currently glibc's cpu_set_t type has an internal mask size limit of 1024 CPUs. Moving to the 'struct mmap_cpu_mask' type allows overcoming that limit. The tools bitmap API is used to manipulate objects of 'struct mmap_cpu_mask' type. Committer notes: To print the 'nbits' struct member we must use %zd, since it is a size_t, this fixes the build in some toolchains/arches. Reported-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/96d7e2ff-ce8b-c1e0-d52c-aa59ea96f0ea@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
9c080c0279
commit
8384a2600c
@@ -219,6 +219,8 @@ static void perf_mmap__aio_munmap(struct mmap *map __maybe_unused)
|
||||
|
||||
void mmap__munmap(struct mmap *map)
|
||||
{
|
||||
bitmap_free(map->affinity_mask.bits);
|
||||
|
||||
perf_mmap__aio_munmap(map);
|
||||
if (map->data != NULL) {
|
||||
munmap(map->data, mmap__mmap_len(map));
|
||||
@@ -227,7 +229,7 @@ void mmap__munmap(struct mmap *map)
|
||||
auxtrace_mmap__munmap(&map->auxtrace_mmap);
|
||||
}
|
||||
|
||||
static void build_node_mask(int node, cpu_set_t *mask)
|
||||
static void build_node_mask(int node, struct mmap_cpu_mask *mask)
|
||||
{
|
||||
int c, cpu, nr_cpus;
|
||||
const struct perf_cpu_map *cpu_map = NULL;
|
||||
@@ -240,17 +242,23 @@ static void build_node_mask(int node, cpu_set_t *mask)
|
||||
for (c = 0; c < nr_cpus; c++) {
|
||||
cpu = cpu_map->map[c]; /* map c index to online cpu index */
|
||||
if (cpu__get_node(cpu) == node)
|
||||
CPU_SET(cpu, mask);
|
||||
set_bit(cpu, mask->bits);
|
||||
}
|
||||
}
|
||||
|
||||
static void perf_mmap__setup_affinity_mask(struct mmap *map, struct mmap_params *mp)
|
||||
static int perf_mmap__setup_affinity_mask(struct mmap *map, struct mmap_params *mp)
|
||||
{
|
||||
CPU_ZERO(&map->affinity_mask);
|
||||
map->affinity_mask.nbits = cpu__max_cpu();
|
||||
map->affinity_mask.bits = bitmap_alloc(map->affinity_mask.nbits);
|
||||
if (!map->affinity_mask.bits)
|
||||
return -1;
|
||||
|
||||
if (mp->affinity == PERF_AFFINITY_NODE && cpu__max_node() > 1)
|
||||
build_node_mask(cpu__get_node(map->core.cpu), &map->affinity_mask);
|
||||
else if (mp->affinity == PERF_AFFINITY_CPU)
|
||||
CPU_SET(map->core.cpu, &map->affinity_mask);
|
||||
set_bit(map->core.cpu, map->affinity_mask.bits);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu)
|
||||
@@ -261,7 +269,15 @@ int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu)
|
||||
return -1;
|
||||
}
|
||||
|
||||
perf_mmap__setup_affinity_mask(map, mp);
|
||||
if (mp->affinity != PERF_AFFINITY_SYS &&
|
||||
perf_mmap__setup_affinity_mask(map, mp)) {
|
||||
pr_debug2("failed to alloc mmap affinity mask, error %d\n",
|
||||
errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (verbose == 2)
|
||||
mmap_cpu_mask__scnprintf(&map->affinity_mask, "mmap");
|
||||
|
||||
map->core.flush = mp->flush;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user