diff options
33 files changed, 78 insertions, 75 deletions
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 268fcb31cd53..3a78b38e43ca 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c | |||
@@ -181,7 +181,7 @@ static int cs_etm_set_option(struct auxtrace_record *itr, | |||
181 | 181 | ||
182 | err = 0; | 182 | err = 0; |
183 | out: | 183 | out: |
184 | cpu_map__put(online_cpus); | 184 | perf_cpu_map__put(online_cpus); |
185 | return err; | 185 | return err; |
186 | } | 186 | } |
187 | 187 | ||
@@ -517,7 +517,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, | |||
517 | } | 517 | } |
518 | } | 518 | } |
519 | 519 | ||
520 | cpu_map__put(online_cpus); | 520 | perf_cpu_map__put(online_cpus); |
521 | 521 | ||
522 | return (CS_ETM_HEADER_SIZE + | 522 | return (CS_ETM_HEADER_SIZE + |
523 | (etmv4 * CS_ETMV4_PRIV_SIZE) + | 523 | (etmv4 * CS_ETMV4_PRIV_SIZE) + |
@@ -679,7 +679,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr, | |||
679 | if (cpu_map__has(cpu_map, i)) | 679 | if (cpu_map__has(cpu_map, i)) |
680 | cs_etm_get_metadata(i, &offset, itr, info); | 680 | cs_etm_get_metadata(i, &offset, itr, info); |
681 | 681 | ||
682 | cpu_map__put(online_cpus); | 682 | perf_cpu_map__put(online_cpus); |
683 | 683 | ||
684 | return 0; | 684 | return 0; |
685 | } | 685 | } |
diff --git a/tools/perf/arch/arm64/util/header.c b/tools/perf/arch/arm64/util/header.c index b3e73a413f5a..602caf550e7f 100644 --- a/tools/perf/arch/arm64/util/header.c +++ b/tools/perf/arch/arm64/util/header.c | |||
@@ -27,7 +27,7 @@ char *get_cpuid_str(struct perf_pmu *pmu) | |||
27 | return NULL; | 27 | return NULL; |
28 | 28 | ||
29 | /* read midr from list of cpus mapped to this pmu */ | 29 | /* read midr from list of cpus mapped to this pmu */ |
30 | cpus = cpu_map__get(pmu->cpus); | 30 | cpus = perf_cpu_map__get(pmu->cpus); |
31 | for (cpu = 0; cpu < cpus->nr; cpu++) { | 31 | for (cpu = 0; cpu < cpus->nr; cpu++) { |
32 | scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR, | 32 | scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR, |
33 | sysfs, cpus->map[cpu]); | 33 | sysfs, cpus->map[cpu]); |
@@ -60,6 +60,6 @@ char *get_cpuid_str(struct perf_pmu *pmu) | |||
60 | buf = NULL; | 60 | buf = NULL; |
61 | } | 61 | } |
62 | 62 | ||
63 | cpu_map__put(cpus); | 63 | perf_cpu_map__put(cpus); |
64 | return buf; | 64 | return buf; |
65 | } | 65 | } |
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 105ef2a17a9c..6943352b8d94 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c | |||
@@ -206,7 +206,7 @@ static int reset_tracing_cpu(void) | |||
206 | int ret; | 206 | int ret; |
207 | 207 | ||
208 | ret = set_tracing_cpumask(cpumap); | 208 | ret = set_tracing_cpumask(cpumap); |
209 | cpu_map__put(cpumap); | 209 | perf_cpu_map__put(cpumap); |
210 | return ret; | 210 | return ret; |
211 | } | 211 | } |
212 | 212 | ||
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 36e66a4f3c57..39bd73d0e06e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -933,8 +933,8 @@ static int perf_stat_init_aggr_mode(void) | |||
933 | 933 | ||
934 | static void perf_stat__exit_aggr_mode(void) | 934 | static void perf_stat__exit_aggr_mode(void) |
935 | { | 935 | { |
936 | cpu_map__put(stat_config.aggr_map); | 936 | perf_cpu_map__put(stat_config.aggr_map); |
937 | cpu_map__put(stat_config.cpus_aggr_map); | 937 | perf_cpu_map__put(stat_config.cpus_aggr_map); |
938 | stat_config.aggr_map = NULL; | 938 | stat_config.aggr_map = NULL; |
939 | stat_config.cpus_aggr_map = NULL; | 939 | stat_config.cpus_aggr_map = NULL; |
940 | } | 940 | } |
diff --git a/tools/perf/lib/cpumap.c b/tools/perf/lib/cpumap.c index 80d587ab95aa..f3cfb4c71106 100644 --- a/tools/perf/lib/cpumap.c +++ b/tools/perf/lib/cpumap.c | |||
@@ -3,6 +3,8 @@ | |||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <linux/refcount.h> | 4 | #include <linux/refcount.h> |
5 | #include <internal/cpumap.h> | 5 | #include <internal/cpumap.h> |
6 | #include <asm/bug.h> | ||
7 | #include <stdio.h> | ||
6 | 8 | ||
7 | struct perf_cpu_map *perf_cpu_map__dummy_new(void) | 9 | struct perf_cpu_map *perf_cpu_map__dummy_new(void) |
8 | { | 10 | { |
@@ -16,3 +18,25 @@ struct perf_cpu_map *perf_cpu_map__dummy_new(void) | |||
16 | 18 | ||
17 | return cpus; | 19 | return cpus; |
18 | } | 20 | } |
21 | |||
22 | static void cpu_map__delete(struct perf_cpu_map *map) | ||
23 | { | ||
24 | if (map) { | ||
25 | WARN_ONCE(refcount_read(&map->refcnt) != 0, | ||
26 | "cpu_map refcnt unbalanced\n"); | ||
27 | free(map); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map) | ||
32 | { | ||
33 | if (map) | ||
34 | refcount_inc(&map->refcnt); | ||
35 | return map; | ||
36 | } | ||
37 | |||
38 | void perf_cpu_map__put(struct perf_cpu_map *map) | ||
39 | { | ||
40 | if (map && refcount_dec_and_test(&map->refcnt)) | ||
41 | cpu_map__delete(map); | ||
42 | } | ||
diff --git a/tools/perf/lib/include/perf/cpumap.h b/tools/perf/lib/include/perf/cpumap.h index fa1e5aa9d662..e16c2515a499 100644 --- a/tools/perf/lib/include/perf/cpumap.h +++ b/tools/perf/lib/include/perf/cpumap.h | |||
@@ -7,5 +7,7 @@ | |||
7 | struct perf_cpu_map; | 7 | struct perf_cpu_map; |
8 | 8 | ||
9 | LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void); | 9 | LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void); |
10 | LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); | ||
11 | LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map); | ||
10 | 12 | ||
11 | #endif /* __LIBPERF_CPUMAP_H */ | 13 | #endif /* __LIBPERF_CPUMAP_H */ |
diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index 65201c6cbe7e..76ce3bc59dd8 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map | |||
@@ -2,6 +2,8 @@ LIBPERF_0.0.1 { | |||
2 | global: | 2 | global: |
3 | libperf_set_print; | 3 | libperf_set_print; |
4 | perf_cpu_map__dummy_new; | 4 | perf_cpu_map__dummy_new; |
5 | perf_cpu_map__get; | ||
6 | perf_cpu_map__put; | ||
5 | local: | 7 | local: |
6 | *; | 8 | *; |
7 | }; | 9 | }; |
diff --git a/tools/perf/tests/bitmap.c b/tools/perf/tests/bitmap.c index 74d0cd32a5c4..95304d29092e 100644 --- a/tools/perf/tests/bitmap.c +++ b/tools/perf/tests/bitmap.c | |||
@@ -21,7 +21,7 @@ static unsigned long *get_bitmap(const char *str, int nbits) | |||
21 | } | 21 | } |
22 | 22 | ||
23 | if (map) | 23 | if (map) |
24 | cpu_map__put(map); | 24 | perf_cpu_map__put(map); |
25 | return bm; | 25 | return bm; |
26 | } | 26 | } |
27 | 27 | ||
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index ec4b0bf28270..ce2d3266286a 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c | |||
@@ -655,7 +655,7 @@ static int do_test_code_reading(bool try_kcore) | |||
655 | * and will be freed by following perf_evlist__set_maps | 655 | * and will be freed by following perf_evlist__set_maps |
656 | * call. Getting refference to keep them alive. | 656 | * call. Getting refference to keep them alive. |
657 | */ | 657 | */ |
658 | cpu_map__get(cpus); | 658 | perf_cpu_map__get(cpus); |
659 | thread_map__get(threads); | 659 | thread_map__get(threads); |
660 | perf_evlist__set_maps(evlist, NULL, NULL); | 660 | perf_evlist__set_maps(evlist, NULL, NULL); |
661 | evlist__delete(evlist); | 661 | evlist__delete(evlist); |
@@ -705,7 +705,7 @@ out_err: | |||
705 | if (evlist) { | 705 | if (evlist) { |
706 | evlist__delete(evlist); | 706 | evlist__delete(evlist); |
707 | } else { | 707 | } else { |
708 | cpu_map__put(cpus); | 708 | perf_cpu_map__put(cpus); |
709 | thread_map__put(threads); | 709 | thread_map__put(threads); |
710 | } | 710 | } |
711 | machine__delete_threads(machine); | 711 | machine__delete_threads(machine); |
diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index 10da4400493d..6c921087b0fe 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c | |||
@@ -39,7 +39,7 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused, | |||
39 | TEST_ASSERT_VAL("wrong cpu", map->map[i] == i); | 39 | TEST_ASSERT_VAL("wrong cpu", map->map[i] == i); |
40 | } | 40 | } |
41 | 41 | ||
42 | cpu_map__put(map); | 42 | perf_cpu_map__put(map); |
43 | return 0; | 43 | return 0; |
44 | } | 44 | } |
45 | 45 | ||
@@ -68,7 +68,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused, | |||
68 | TEST_ASSERT_VAL("wrong cpu", map->map[0] == 1); | 68 | TEST_ASSERT_VAL("wrong cpu", map->map[0] == 1); |
69 | TEST_ASSERT_VAL("wrong cpu", map->map[1] == 256); | 69 | TEST_ASSERT_VAL("wrong cpu", map->map[1] == 256); |
70 | TEST_ASSERT_VAL("wrong refcnt", refcount_read(&map->refcnt) == 1); | 70 | TEST_ASSERT_VAL("wrong refcnt", refcount_read(&map->refcnt) == 1); |
71 | cpu_map__put(map); | 71 | perf_cpu_map__put(map); |
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
@@ -83,7 +83,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may | |||
83 | TEST_ASSERT_VAL("failed to synthesize map", | 83 | TEST_ASSERT_VAL("failed to synthesize map", |
84 | !perf_event__synthesize_cpu_map(NULL, cpus, process_event_mask, NULL)); | 84 | !perf_event__synthesize_cpu_map(NULL, cpus, process_event_mask, NULL)); |
85 | 85 | ||
86 | cpu_map__put(cpus); | 86 | perf_cpu_map__put(cpus); |
87 | 87 | ||
88 | /* This one is better stores in cpu values. */ | 88 | /* This one is better stores in cpu values. */ |
89 | cpus = cpu_map__new("1,256"); | 89 | cpus = cpu_map__new("1,256"); |
@@ -91,7 +91,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may | |||
91 | TEST_ASSERT_VAL("failed to synthesize map", | 91 | TEST_ASSERT_VAL("failed to synthesize map", |
92 | !perf_event__synthesize_cpu_map(NULL, cpus, process_event_cpus, NULL)); | 92 | !perf_event__synthesize_cpu_map(NULL, cpus, process_event_cpus, NULL)); |
93 | 93 | ||
94 | cpu_map__put(cpus); | 94 | perf_cpu_map__put(cpus); |
95 | return 0; | 95 | return 0; |
96 | } | 96 | } |
97 | 97 | ||
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index bf00d3d792fb..dcfff4b20c92 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c | |||
@@ -132,7 +132,7 @@ static int attach__cpu_disabled(struct evlist *evlist) | |||
132 | return err; | 132 | return err; |
133 | } | 133 | } |
134 | 134 | ||
135 | cpu_map__put(cpus); | 135 | perf_cpu_map__put(cpus); |
136 | return evsel__enable(evsel); | 136 | return evsel__enable(evsel); |
137 | } | 137 | } |
138 | 138 | ||
@@ -154,7 +154,7 @@ static int attach__cpu_enabled(struct evlist *evlist) | |||
154 | if (err == -EACCES) | 154 | if (err == -EACCES) |
155 | return TEST_SKIP; | 155 | return TEST_SKIP; |
156 | 156 | ||
157 | cpu_map__put(cpus); | 157 | perf_cpu_map__put(cpus); |
158 | return err ? TEST_FAIL : TEST_OK; | 158 | return err ? TEST_FAIL : TEST_OK; |
159 | } | 159 | } |
160 | 160 | ||
diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c index eb0dd359762d..415d12e96834 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c | |||
@@ -73,7 +73,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused, | |||
73 | TEST_ASSERT_VAL("wrong cpus", map->map[0] == 1); | 73 | TEST_ASSERT_VAL("wrong cpus", map->map[0] == 1); |
74 | TEST_ASSERT_VAL("wrong cpus", map->map[1] == 2); | 74 | TEST_ASSERT_VAL("wrong cpus", map->map[1] == 2); |
75 | TEST_ASSERT_VAL("wrong cpus", map->map[2] == 3); | 75 | TEST_ASSERT_VAL("wrong cpus", map->map[2] == 3); |
76 | cpu_map__put(map); | 76 | perf_cpu_map__put(map); |
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |
79 | 79 | ||
@@ -113,6 +113,6 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu | |||
113 | TEST_ASSERT_VAL("failed to synthesize attr update cpus", | 113 | TEST_ASSERT_VAL("failed to synthesize attr update cpus", |
114 | !perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus)); | 114 | !perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus)); |
115 | 115 | ||
116 | cpu_map__put(evsel->own_cpus); | 116 | perf_cpu_map__put(evsel->own_cpus); |
117 | return 0; | 117 | return 0; |
118 | } | 118 | } |
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index 7bfc859971e5..43e55fe98f8c 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c | |||
@@ -149,7 +149,7 @@ out_err: | |||
149 | evlist__disable(evlist); | 149 | evlist__disable(evlist); |
150 | evlist__delete(evlist); | 150 | evlist__delete(evlist); |
151 | } else { | 151 | } else { |
152 | cpu_map__put(cpus); | 152 | perf_cpu_map__put(cpus); |
153 | thread_map__put(threads); | 153 | thread_map__put(threads); |
154 | } | 154 | } |
155 | 155 | ||
diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c index e12eedfba781..6fe2c1e7918b 100644 --- a/tools/perf/tests/mem2node.c +++ b/tools/perf/tests/mem2node.c | |||
@@ -32,7 +32,7 @@ static unsigned long *get_bitmap(const char *str, int nbits) | |||
32 | } | 32 | } |
33 | 33 | ||
34 | if (map) | 34 | if (map) |
35 | cpu_map__put(map); | 35 | perf_cpu_map__put(map); |
36 | else | 36 | else |
37 | free(bm); | 37 | free(bm); |
38 | 38 | ||
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 40511025208f..d15282174b2e 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c | |||
@@ -155,7 +155,7 @@ out_delete_evlist: | |||
155 | cpus = NULL; | 155 | cpus = NULL; |
156 | threads = NULL; | 156 | threads = NULL; |
157 | out_free_cpus: | 157 | out_free_cpus: |
158 | cpu_map__put(cpus); | 158 | perf_cpu_map__put(cpus); |
159 | out_free_threads: | 159 | out_free_threads: |
160 | thread_map__put(threads); | 160 | thread_map__put(threads); |
161 | return err; | 161 | return err; |
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index f96cbd304024..611f6ea9b702 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c | |||
@@ -120,7 +120,7 @@ out_close_fd: | |||
120 | out_evsel_delete: | 120 | out_evsel_delete: |
121 | evsel__delete(evsel); | 121 | evsel__delete(evsel); |
122 | out_cpu_map_delete: | 122 | out_cpu_map_delete: |
123 | cpu_map__put(cpus); | 123 | perf_cpu_map__put(cpus); |
124 | out_thread_map_delete: | 124 | out_thread_map_delete: |
125 | thread_map__put(threads); | 125 | thread_map__put(threads); |
126 | return err; | 126 | return err; |
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index c6d3f4488b73..c464e301ade9 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c | |||
@@ -125,7 +125,7 @@ out_init: | |||
125 | } | 125 | } |
126 | 126 | ||
127 | out_free_maps: | 127 | out_free_maps: |
128 | cpu_map__put(cpus); | 128 | perf_cpu_map__put(cpus); |
129 | thread_map__put(threads); | 129 | thread_map__put(threads); |
130 | out_delete_evlist: | 130 | out_delete_evlist: |
131 | evlist__delete(evlist); | 131 | evlist__delete(evlist); |
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index d5537edb47db..27af7b7109a3 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c | |||
@@ -569,7 +569,7 @@ out: | |||
569 | evlist__disable(evlist); | 569 | evlist__disable(evlist); |
570 | evlist__delete(evlist); | 570 | evlist__delete(evlist); |
571 | } else { | 571 | } else { |
572 | cpu_map__put(cpus); | 572 | perf_cpu_map__put(cpus); |
573 | thread_map__put(threads); | 573 | thread_map__put(threads); |
574 | } | 574 | } |
575 | 575 | ||
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index c094fb8cc877..f026759a05d7 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c | |||
@@ -135,7 +135,7 @@ out_init: | |||
135 | } | 135 | } |
136 | 136 | ||
137 | out_free_maps: | 137 | out_free_maps: |
138 | cpu_map__put(cpus); | 138 | perf_cpu_map__put(cpus); |
139 | thread_map__put(threads); | 139 | thread_map__put(threads); |
140 | out_delete_evlist: | 140 | out_delete_evlist: |
141 | evlist__delete(evlist); | 141 | evlist__delete(evlist); |
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c index 443d0272ebbd..1b57ded58d59 100644 --- a/tools/perf/tests/topology.c +++ b/tools/perf/tests/topology.c | |||
@@ -133,7 +133,7 @@ int test__session_topology(struct test *test __maybe_unused, int subtest __maybe | |||
133 | } | 133 | } |
134 | 134 | ||
135 | ret = check_cpu_topology(path, map); | 135 | ret = check_cpu_topology(path, map); |
136 | cpu_map__put(map); | 136 | perf_cpu_map__put(map); |
137 | 137 | ||
138 | free_path: | 138 | free_path: |
139 | unlink(path); | 139 | unlink(path); |
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index acda9bfb4002..44082e5eabde 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c | |||
@@ -273,28 +273,6 @@ struct perf_cpu_map *cpu_map__empty_new(int nr) | |||
273 | return cpus; | 273 | return cpus; |
274 | } | 274 | } |
275 | 275 | ||
276 | static void cpu_map__delete(struct perf_cpu_map *map) | ||
277 | { | ||
278 | if (map) { | ||
279 | WARN_ONCE(refcount_read(&map->refcnt) != 0, | ||
280 | "cpu_map refcnt unbalanced\n"); | ||
281 | free(map); | ||
282 | } | ||
283 | } | ||
284 | |||
285 | struct perf_cpu_map *cpu_map__get(struct perf_cpu_map *map) | ||
286 | { | ||
287 | if (map) | ||
288 | refcount_inc(&map->refcnt); | ||
289 | return map; | ||
290 | } | ||
291 | |||
292 | void cpu_map__put(struct perf_cpu_map *map) | ||
293 | { | ||
294 | if (map && refcount_dec_and_test(&map->refcnt)) | ||
295 | cpu_map__delete(map); | ||
296 | } | ||
297 | |||
298 | static int cpu__get_topology_int(int cpu, const char *name, int *value) | 276 | static int cpu__get_topology_int(int cpu, const char *name, int *value) |
299 | { | 277 | { |
300 | char path[PATH_MAX]; | 278 | char path[PATH_MAX]; |
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index 0ce3f6bd9449..b7af2cb68c19 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h | |||
@@ -29,9 +29,6 @@ int cpu_map__build_die_map(struct perf_cpu_map *cpus, struct perf_cpu_map **diep | |||
29 | int cpu_map__build_core_map(struct perf_cpu_map *cpus, struct perf_cpu_map **corep); | 29 | int cpu_map__build_core_map(struct perf_cpu_map *cpus, struct perf_cpu_map **corep); |
30 | const struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */ | 30 | const struct perf_cpu_map *cpu_map__online(void); /* thread unsafe */ |
31 | 31 | ||
32 | struct perf_cpu_map *cpu_map__get(struct perf_cpu_map *map); | ||
33 | void cpu_map__put(struct perf_cpu_map *map); | ||
34 | |||
35 | static inline int cpu_map__socket(struct perf_cpu_map *sock, int s) | 32 | static inline int cpu_map__socket(struct perf_cpu_map *sock, int s) |
36 | { | 33 | { |
37 | if (!sock || s > sock->nr || s < 0) | 34 | if (!sock || s > sock->nr || s < 0) |
diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c index 157b0988435e..0cd99c460cd4 100644 --- a/tools/perf/util/cputopo.c +++ b/tools/perf/util/cputopo.c | |||
@@ -219,7 +219,7 @@ struct cpu_topology *cpu_topology__new(void) | |||
219 | } | 219 | } |
220 | 220 | ||
221 | out_free: | 221 | out_free: |
222 | cpu_map__put(map); | 222 | perf_cpu_map__put(map); |
223 | if (ret) { | 223 | if (ret) { |
224 | cpu_topology__delete(tp); | 224 | cpu_topology__delete(tp); |
225 | tp = NULL; | 225 | tp = NULL; |
@@ -335,7 +335,7 @@ struct numa_topology *numa_topology__new(void) | |||
335 | out: | 335 | out: |
336 | free(buf); | 336 | free(buf); |
337 | fclose(fp); | 337 | fclose(fp); |
338 | cpu_map__put(node_map); | 338 | perf_cpu_map__put(node_map); |
339 | return tp; | 339 | return tp; |
340 | } | 340 | } |
341 | 341 | ||
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 9909ec40c6d2..d77912b2b5e7 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c | |||
@@ -179,7 +179,7 @@ void perf_env__exit(struct perf_env *env) | |||
179 | zfree(&env->cpu); | 179 | zfree(&env->cpu); |
180 | 180 | ||
181 | for (i = 0; i < env->nr_numa_nodes; i++) | 181 | for (i = 0; i < env->nr_numa_nodes; i++) |
182 | cpu_map__put(env->numa_nodes[i].map); | 182 | perf_cpu_map__put(env->numa_nodes[i].map); |
183 | zfree(&env->numa_nodes); | 183 | zfree(&env->numa_nodes); |
184 | 184 | ||
185 | for (i = 0; i < env->caches_cnt; i++) | 185 | for (i = 0; i < env->caches_cnt; i++) |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f78837788b14..1a3db35f9f7d 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -1403,7 +1403,7 @@ size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp) | |||
1403 | else | 1403 | else |
1404 | ret += fprintf(fp, "failed to get cpumap from event\n"); | 1404 | ret += fprintf(fp, "failed to get cpumap from event\n"); |
1405 | 1405 | ||
1406 | cpu_map__put(cpus); | 1406 | perf_cpu_map__put(cpus); |
1407 | return ret; | 1407 | return ret; |
1408 | } | 1408 | } |
1409 | 1409 | ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 461c1e68e9e7..35020d50f51e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -141,7 +141,7 @@ void evlist__delete(struct evlist *evlist) | |||
141 | 141 | ||
142 | perf_evlist__munmap(evlist); | 142 | perf_evlist__munmap(evlist); |
143 | evlist__close(evlist); | 143 | evlist__close(evlist); |
144 | cpu_map__put(evlist->cpus); | 144 | perf_cpu_map__put(evlist->cpus); |
145 | thread_map__put(evlist->threads); | 145 | thread_map__put(evlist->threads); |
146 | evlist->cpus = NULL; | 146 | evlist->cpus = NULL; |
147 | evlist->threads = NULL; | 147 | evlist->threads = NULL; |
@@ -158,11 +158,11 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist, | |||
158 | * keep it, if there's no target cpu list defined. | 158 | * keep it, if there's no target cpu list defined. |
159 | */ | 159 | */ |
160 | if (!evsel->own_cpus || evlist->has_user_cpus) { | 160 | if (!evsel->own_cpus || evlist->has_user_cpus) { |
161 | cpu_map__put(evsel->cpus); | 161 | perf_cpu_map__put(evsel->cpus); |
162 | evsel->cpus = cpu_map__get(evlist->cpus); | 162 | evsel->cpus = perf_cpu_map__get(evlist->cpus); |
163 | } else if (evsel->cpus != evsel->own_cpus) { | 163 | } else if (evsel->cpus != evsel->own_cpus) { |
164 | cpu_map__put(evsel->cpus); | 164 | perf_cpu_map__put(evsel->cpus); |
165 | evsel->cpus = cpu_map__get(evsel->own_cpus); | 165 | evsel->cpus = perf_cpu_map__get(evsel->own_cpus); |
166 | } | 166 | } |
167 | 167 | ||
168 | thread_map__put(evsel->threads); | 168 | thread_map__put(evsel->threads); |
@@ -1115,8 +1115,8 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus, | |||
1115 | * the caller to increase the reference count. | 1115 | * the caller to increase the reference count. |
1116 | */ | 1116 | */ |
1117 | if (cpus != evlist->cpus) { | 1117 | if (cpus != evlist->cpus) { |
1118 | cpu_map__put(evlist->cpus); | 1118 | perf_cpu_map__put(evlist->cpus); |
1119 | evlist->cpus = cpu_map__get(cpus); | 1119 | evlist->cpus = perf_cpu_map__get(cpus); |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | if (threads != evlist->threads) { | 1122 | if (threads != evlist->threads) { |
@@ -1383,7 +1383,7 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist) | |||
1383 | out: | 1383 | out: |
1384 | return err; | 1384 | return err; |
1385 | out_put: | 1385 | out_put: |
1386 | cpu_map__put(cpus); | 1386 | perf_cpu_map__put(cpus); |
1387 | goto out; | 1387 | goto out; |
1388 | } | 1388 | } |
1389 | 1389 | ||
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a389752840a9..72c0e6948e83 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1325,8 +1325,8 @@ void perf_evsel__exit(struct evsel *evsel) | |||
1325 | perf_evsel__free_id(evsel); | 1325 | perf_evsel__free_id(evsel); |
1326 | perf_evsel__free_config_terms(evsel); | 1326 | perf_evsel__free_config_terms(evsel); |
1327 | cgroup__put(evsel->cgrp); | 1327 | cgroup__put(evsel->cgrp); |
1328 | cpu_map__put(evsel->cpus); | 1328 | perf_cpu_map__put(evsel->cpus); |
1329 | cpu_map__put(evsel->own_cpus); | 1329 | perf_cpu_map__put(evsel->own_cpus); |
1330 | thread_map__put(evsel->threads); | 1330 | thread_map__put(evsel->threads); |
1331 | zfree(&evsel->group_name); | 1331 | zfree(&evsel->group_name); |
1332 | zfree(&evsel->name); | 1332 | zfree(&evsel->name); |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index decb66d243ca..8c9928feb38a 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -332,8 +332,8 @@ __add_event(struct list_head *list, int *idx, | |||
332 | return NULL; | 332 | return NULL; |
333 | 333 | ||
334 | (*idx)++; | 334 | (*idx)++; |
335 | evsel->cpus = cpu_map__get(cpus); | 335 | evsel->cpus = perf_cpu_map__get(cpus); |
336 | evsel->own_cpus = cpu_map__get(cpus); | 336 | evsel->own_cpus = perf_cpu_map__get(cpus); |
337 | evsel->system_wide = pmu ? pmu->is_uncore : false; | 337 | evsel->system_wide = pmu ? pmu->is_uncore : false; |
338 | evsel->auto_merge_stats = auto_merge_stats; | 338 | evsel->auto_merge_stats = auto_merge_stats; |
339 | 339 | ||
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 4929a50c0973..d355f9506a1c 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -626,7 +626,7 @@ static bool pmu_is_uncore(const char *name) | |||
626 | 626 | ||
627 | snprintf(path, PATH_MAX, CPUS_TEMPLATE_UNCORE, sysfs, name); | 627 | snprintf(path, PATH_MAX, CPUS_TEMPLATE_UNCORE, sysfs, name); |
628 | cpus = __pmu_cpumask(path); | 628 | cpus = __pmu_cpumask(path); |
629 | cpu_map__put(cpus); | 629 | perf_cpu_map__put(cpus); |
630 | 630 | ||
631 | return !!cpus; | 631 | return !!cpus; |
632 | } | 632 | } |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index cc4af99ab190..677c93f91c6c 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -557,7 +557,7 @@ static int pyrf_cpu_map__init(struct pyrf_cpu_map *pcpus, | |||
557 | 557 | ||
558 | static void pyrf_cpu_map__delete(struct pyrf_cpu_map *pcpus) | 558 | static void pyrf_cpu_map__delete(struct pyrf_cpu_map *pcpus) |
559 | { | 559 | { |
560 | cpu_map__put(pcpus->cpus); | 560 | perf_cpu_map__put(pcpus->cpus); |
561 | Py_TYPE(pcpus)->tp_free((PyObject*)pcpus); | 561 | Py_TYPE(pcpus)->tp_free((PyObject*)pcpus); |
562 | } | 562 | } |
563 | 563 | ||
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 9f8841548539..fecccfd71aa1 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c | |||
@@ -67,7 +67,7 @@ static bool perf_probe_api(setup_probe_fn_t fn) | |||
67 | if (!cpus) | 67 | if (!cpus) |
68 | return false; | 68 | return false; |
69 | cpu = cpus->map[0]; | 69 | cpu = cpus->map[0]; |
70 | cpu_map__put(cpus); | 70 | perf_cpu_map__put(cpus); |
71 | 71 | ||
72 | do { | 72 | do { |
73 | ret = perf_do_probe_api(fn, cpu, try[i++]); | 73 | ret = perf_do_probe_api(fn, cpu, try[i++]); |
@@ -122,7 +122,7 @@ bool perf_can_record_cpu_wide(void) | |||
122 | if (!cpus) | 122 | if (!cpus) |
123 | return false; | 123 | return false; |
124 | cpu = cpus->map[0]; | 124 | cpu = cpus->map[0]; |
125 | cpu_map__put(cpus); | 125 | perf_cpu_map__put(cpus); |
126 | 126 | ||
127 | fd = sys_perf_event_open(&attr, -1, cpu, -1, 0); | 127 | fd = sys_perf_event_open(&attr, -1, cpu, -1, 0); |
128 | if (fd < 0) | 128 | if (fd < 0) |
@@ -278,7 +278,7 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str) | |||
278 | struct perf_cpu_map *cpus = cpu_map__new(NULL); | 278 | struct perf_cpu_map *cpus = cpu_map__new(NULL); |
279 | 279 | ||
280 | cpu = cpus ? cpus->map[0] : 0; | 280 | cpu = cpus ? cpus->map[0] : 0; |
281 | cpu_map__put(cpus); | 281 | perf_cpu_map__put(cpus); |
282 | } else { | 282 | } else { |
283 | cpu = evlist->cpus->map[0]; | 283 | cpu = evlist->cpus->map[0]; |
284 | } | 284 | } |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c191dc152175..62d37440cbee 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -2310,7 +2310,7 @@ int perf_session__cpu_bitmap(struct perf_session *session, | |||
2310 | err = 0; | 2310 | err = 0; |
2311 | 2311 | ||
2312 | out_delete_map: | 2312 | out_delete_map: |
2313 | cpu_map__put(map); | 2313 | perf_cpu_map__put(map); |
2314 | return err; | 2314 | return err; |
2315 | } | 2315 | } |
2316 | 2316 | ||
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index 99132c6a30a6..a9ca5c4fffee 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c | |||
@@ -745,7 +745,7 @@ static int str_to_bitmap(char *s, cpumask_t *b) | |||
745 | set_bit(c, cpumask_bits(b)); | 745 | set_bit(c, cpumask_bits(b)); |
746 | } | 746 | } |
747 | 747 | ||
748 | cpu_map__put(m); | 748 | perf_cpu_map__put(m); |
749 | 749 | ||
750 | return ret; | 750 | return ret; |
751 | } | 751 | } |