perf evsel: Add own_cpus member
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 8 Sep 2015 07:58:55 +0000 (10:58 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 15 Sep 2015 13:41:13 +0000 (10:41 -0300)
perf_evlist__propagate_maps() cannot easily tell if an evsel has its own
cpu map.  To make that simpler, keep a copy of the PMU cpu map and
adjust the propagation logic accordingly.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Link: http://lkml.kernel.org/r/1441699142-18905-8-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h
tools/perf/util/parse-events.c

index 79056c6ae507245ba14122a9cdcdd20eafc2aebf..5bd3b49452c6248a821fe63c9796584bd4fd6927 100644 (file)
@@ -1111,9 +1111,12 @@ static void perf_evlist__propagate_maps(struct perf_evlist *evlist)
                 * We already have cpus for evsel (via PMU sysfs) so
                 * keep it, if there's no target cpu list defined.
                 */
-               if (!evsel->cpus || evlist->has_user_cpus) {
+               if (!evsel->own_cpus || evlist->has_user_cpus) {
                        cpu_map__put(evsel->cpus);
                        evsel->cpus = cpu_map__get(evlist->cpus);
+               } else if (evsel->cpus != evsel->own_cpus) {
+                       cpu_map__put(evsel->cpus);
+                       evsel->cpus = cpu_map__get(evsel->own_cpus);
                }
 
                thread_map__put(evsel->threads);
index c53f79123b37f4ab506f3a914263d59c3122cfb6..5410483d52198c5909ec5a502c61567c5119c8ef 100644 (file)
@@ -1033,6 +1033,7 @@ void perf_evsel__exit(struct perf_evsel *evsel)
        perf_evsel__free_config_terms(evsel);
        close_cgroup(evsel->cgrp);
        cpu_map__put(evsel->cpus);
+       cpu_map__put(evsel->own_cpus);
        thread_map__put(evsel->threads);
        zfree(&evsel->group_name);
        zfree(&evsel->name);
index 298e6bbca200bd4740bddc4e6bb1fce7414d5bf4..ef8925f7211a4a311c927e6919d83817745eb1cf 100644 (file)
@@ -98,6 +98,7 @@ struct perf_evsel {
        struct cgroup_sel       *cgrp;
        void                    *handler;
        struct cpu_map          *cpus;
+       struct cpu_map          *own_cpus;
        struct thread_map       *threads;
        unsigned int            sample_size;
        int                     id_pos;
index 7e8ae21906e2a87a02d7043b80917ccc6f8fbe66..21ed6ee63da9747d1215ac638f936357c8df2e8c 100644 (file)
@@ -287,8 +287,8 @@ __add_event(struct list_head *list, int *idx,
        if (!evsel)
                return NULL;
 
-       if (cpus)
-               evsel->cpus = cpu_map__get(cpus);
+       evsel->cpus     = cpu_map__get(cpus);
+       evsel->own_cpus = cpu_map__get(cpus);
 
        if (name)
                evsel->name = strdup(name);