Re: [PATCH v1 2/3] perf record: apply affinity masks when reading mmap buffers

From: Alexey Budankov
Date: Thu Dec 13 2018 - 01:26:52 EST


Hi,
On 12.12.2018 15:15, Jiri Olsa wrote:
> On Wed, Dec 12, 2018 at 10:40:22AM +0300, Alexey Budankov wrote:
>
> SNIP
>
>> int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int cpu)
>> {
>> + int c, nr_cpus, node;
>> /*
>> * The last one will be done at perf_mmap__consume(), so that we
>> * make sure we don't prevent tools from consuming every last event in
>> @@ -344,6 +369,17 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int c
>> map->cpu = cpu;
>>
>> CPU_ZERO(&map->affinity_mask);
>> + if (mp->affinity == PERF_AFFINITY_NODE && cpu__max_node() > 1) {
>> + nr_cpus = cpu_map__nr(mp->cpu_map);
>> + node = cpu__get_node(map->cpu);
>> + for (c = 0; c < nr_cpus; c++) {
>> + if (cpu__get_node(c) == node) {
>> + CPU_SET(c, &map->affinity_mask);
>> + }
>> + }
>> + } else if (mp->affinity == PERF_AFFINITY_CPU) {
>> + CPU_SET(map->cpu, &map->affinity_mask);
>> + }
>
> won't both of this end up in same mask?

For tested dual socket 44 core broadwell:

node 0 node 1
cpu mask 0-21,44-65 22-43,66-87

For affinity=node map->affinity_mask is either [0-21,44-65] or [22-43,66-87].
For affinity=cpu map->affinity_mask is [0] or [1] or [2] and so on.

Without affinity option set map->affinity_mask and record->affinity_mask are [].

Thanks,
Alexey

>
> jirka
>