libperf: Add cpus to struct perf_evsel
authorJiri Olsa <jolsa@kernel.org>
Sun, 21 Jul 2019 11:24:37 +0000 (13:24 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 29 Jul 2019 21:34:45 +0000 (18:34 -0300)
Mov the 'cpus' field from tools/perf's evsel to libperf's perf_evsel.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-51-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-record.c
tools/perf/builtin-script.c
tools/perf/lib/include/internal/evsel.h
tools/perf/util/evlist.c
tools/perf/util/evsel.c
tools/perf/util/evsel.h
tools/perf/util/parse-events.c
tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/util/stat-display.c

index b7d2c27c416449c981c4b686202bfe2993bb2b3b..090aaa2cf4b34b821c974086e22464ce0801a0e5 100644 (file)
@@ -739,7 +739,7 @@ static int record__open(struct record *rec)
 
        evlist__for_each_entry(evlist, pos) {
 try_again:
-               if (evsel__open(pos, pos->cpus, pos->threads) < 0) {
+               if (evsel__open(pos, pos->core.cpus, pos->threads) < 0) {
                        if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
                                if (verbose > 0)
                                        ui__warning("%s\n", msg);
index 69133b35bbc15792ed86ebe80cdc8d182d59f8a1..35f07dde5ad4af8b972d870593c0ee6aaa695c56 100644 (file)
@@ -1920,7 +1920,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp)
                        counts = perf_counts(counter->counts, cpu, thread);
 
                        printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
-                               counter->cpus->map[cpu],
+                               counter->core.cpus->map[cpu],
                                thread_map__pid(counter->threads, thread),
                                counts->val,
                                counts->ena,
index c2e0bd104c9496763463c7bba0085f97b8f8afe8..b2c76e1a62449454a789b55cc9cdfd4ebcba501d 100644 (file)
@@ -5,9 +5,12 @@
 #include <linux/types.h>
 #include <linux/perf_event.h>
 
+struct perf_cpu_map;
+
 struct perf_evsel {
-       struct list_head        node;
-       struct perf_event_attr  attr;
+       struct list_head         node;
+       struct perf_event_attr   attr;
+       struct perf_cpu_map     *cpus;
 };
 
 #endif /* __LIBPERF_INTERNAL_EVSEL_H */
index 67c67e9a38cd6ff2c0e7e645a8612c8227216800..713968130d1d2eed72772b7f9e7efaef9ae912a4 100644 (file)
@@ -160,11 +160,11 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,
         * keep it, if there's no target cpu list defined.
         */
        if (!evsel->own_cpus || evlist->has_user_cpus) {
-               perf_cpu_map__put(evsel->cpus);
-               evsel->cpus = perf_cpu_map__get(evlist->cpus);
-       } else if (evsel->cpus != evsel->own_cpus) {
-               perf_cpu_map__put(evsel->cpus);
-               evsel->cpus = perf_cpu_map__get(evsel->own_cpus);
+               perf_cpu_map__put(evsel->core.cpus);
+               evsel->core.cpus = perf_cpu_map__get(evlist->cpus);
+       } else if (evsel->core.cpus != evsel->own_cpus) {
+               perf_cpu_map__put(evsel->core.cpus);
+               evsel->core.cpus = perf_cpu_map__get(evsel->own_cpus);
        }
 
        perf_thread_map__put(evsel->threads);
@@ -786,7 +786,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx,
                if (evsel->system_wide && thread)
                        continue;
 
-               cpu = cpu_map__idx(evsel->cpus, evlist_cpu);
+               cpu = cpu_map__idx(evsel->core.cpus, evlist_cpu);
                if (cpu == -1)
                        continue;
 
@@ -1407,7 +1407,7 @@ int evlist__open(struct evlist *evlist)
        perf_evlist__update_id_pos(evlist);
 
        evlist__for_each_entry(evlist, evsel) {
-               err = evsel__open(evsel, evsel->cpus, evsel->threads);
+               err = evsel__open(evsel, evsel->core.cpus, evsel->threads);
                if (err < 0)
                        goto out_err;
        }
index 089582e644d783bc4539c7a31f7ff722ac313eda..651f66ee902ef9539f90ca089264c3a12f6ac1c1 100644 (file)
@@ -1325,7 +1325,7 @@ void perf_evsel__exit(struct evsel *evsel)
        perf_evsel__free_id(evsel);
        perf_evsel__free_config_terms(evsel);
        cgroup__put(evsel->cgrp);
-       perf_cpu_map__put(evsel->cpus);
+       perf_cpu_map__put(evsel->core.cpus);
        perf_cpu_map__put(evsel->own_cpus);
        perf_thread_map__put(evsel->threads);
        zfree(&evsel->group_name);
@@ -3064,7 +3064,7 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)
 
 int perf_evsel__store_ids(struct evsel *evsel, struct evlist *evlist)
 {
-       struct perf_cpu_map *cpus = evsel->cpus;
+       struct perf_cpu_map *cpus = evsel->core.cpus;
        struct perf_thread_map *threads = evsel->threads;
 
        if (perf_evsel__alloc_id(evsel, cpus->nr, threads->nr))
index 43f66158de3b69d18126afbecaad9b890247a6ee..8ece5edf65acce6854d2daadb48c783844c3fd33 100644 (file)
@@ -123,7 +123,6 @@ struct evsel {
        u64                     db_id;
        struct cgroup           *cgrp;
        void                    *handler;
-       struct perf_cpu_map     *cpus;
        struct perf_cpu_map     *own_cpus;
        struct perf_thread_map *threads;
        unsigned int            sample_size;
@@ -198,7 +197,7 @@ struct record_opts;
 
 static inline struct perf_cpu_map *evsel__cpus(struct evsel *evsel)
 {
-       return evsel->cpus;
+       return evsel->core.cpus;
 }
 
 static inline int perf_evsel__nr_cpus(struct evsel *evsel)
index db2460d6b62585a2ca5159f562421eeb27b59eb7..a27771eca9c2adc123c882dabc65b7d1ab551486 100644 (file)
@@ -333,7 +333,7 @@ __add_event(struct list_head *list, int *idx,
                return NULL;
 
        (*idx)++;
-       evsel->cpus        = perf_cpu_map__get(cpus);
+       evsel->core.cpus   = perf_cpu_map__get(cpus);
        evsel->own_cpus    = perf_cpu_map__get(cpus);
        evsel->system_wide = pmu ? pmu->is_uncore : false;
        evsel->auto_merge_stats = auto_merge_stats;
index 78b40c1d688e8c5fdcf96cd25446151a4089dea2..c5f520e0885b347eb9f9e30ca2ad1bda7165aba5 100644 (file)
@@ -1393,7 +1393,7 @@ static void python_process_stat(struct perf_stat_config *config,
                                struct evsel *counter, u64 tstamp)
 {
        struct perf_thread_map *threads = counter->threads;
-       struct perf_cpu_map *cpus = counter->cpus;
+       struct perf_cpu_map *cpus = counter->core.cpus;
        int cpu, thread;
 
        if (config->aggr_mode == AGGR_GLOBAL) {
index 99bda99a1b2d66374f5a3da300b8b9ebc7c311b8..e84f8063c2dbec87fea8504e13d5f212c8cf27f9 100644 (file)
@@ -745,7 +745,7 @@ static void print_aggr_thread(struct perf_stat_config *config,
 {
        FILE *output = config->output;
        int nthreads = thread_map__nr(counter->threads);
-       int ncpus = cpu_map__nr(counter->cpus);
+       int ncpus = cpu_map__nr(counter->core.cpus);
        int thread, sorted_threads, id;
        struct perf_aggr_thread_value *buf;