Re: [PATCH v11 01/24] perf record: Introduce thread affinity and mmap masks
From: Jiri Olsa
Date: Sun Sep 12 2021 - 16:45:38 EST
On Tue, Aug 17, 2021 at 11:23:04AM +0300, Alexey Bayduraev wrote:
SNIP
> +static int record__init_thread_default_masks(struct record *rec, struct perf_cpu_map *cpus)
> +{
> + int ret;
> +
> + ret = record__alloc_thread_masks(rec, 1, cpu__max_cpu());
> + if (ret)
> + return ret;
> +
> + record__mmap_cpu_mask_init(&rec->thread_masks->maps, cpus);
> +
> + rec->nr_threads = 1;
> +
> + return 0;
> +}
> +
> +static int record__init_thread_masks(struct record *rec)
> +{
> + struct perf_cpu_map *cpus = rec->evlist->core.cpus;
> +
> + return record__init_thread_default_masks(rec, cpus);
> +}
> +
> +static void record__fini_thread_masks(struct record *rec)
> +{
> + record__free_thread_masks(rec, rec->nr_threads);
> +
> + rec->nr_threads = 0;
hum, is this needed?
jirka
> +}
> +
> int cmd_record(int argc, const char **argv)
> {
> int err;
> @@ -2883,6 +3011,12 @@ int cmd_record(int argc, const char **argv)
> goto out;
> }
>
> + err = record__init_thread_masks(rec);
> + if (err) {
> + pr_err("record__init_thread_masks failed, error %d\n", err);
> + goto out;
> + }
> +
> if (rec->opts.nr_cblocks > nr_cblocks_max)
> rec->opts.nr_cblocks = nr_cblocks_max;
> pr_debug("nr_cblocks: %d\n", rec->opts.nr_cblocks);
> @@ -2901,6 +3035,7 @@ int cmd_record(int argc, const char **argv)
> symbol__exit();
> auxtrace_record__free(rec->itr);
> out_opts:
> + record__fini_thread_masks(rec);
> evlist__close_control(rec->opts.ctl_fd, rec->opts.ctl_fd_ack, &rec->opts.ctl_fd_close);
> return err;
> }
> --
> 2.19.0
>