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

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-53-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/scripting-engines/trace-event-python.c
tools/perf/util/stat-display.c
tools/perf/util/stat.c

index 090aaa2cf4b34b821c974086e22464ce0801a0e5..27ff899bed88eb516f26c970b4639a4a6eeb3c23 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->core.cpus, pos->threads) < 0) {
+               if (evsel__open(pos, pos->core.cpus, pos->core.threads) < 0) {
                        if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
                                if (verbose > 0)
                                        ui__warning("%s\n", msg);
index 35f07dde5ad4af8b972d870593c0ee6aaa695c56..a787c5cb13314e6c2eb13c24c6e82376be45c221 100644 (file)
@@ -1899,7 +1899,7 @@ static struct scripting_ops       *scripting_ops;
 
 static void __process_stat(struct evsel *counter, u64 tstamp)
 {
-       int nthreads = thread_map__nr(counter->threads);
+       int nthreads = thread_map__nr(counter->core.threads);
        int ncpus = perf_evsel__nr_cpus(counter);
        int cpu, thread;
        static int header_printed;
@@ -1921,7 +1921,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp)
 
                        printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
                                counter->core.cpus->map[cpu],
-                               thread_map__pid(counter->threads, thread),
+                               thread_map__pid(counter->core.threads, thread),
                                counts->val,
                                counts->ena,
                                counts->run,
index d15d8ccfa3dc2007a84e993eebd7c187fb059d8f..8340fd883a3d9da651e9f56540a4fdc2afb66dc1 100644 (file)
@@ -6,12 +6,14 @@
 #include <linux/perf_event.h>
 
 struct perf_cpu_map;
+struct perf_thread_map;
 
 struct perf_evsel {
        struct list_head         node;
        struct perf_event_attr   attr;
        struct perf_cpu_map     *cpus;
        struct perf_cpu_map     *own_cpus;
+       struct perf_thread_map  *threads;
 };
 
 #endif /* __LIBPERF_INTERNAL_EVSEL_H */
index d203305ac187827218d1cbb3199e8ae0cac43262..5ce8fc730453575dd2149151bd1bae25c9874363 100644 (file)
@@ -167,8 +167,8 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,
                evsel->core.cpus = perf_cpu_map__get(evsel->core.own_cpus);
        }
 
-       perf_thread_map__put(evsel->threads);
-       evsel->threads = perf_thread_map__get(evlist->threads);
+       perf_thread_map__put(evsel->core.threads);
+       evsel->core.threads = perf_thread_map__get(evlist->threads);
 }
 
 static void perf_evlist__propagate_maps(struct evlist *evlist)
@@ -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->core.cpus, evsel->threads);
+               err = evsel__open(evsel, evsel->core.cpus, evsel->core.threads);
                if (err < 0)
                        goto out_err;
        }
index c5f6ee6d5f3b25be07135991177bbe70add6e03c..f7758ce0dd5c0d5b5a450f4bc07a0cd21d908e15 100644 (file)
@@ -1327,7 +1327,7 @@ void perf_evsel__exit(struct evsel *evsel)
        cgroup__put(evsel->cgrp);
        perf_cpu_map__put(evsel->core.cpus);
        perf_cpu_map__put(evsel->core.own_cpus);
-       perf_thread_map__put(evsel->threads);
+       perf_thread_map__put(evsel->core.threads);
        zfree(&evsel->group_name);
        zfree(&evsel->name);
        perf_evsel__object.fini(evsel);
@@ -3065,7 +3065,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->core.cpus;
-       struct perf_thread_map *threads = evsel->threads;
+       struct perf_thread_map *threads = evsel->core.threads;
 
        if (perf_evsel__alloc_id(evsel, cpus->nr, threads->nr))
                return -ENOMEM;
index 2eff837f10bdba3e46cffa9236a1249e7255ddbf..57b5523b480c63ea891e809066666f4959863942 100644 (file)
@@ -123,7 +123,6 @@ struct evsel {
        u64                     db_id;
        struct cgroup           *cgrp;
        void                    *handler;
-       struct perf_thread_map *threads;
        unsigned int            sample_size;
        int                     id_pos;
        int                     is_pos;
index c5f520e0885b347eb9f9e30ca2ad1bda7165aba5..32c17a72745081c06bc7207c98172f9663d5a587 100644 (file)
@@ -1392,7 +1392,7 @@ process_stat(struct evsel *counter, int cpu, int thread, u64 tstamp,
 static void python_process_stat(struct perf_stat_config *config,
                                struct evsel *counter, u64 tstamp)
 {
-       struct perf_thread_map *threads = counter->threads;
+       struct perf_thread_map *threads = counter->core.threads;
        struct perf_cpu_map *cpus = counter->core.cpus;
        int cpu, thread;
 
index e84f8063c2dbec87fea8504e13d5f212c8cf27f9..7c938135398b463bb1b8d28b6d4ac43ea92a1c7c 100644 (file)
@@ -116,9 +116,9 @@ static void aggr_printout(struct perf_stat_config *config,
        case AGGR_THREAD:
                fprintf(config->output, "%*s-%*d%s",
                        config->csv_output ? 0 : 16,
-                       perf_thread_map__comm(evsel->threads, id),
+                       perf_thread_map__comm(evsel->core.threads, id),
                        config->csv_output ? 0 : -8,
-                       thread_map__pid(evsel->threads, id),
+                       thread_map__pid(evsel->core.threads, id),
                        config->csv_sep);
                break;
        case AGGR_GLOBAL:
@@ -744,7 +744,7 @@ static void print_aggr_thread(struct perf_stat_config *config,
                              struct evsel *counter, char *prefix)
 {
        FILE *output = config->output;
-       int nthreads = thread_map__nr(counter->threads);
+       int nthreads = thread_map__nr(counter->core.threads);
        int ncpus = cpu_map__nr(counter->core.cpus);
        int thread, sorted_threads, id;
        struct perf_aggr_thread_value *buf;
index 632bf72cf7801608f33ded0cadd17893a0415ae6..1e351462ca4932eec30f2e44dcc4511780ce375b 100644 (file)
@@ -158,7 +158,7 @@ static void perf_evsel__free_prev_raw_counts(struct evsel *evsel)
 static int perf_evsel__alloc_stats(struct evsel *evsel, bool alloc_raw)
 {
        int ncpus = perf_evsel__nr_cpus(evsel);
-       int nthreads = thread_map__nr(evsel->threads);
+       int nthreads = thread_map__nr(evsel->core.threads);
 
        if (perf_evsel__alloc_stat_priv(evsel) < 0 ||
            perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
@@ -308,7 +308,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
 static int process_counter_maps(struct perf_stat_config *config,
                                struct evsel *counter)
 {
-       int nthreads = thread_map__nr(counter->threads);
+       int nthreads = thread_map__nr(counter->core.threads);
        int ncpus = perf_evsel__nr_cpus(counter);
        int cpu, thread;
 
@@ -485,7 +485,7 @@ int create_perf_stat_counter(struct evsel *evsel,
        if (target__has_cpu(target) && !target__has_per_thread(target))
                return perf_evsel__open_per_cpu(evsel, evsel__cpus(evsel));
 
-       return perf_evsel__open_per_thread(evsel, evsel->threads);
+       return perf_evsel__open_per_thread(evsel, evsel->core.threads);
 }
 
 int perf_stat_synthesize_config(struct perf_stat_config *config,