diff options
author | Jiri Olsa <jolsa@kernel.org> | 2019-07-21 07:24:43 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-07-29 17:34:45 -0400 |
commit | 453fa03090a64c0e0a561f10dfd5e8747796949c (patch) | |
tree | 6564b16701f97ca029f27513b0d19c1fc478146f | |
parent | 03617c22e31f32cbf0e4797e216db898fb898d90 (diff) |
libperf: Add perf_evlist__set_maps() function
Move the evlist__set_maps() function from tools/perf to libperf.
Committer notes:
Fix up reject due to earlier inversion in calling perf_evlist__init().
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-57-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/arch/x86/tests/perf-time-to-tsc.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-script.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 3 | ||||
-rw-r--r-- | tools/perf/lib/evlist.c | 54 | ||||
-rw-r--r-- | tools/perf/lib/include/perf/evlist.h | 6 | ||||
-rw-r--r-- | tools/perf/lib/libperf.map | 1 | ||||
-rw-r--r-- | tools/perf/tests/code-reading.c | 5 | ||||
-rw-r--r-- | tools/perf/tests/keep-tracking.c | 3 | ||||
-rw-r--r-- | tools/perf/tests/mmap-basic.c | 3 | ||||
-rw-r--r-- | tools/perf/tests/sw-clock.c | 3 | ||||
-rw-r--r-- | tools/perf/tests/switch-tracking.c | 3 | ||||
-rw-r--r-- | tools/perf/tests/task-exit.c | 3 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 58 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 2 |
14 files changed, 83 insertions, 67 deletions
diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index 261bdd680651..582182d98a7f 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
7 | #include <sys/prctl.h> | 7 | #include <sys/prctl.h> |
8 | #include <perf/cpumap.h> | 8 | #include <perf/cpumap.h> |
9 | #include <perf/evlist.h> | ||
9 | 10 | ||
10 | #include "parse-events.h" | 11 | #include "parse-events.h" |
11 | #include "evlist.h" | 12 | #include "evlist.h" |
@@ -72,7 +73,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe | |||
72 | evlist = evlist__new(); | 73 | evlist = evlist__new(); |
73 | CHECK_NOT_NULL__(evlist); | 74 | CHECK_NOT_NULL__(evlist); |
74 | 75 | ||
75 | perf_evlist__set_maps(evlist, cpus, threads); | 76 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
76 | 77 | ||
77 | CHECK__(parse_events(evlist, "cycles:u", NULL)); | 78 | CHECK__(parse_events(evlist, "cycles:u", NULL)); |
78 | 79 | ||
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index a787c5cb1331..46fadbbe1c3e 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <fcntl.h> | 48 | #include <fcntl.h> |
49 | #include <unistd.h> | 49 | #include <unistd.h> |
50 | #include <subcmd/pager.h> | 50 | #include <subcmd/pager.h> |
51 | #include <perf/evlist.h> | ||
51 | 52 | ||
52 | #include <linux/ctype.h> | 53 | #include <linux/ctype.h> |
53 | 54 | ||
@@ -3264,7 +3265,7 @@ static int set_maps(struct perf_script *script) | |||
3264 | if (WARN_ONCE(script->allocated, "stats double allocation\n")) | 3265 | if (WARN_ONCE(script->allocated, "stats double allocation\n")) |
3265 | return -EINVAL; | 3266 | return -EINVAL; |
3266 | 3267 | ||
3267 | perf_evlist__set_maps(evlist, script->cpus, script->threads); | 3268 | perf_evlist__set_maps(&evlist->core, script->cpus, script->threads); |
3268 | 3269 | ||
3269 | if (perf_evlist__alloc_stats(evlist, true)) | 3270 | if (perf_evlist__alloc_stats(evlist, true)) |
3270 | return -ENOMEM; | 3271 | return -ENOMEM; |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 4a94ca131d56..14e4c970d16a 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -83,6 +83,7 @@ | |||
83 | #include <sys/resource.h> | 83 | #include <sys/resource.h> |
84 | 84 | ||
85 | #include <linux/ctype.h> | 85 | #include <linux/ctype.h> |
86 | #include <perf/evlist.h> | ||
86 | 87 | ||
87 | #define DEFAULT_SEPARATOR " " | 88 | #define DEFAULT_SEPARATOR " " |
88 | #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" | 89 | #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" |
@@ -1517,7 +1518,7 @@ static int set_maps(struct perf_stat *st) | |||
1517 | if (WARN_ONCE(st->maps_allocated, "stats double allocation\n")) | 1518 | if (WARN_ONCE(st->maps_allocated, "stats double allocation\n")) |
1518 | return -EINVAL; | 1519 | return -EINVAL; |
1519 | 1520 | ||
1520 | perf_evlist__set_maps(evsel_list, st->cpus, st->threads); | 1521 | perf_evlist__set_maps(&evsel_list->core, st->cpus, st->threads); |
1521 | 1522 | ||
1522 | if (perf_evlist__alloc_stats(evsel_list, true)) | 1523 | if (perf_evlist__alloc_stats(evsel_list, true)) |
1523 | return -ENOMEM; | 1524 | return -ENOMEM; |
diff --git a/tools/perf/lib/evlist.c b/tools/perf/lib/evlist.c index 087ef76ea8fd..6a2308ef9868 100644 --- a/tools/perf/lib/evlist.c +++ b/tools/perf/lib/evlist.c | |||
@@ -5,6 +5,8 @@ | |||
5 | #include <internal/evsel.h> | 5 | #include <internal/evsel.h> |
6 | #include <linux/zalloc.h> | 6 | #include <linux/zalloc.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <perf/cpumap.h> | ||
9 | #include <perf/threadmap.h> | ||
8 | 10 | ||
9 | void perf_evlist__init(struct perf_evlist *evlist) | 11 | void perf_evlist__init(struct perf_evlist *evlist) |
10 | { | 12 | { |
@@ -12,11 +14,39 @@ void perf_evlist__init(struct perf_evlist *evlist) | |||
12 | evlist->nr_entries = 0; | 14 | evlist->nr_entries = 0; |
13 | } | 15 | } |
14 | 16 | ||
17 | static void __perf_evlist__propagate_maps(struct perf_evlist *evlist, | ||
18 | struct perf_evsel *evsel) | ||
19 | { | ||
20 | /* | ||
21 | * We already have cpus for evsel (via PMU sysfs) so | ||
22 | * keep it, if there's no target cpu list defined. | ||
23 | */ | ||
24 | if (!evsel->own_cpus || evlist->has_user_cpus) { | ||
25 | perf_cpu_map__put(evsel->cpus); | ||
26 | evsel->cpus = perf_cpu_map__get(evlist->cpus); | ||
27 | } else if (evsel->cpus != evsel->own_cpus) { | ||
28 | perf_cpu_map__put(evsel->cpus); | ||
29 | evsel->cpus = perf_cpu_map__get(evsel->own_cpus); | ||
30 | } | ||
31 | |||
32 | perf_thread_map__put(evsel->threads); | ||
33 | evsel->threads = perf_thread_map__get(evlist->threads); | ||
34 | } | ||
35 | |||
36 | static void perf_evlist__propagate_maps(struct perf_evlist *evlist) | ||
37 | { | ||
38 | struct perf_evsel *evsel; | ||
39 | |||
40 | perf_evlist__for_each_evsel(evlist, evsel) | ||
41 | __perf_evlist__propagate_maps(evlist, evsel); | ||
42 | } | ||
43 | |||
15 | void perf_evlist__add(struct perf_evlist *evlist, | 44 | void perf_evlist__add(struct perf_evlist *evlist, |
16 | struct perf_evsel *evsel) | 45 | struct perf_evsel *evsel) |
17 | { | 46 | { |
18 | list_add_tail(&evsel->node, &evlist->entries); | 47 | list_add_tail(&evsel->node, &evlist->entries); |
19 | evlist->nr_entries += 1; | 48 | evlist->nr_entries += 1; |
49 | __perf_evlist__propagate_maps(evlist, evsel); | ||
20 | } | 50 | } |
21 | 51 | ||
22 | void perf_evlist__remove(struct perf_evlist *evlist, | 52 | void perf_evlist__remove(struct perf_evlist *evlist, |
@@ -60,3 +90,27 @@ void perf_evlist__delete(struct perf_evlist *evlist) | |||
60 | { | 90 | { |
61 | free(evlist); | 91 | free(evlist); |
62 | } | 92 | } |
93 | |||
94 | void perf_evlist__set_maps(struct perf_evlist *evlist, | ||
95 | struct perf_cpu_map *cpus, | ||
96 | struct perf_thread_map *threads) | ||
97 | { | ||
98 | /* | ||
99 | * Allow for the possibility that one or another of the maps isn't being | ||
100 | * changed i.e. don't put it. Note we are assuming the maps that are | ||
101 | * being applied are brand new and evlist is taking ownership of the | ||
102 | * original reference count of 1. If that is not the case it is up to | ||
103 | * the caller to increase the reference count. | ||
104 | */ | ||
105 | if (cpus != evlist->cpus) { | ||
106 | perf_cpu_map__put(evlist->cpus); | ||
107 | evlist->cpus = perf_cpu_map__get(cpus); | ||
108 | } | ||
109 | |||
110 | if (threads != evlist->threads) { | ||
111 | perf_thread_map__put(evlist->threads); | ||
112 | evlist->threads = perf_thread_map__get(threads); | ||
113 | } | ||
114 | |||
115 | perf_evlist__propagate_maps(evlist); | ||
116 | } | ||
diff --git a/tools/perf/lib/include/perf/evlist.h b/tools/perf/lib/include/perf/evlist.h index 9a126fd0773c..b1d8dee018d6 100644 --- a/tools/perf/lib/include/perf/evlist.h +++ b/tools/perf/lib/include/perf/evlist.h | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | struct perf_evlist; | 7 | struct perf_evlist; |
8 | struct perf_evsel; | 8 | struct perf_evsel; |
9 | struct perf_cpu_map; | ||
10 | struct perf_thread_map; | ||
9 | 11 | ||
10 | LIBPERF_API void perf_evlist__init(struct perf_evlist *evlist); | 12 | LIBPERF_API void perf_evlist__init(struct perf_evlist *evlist); |
11 | LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, | 13 | LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, |
@@ -22,4 +24,8 @@ LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, | |||
22 | (pos) != NULL; \ | 24 | (pos) != NULL; \ |
23 | (pos) = perf_evlist__next((evlist), (pos))) | 25 | (pos) = perf_evlist__next((evlist), (pos))) |
24 | 26 | ||
27 | LIBPERF_API void perf_evlist__set_maps(struct perf_evlist *evlist, | ||
28 | struct perf_cpu_map *cpus, | ||
29 | struct perf_thread_map *threads); | ||
30 | |||
25 | #endif /* __LIBPERF_EVLIST_H */ | 31 | #endif /* __LIBPERF_EVLIST_H */ |
diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index 28ed04cbd223..9b6e8f165014 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map | |||
@@ -20,6 +20,7 @@ LIBPERF_0.0.1 { | |||
20 | perf_evlist__add; | 20 | perf_evlist__add; |
21 | perf_evlist__remove; | 21 | perf_evlist__remove; |
22 | perf_evlist__next; | 22 | perf_evlist__next; |
23 | perf_evlist__set_maps; | ||
23 | local: | 24 | local: |
24 | *; | 25 | *; |
25 | }; | 26 | }; |
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index bfaf22c2023c..e45df0736261 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <sys/param.h> | 10 | #include <sys/param.h> |
11 | #include <perf/cpumap.h> | 11 | #include <perf/cpumap.h> |
12 | #include <perf/evlist.h> | ||
12 | 13 | ||
13 | #include "parse-events.h" | 14 | #include "parse-events.h" |
14 | #include "evlist.h" | 15 | #include "evlist.h" |
@@ -629,7 +630,7 @@ static int do_test_code_reading(bool try_kcore) | |||
629 | goto out_put; | 630 | goto out_put; |
630 | } | 631 | } |
631 | 632 | ||
632 | perf_evlist__set_maps(evlist, cpus, threads); | 633 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
633 | 634 | ||
634 | str = do_determine_event(excl_kernel); | 635 | str = do_determine_event(excl_kernel); |
635 | pr_debug("Parsing event '%s'\n", str); | 636 | pr_debug("Parsing event '%s'\n", str); |
@@ -658,7 +659,7 @@ static int do_test_code_reading(bool try_kcore) | |||
658 | */ | 659 | */ |
659 | perf_cpu_map__get(cpus); | 660 | perf_cpu_map__get(cpus); |
660 | perf_thread_map__get(threads); | 661 | perf_thread_map__get(threads); |
661 | perf_evlist__set_maps(evlist, NULL, NULL); | 662 | perf_evlist__set_maps(&evlist->core, NULL, NULL); |
662 | evlist__delete(evlist); | 663 | evlist__delete(evlist); |
663 | evlist = NULL; | 664 | evlist = NULL; |
664 | continue; | 665 | continue; |
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index 46478ba1ed16..0ce5ce33bac4 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <unistd.h> | 3 | #include <unistd.h> |
4 | #include <sys/prctl.h> | 4 | #include <sys/prctl.h> |
5 | #include <perf/cpumap.h> | 5 | #include <perf/cpumap.h> |
6 | #include <perf/evlist.h> | ||
6 | 7 | ||
7 | #include "parse-events.h" | 8 | #include "parse-events.h" |
8 | #include "evlist.h" | 9 | #include "evlist.h" |
@@ -82,7 +83,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un | |||
82 | evlist = evlist__new(); | 83 | evlist = evlist__new(); |
83 | CHECK_NOT_NULL__(evlist); | 84 | CHECK_NOT_NULL__(evlist); |
84 | 85 | ||
85 | perf_evlist__set_maps(evlist, cpus, threads); | 86 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
86 | 87 | ||
87 | CHECK__(parse_events(evlist, "dummy:u", NULL)); | 88 | CHECK__(parse_events(evlist, "dummy:u", NULL)); |
88 | CHECK__(parse_events(evlist, "cycles:u", NULL)); | 89 | CHECK__(parse_events(evlist, "cycles:u", NULL)); |
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index aa792aebd7f0..7327694fbde0 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "tests.h" | 12 | #include "tests.h" |
13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <perf/evlist.h> | ||
15 | 16 | ||
16 | /* | 17 | /* |
17 | * This test will generate random numbers of calls to some getpid syscalls, | 18 | * This test will generate random numbers of calls to some getpid syscalls, |
@@ -68,7 +69,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse | |||
68 | goto out_free_cpus; | 69 | goto out_free_cpus; |
69 | } | 70 | } |
70 | 71 | ||
71 | perf_evlist__set_maps(evlist, cpus, threads); | 72 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
72 | 73 | ||
73 | for (i = 0; i < nsyscalls; ++i) { | 74 | for (i = 0; i < nsyscalls; ++i) { |
74 | char name[64]; | 75 | char name[64]; |
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 2decda2d4c17..c5f1a9f83380 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "util/evlist.h" | 11 | #include "util/evlist.h" |
12 | #include "util/cpumap.h" | 12 | #include "util/cpumap.h" |
13 | #include "util/thread_map.h" | 13 | #include "util/thread_map.h" |
14 | #include <perf/evlist.h> | ||
14 | 15 | ||
15 | #define NR_LOOPS 10000000 | 16 | #define NR_LOOPS 10000000 |
16 | 17 | ||
@@ -64,7 +65,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
64 | goto out_free_maps; | 65 | goto out_free_maps; |
65 | } | 66 | } |
66 | 67 | ||
67 | perf_evlist__set_maps(evlist, cpus, threads); | 68 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
68 | 69 | ||
69 | cpus = NULL; | 70 | cpus = NULL; |
70 | threads = NULL; | 71 | threads = NULL; |
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index 9e0bbea15005..e3cee69f6ea2 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <linux/zalloc.h> | 7 | #include <linux/zalloc.h> |
8 | #include <perf/cpumap.h> | 8 | #include <perf/cpumap.h> |
9 | #include <perf/evlist.h> | ||
9 | 10 | ||
10 | #include "parse-events.h" | 11 | #include "parse-events.h" |
11 | #include "evlist.h" | 12 | #include "evlist.h" |
@@ -354,7 +355,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_ | |||
354 | goto out_err; | 355 | goto out_err; |
355 | } | 356 | } |
356 | 357 | ||
357 | perf_evlist__set_maps(evlist, cpus, threads); | 358 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
358 | 359 | ||
359 | /* First event */ | 360 | /* First event */ |
360 | err = parse_events(evlist, "cpu-clock:u", NULL); | 361 | err = parse_events(evlist, "cpu-clock:u", NULL); |
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index b0192ea636a7..4ca38fd0379a 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include <signal.h> | 9 | #include <signal.h> |
10 | #include <perf/evlist.h> | ||
10 | 11 | ||
11 | static int exited; | 12 | static int exited; |
12 | static int nr_exit; | 13 | static int nr_exit; |
@@ -71,7 +72,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused | |||
71 | goto out_free_maps; | 72 | goto out_free_maps; |
72 | } | 73 | } |
73 | 74 | ||
74 | perf_evlist__set_maps(evlist, cpus, threads); | 75 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
75 | 76 | ||
76 | cpus = NULL; | 77 | cpus = NULL; |
77 | threads = NULL; | 78 | threads = NULL; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 1a6f877ebb03..4433b656cfb7 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -51,7 +51,7 @@ void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus, | |||
51 | for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i) | 51 | for (i = 0; i < PERF_EVLIST__HLIST_SIZE; ++i) |
52 | INIT_HLIST_HEAD(&evlist->heads[i]); | 52 | INIT_HLIST_HEAD(&evlist->heads[i]); |
53 | perf_evlist__init(&evlist->core); | 53 | perf_evlist__init(&evlist->core); |
54 | perf_evlist__set_maps(evlist, cpus, threads); | 54 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
55 | fdarray__init(&evlist->pollfd, 64); | 55 | fdarray__init(&evlist->pollfd, 64); |
56 | evlist->workload.pid = -1; | 56 | evlist->workload.pid = -1; |
57 | evlist->bkw_mmap_state = BKW_MMAP_NOTREADY; | 57 | evlist->bkw_mmap_state = BKW_MMAP_NOTREADY; |
@@ -152,33 +152,6 @@ void evlist__delete(struct evlist *evlist) | |||
152 | free(evlist); | 152 | free(evlist); |
153 | } | 153 | } |
154 | 154 | ||
155 | static void __perf_evlist__propagate_maps(struct evlist *evlist, | ||
156 | struct evsel *evsel) | ||
157 | { | ||
158 | /* | ||
159 | * We already have cpus for evsel (via PMU sysfs) so | ||
160 | * keep it, if there's no target cpu list defined. | ||
161 | */ | ||
162 | if (!evsel->core.own_cpus || evlist->core.has_user_cpus) { | ||
163 | perf_cpu_map__put(evsel->core.cpus); | ||
164 | evsel->core.cpus = perf_cpu_map__get(evlist->core.cpus); | ||
165 | } else if (evsel->core.cpus != evsel->core.own_cpus) { | ||
166 | perf_cpu_map__put(evsel->core.cpus); | ||
167 | evsel->core.cpus = perf_cpu_map__get(evsel->core.own_cpus); | ||
168 | } | ||
169 | |||
170 | perf_thread_map__put(evsel->core.threads); | ||
171 | evsel->core.threads = perf_thread_map__get(evlist->core.threads); | ||
172 | } | ||
173 | |||
174 | static void perf_evlist__propagate_maps(struct evlist *evlist) | ||
175 | { | ||
176 | struct evsel *evsel; | ||
177 | |||
178 | evlist__for_each_entry(evlist, evsel) | ||
179 | __perf_evlist__propagate_maps(evlist, evsel); | ||
180 | } | ||
181 | |||
182 | void evlist__add(struct evlist *evlist, struct evsel *entry) | 155 | void evlist__add(struct evlist *evlist, struct evsel *entry) |
183 | { | 156 | { |
184 | entry->evlist = evlist; | 157 | entry->evlist = evlist; |
@@ -189,8 +162,6 @@ void evlist__add(struct evlist *evlist, struct evsel *entry) | |||
189 | 162 | ||
190 | if (evlist->core.nr_entries == 1) | 163 | if (evlist->core.nr_entries == 1) |
191 | perf_evlist__set_id_pos(evlist); | 164 | perf_evlist__set_id_pos(evlist); |
192 | |||
193 | __perf_evlist__propagate_maps(evlist, entry); | ||
194 | } | 165 | } |
195 | 166 | ||
196 | void evlist__remove(struct evlist *evlist, struct evsel *evsel) | 167 | void evlist__remove(struct evlist *evlist, struct evsel *evsel) |
@@ -1097,7 +1068,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target) | |||
1097 | 1068 | ||
1098 | evlist->core.has_user_cpus = !!target->cpu_list; | 1069 | evlist->core.has_user_cpus = !!target->cpu_list; |
1099 | 1070 | ||
1100 | perf_evlist__set_maps(evlist, cpus, threads); | 1071 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
1101 | 1072 | ||
1102 | return 0; | 1073 | return 0; |
1103 | 1074 | ||
@@ -1106,29 +1077,6 @@ out_delete_threads: | |||
1106 | return -1; | 1077 | return -1; |
1107 | } | 1078 | } |
1108 | 1079 | ||
1109 | void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus, | ||
1110 | struct perf_thread_map *threads) | ||
1111 | { | ||
1112 | /* | ||
1113 | * Allow for the possibility that one or another of the maps isn't being | ||
1114 | * changed i.e. don't put it. Note we are assuming the maps that are | ||
1115 | * being applied are brand new and evlist is taking ownership of the | ||
1116 | * original reference count of 1. If that is not the case it is up to | ||
1117 | * the caller to increase the reference count. | ||
1118 | */ | ||
1119 | if (cpus != evlist->core.cpus) { | ||
1120 | perf_cpu_map__put(evlist->core.cpus); | ||
1121 | evlist->core.cpus = perf_cpu_map__get(cpus); | ||
1122 | } | ||
1123 | |||
1124 | if (threads != evlist->core.threads) { | ||
1125 | perf_thread_map__put(evlist->core.threads); | ||
1126 | evlist->core.threads = perf_thread_map__get(threads); | ||
1127 | } | ||
1128 | |||
1129 | perf_evlist__propagate_maps(evlist); | ||
1130 | } | ||
1131 | |||
1132 | void __perf_evlist__set_sample_bit(struct evlist *evlist, | 1080 | void __perf_evlist__set_sample_bit(struct evlist *evlist, |
1133 | enum perf_event_sample_format bit) | 1081 | enum perf_event_sample_format bit) |
1134 | { | 1082 | { |
@@ -1381,7 +1329,7 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist) | |||
1381 | if (!threads) | 1329 | if (!threads) |
1382 | goto out_put; | 1330 | goto out_put; |
1383 | 1331 | ||
1384 | perf_evlist__set_maps(evlist, cpus, threads); | 1332 | perf_evlist__set_maps(&evlist->core, cpus, threads); |
1385 | out: | 1333 | out: |
1386 | return err; | 1334 | return err; |
1387 | out_put: | 1335 | out_put: |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index de2025d198d4..e31ddcc058f2 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -191,8 +191,6 @@ int perf_evlist__enable_event_idx(struct evlist *evlist, | |||
191 | void perf_evlist__set_selected(struct evlist *evlist, | 191 | void perf_evlist__set_selected(struct evlist *evlist, |
192 | struct evsel *evsel); | 192 | struct evsel *evsel); |
193 | 193 | ||
194 | void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus, | ||
195 | struct perf_thread_map *threads); | ||
196 | int perf_evlist__create_maps(struct evlist *evlist, struct target *target); | 194 | int perf_evlist__create_maps(struct evlist *evlist, struct target *target); |
197 | int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel); | 195 | int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel); |
198 | 196 | ||