[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150615193418.GG5845@kernel.org>
Date: Mon, 15 Jun 2015 16:34:18 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Jiri Olsa <jolsa@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Andi Kleen <ak@...ux.intel.com>,
David Ahern <dsahern@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 08/30] perf tools: Propagate cpu maps through the evlist
Em Sun, Jun 14, 2015 at 10:19:23AM +0200, Jiri Olsa escreveu:
> Propagate evlist's cpu_map object through all the evsel objects,
> while keeping already configured evsel->cpus.
>
> It'll be handy to access evsel's cpus directly
> in following patches.
>
> Link: http://lkml.kernel.org/n/tip-myadl53clbkjvzeqolwp95w0@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
> tools/perf/util/evlist.c | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index f7d80ca58136..c0d3058c1868 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -1085,6 +1085,28 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
> return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false);
> }
>
> +static int propagate_maps(struct perf_evlist *evlist, struct target *target)
Please rename this to perf_evlist__set_maps()
> +{
> + struct perf_evsel *evsel;
> + evlist__for_each(evlist, evsel) {
> + /*
> + * We already have cpus for evsel (via PMU sysfs) so
If we already...
> + * keep it, if there's no target cpu list defined.
^ The comma here confused me
> + */
> + if (evsel->cpus && target->cpu_list)
> + cpu_map__put(evsel->cpus);
If you drop the reference, and then will test it... use a
cpu_map__zput(&evsel->cpus), so that after the put you don't access
something you don't hold a reference for anymore...
But the logic is still confusing! Can you try to rewrite it in a more
clear way?
> + if (!evsel->cpus || target->cpu_list)
> + evsel->cpus = cpu_map__get(evlist->cpus);
Something like:
if (evsel->cpus) {
something
} else {
something else
}
> +
> + if (!evsel->cpus)
> + return -ENOMEM;
Where was that we tried to allocate memory in this operation?
> + }
> +
> + return 0;
> +}
> +
> int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
> {
> evlist->threads = thread_map__new_str(target->pid, target->tid,
> @@ -1101,7 +1123,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
> if (evlist->cpus == NULL)
> goto out_delete_threads;
>
> - return 0;
> + return propagate_maps(evlist, target);
>
> out_delete_threads:
> thread_map__put(evlist->threads);
> --
> 1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists