Re: [PATCH v3 3/3] perf record: adapt affinity to machines with #CPUs > 1K
From: Alexey Budankov
Date: Fri Nov 29 2019 - 10:49:31 EST
On 29.11.2019 16:07, Jiri Olsa wrote:
> On Fri, Nov 29, 2019 at 01:05:26PM +0300, Alexey Budankov wrote:
>
> SNIP
>
>> # undef REASON
>> #endif
>>
>> - CPU_ZERO(&rec->affinity_mask);
>> rec->opts.affinity = PERF_AFFINITY_SYS;
>>
>> rec->evlist = evlist__new();
>> @@ -2499,6 +2504,14 @@ int cmd_record(int argc, const char **argv)
>>
>> symbol__init(NULL);
>>
>> + rec->affinity_mask.nbits = cpu__max_cpu();
>> + rec->affinity_mask.bits = bitmap_alloc(rec->affinity_mask.nbits);
>> + if (!rec->affinity_mask.bits) {
>> + pr_err("Failed to allocate thread mask for %ld cpus\n", rec->affinity_mask.nbits);
>> + return -ENOMEM;
>> + }
>> + pr_debug2("thread mask[%ld]: empty\n", rec->affinity_mask.nbits);
>
> above can be done only for (rec->opts.affinity != PERF_AFFINITY_SYS)
Indeed. Corrected in v4.
>
>
>> +
>> err = record__auxtrace_init(rec);
>> if (err)
>> goto out;
>> @@ -2613,6 +2626,8 @@ int cmd_record(int argc, const char **argv)
>>
>> err = __cmd_record(&record, argc, argv);
>> out:
>> + if (rec->affinity_mask.bits)
>> + bitmap_free(rec->affinity_mask.bits);
>> evlist__delete(rec->evlist);
>> symbol__exit();
>> auxtrace_record__free(rec->itr);
>> diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
>> index 30ff7aef06f2..615d05870849 100644
>> --- a/tools/perf/util/mmap.c
>> +++ b/tools/perf/util/mmap.c
>> @@ -219,6 +219,9 @@ static void perf_mmap__aio_munmap(struct mmap *map __maybe_unused)
>>
>> void mmap__munmap(struct mmap *map)
>> {
>> + if (map->affinity_mask.bits)
>> + bitmap_free(map->affinity_mask.bits);
>
> you don't need to check map->affinity_mask.bits, it's checked in free
Makes sense. Corrected in v4.
>
> jirka
Thanks,
Alexey