summaryrefslogtreecommitdiff
path: root/tools/perf/util
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2019-07-21 13:24:20 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-07-29 18:34:44 -0300
commit7836e52e518b5e3fd695850f1d4081f756f58406 (patch)
tree0dd7986d87a1a7065be0eb472928a648b8825d09 /tools/perf/util
parent4b49cce25e719587e934b745fe9bbb5bc8c4ba29 (diff)
libperf: Add perf_thread_map__get()/perf_thread_map__put()
Move the following functions: thread_map__get() thread_map__put() thread_map__comm() to libperf with the following names: perf_thread_map__get() perf_thread_map__put() perf_thread_map__comm() Add the perf_thread_map__comm() function for it to work/compile. 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-34-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/event.c4
-rw-r--r--tools/perf/util/evlist.c12
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/parse-events.c2
-rw-r--r--tools/perf/util/python.c2
-rw-r--r--tools/perf/util/stat-display.c2
-rw-r--r--tools/perf/util/thread_map.c26
-rw-r--r--tools/perf/util/thread_map.h8
8 files changed, 12 insertions, 46 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 1a3db35f9f7d..f440fdc3e953 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -992,7 +992,7 @@ int perf_event__synthesize_thread_map2(struct perf_tool *tool,
for (i = 0; i < threads->nr; i++) {
struct thread_map_event_entry *entry = &event->thread_map.entries[i];
- char *comm = thread_map__comm(threads, i);
+ char *comm = perf_thread_map__comm(threads, i);
if (!comm)
comm = (char *) "";
@@ -1387,7 +1387,7 @@ size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp)
else
ret += fprintf(fp, "failed to get threads from event\n");
- thread_map__put(threads);
+ perf_thread_map__put(threads);
return ret;
}
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 88d131769df4..38a3c6d16b4b 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -142,7 +142,7 @@ void evlist__delete(struct evlist *evlist)
perf_evlist__munmap(evlist);
evlist__close(evlist);
perf_cpu_map__put(evlist->cpus);
- thread_map__put(evlist->threads);
+ perf_thread_map__put(evlist->threads);
evlist->cpus = NULL;
evlist->threads = NULL;
perf_evlist__purge(evlist);
@@ -165,8 +165,8 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,
evsel->cpus = perf_cpu_map__get(evsel->own_cpus);
}
- thread_map__put(evsel->threads);
- evsel->threads = thread_map__get(evlist->threads);
+ perf_thread_map__put(evsel->threads);
+ evsel->threads = perf_thread_map__get(evlist->threads);
}
static void perf_evlist__propagate_maps(struct evlist *evlist)
@@ -1100,7 +1100,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)
return 0;
out_delete_threads:
- thread_map__put(threads);
+ perf_thread_map__put(threads);
return -1;
}
@@ -1120,8 +1120,8 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus,
}
if (threads != evlist->threads) {
- thread_map__put(evlist->threads);
- evlist->threads = thread_map__get(threads);
+ perf_thread_map__put(evlist->threads);
+ evlist->threads = perf_thread_map__get(threads);
}
perf_evlist__propagate_maps(evlist);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 72c0e6948e83..652e53279b28 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1327,7 +1327,7 @@ void perf_evsel__exit(struct evsel *evsel)
cgroup__put(evsel->cgrp);
perf_cpu_map__put(evsel->cpus);
perf_cpu_map__put(evsel->own_cpus);
- thread_map__put(evsel->threads);
+ perf_thread_map__put(evsel->threads);
zfree(&evsel->group_name);
zfree(&evsel->name);
perf_evsel__object.fini(evsel);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 8c9928feb38a..38eeca6fa1fc 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2337,7 +2337,7 @@ static bool is_event_supported(u8 type, unsigned config)
evsel__delete(evsel);
}
- thread_map__put(tmap);
+ perf_thread_map__put(tmap);
return ret;
}
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 677c93f91c6c..19d2feee91d5 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -626,7 +626,7 @@ static int pyrf_thread_map__init(struct pyrf_thread_map *pthreads,
static void pyrf_thread_map__delete(struct pyrf_thread_map *pthreads)
{
- thread_map__put(pthreads->threads);
+ perf_thread_map__put(pthreads->threads);
Py_TYPE(pthreads)->tp_free((PyObject*)pthreads);
}
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index f7666d2e6e0c..1f099823a1f9 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -116,7 +116,7 @@ static void aggr_printout(struct perf_stat_config *config,
case AGGR_THREAD:
fprintf(config->output, "%*s-%*d%s",
config->csv_output ? 0 : 16,
- thread_map__comm(evsel->threads, id),
+ perf_thread_map__comm(evsel->threads, id),
config->csv_output ? 0 : -8,
thread_map__pid(evsel->threads, id),
config->csv_sep);
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index 06dd9f2e4ce5..c58385ea05be 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -304,32 +304,6 @@ struct perf_thread_map *thread_map__new_str(const char *pid, const char *tid,
return thread_map__new_by_tid_str(tid);
}
-static void thread_map__delete(struct perf_thread_map *threads)
-{
- if (threads) {
- int i;
-
- WARN_ONCE(refcount_read(&threads->refcnt) != 0,
- "thread map refcnt unbalanced\n");
- for (i = 0; i < threads->nr; i++)
- free(thread_map__comm(threads, i));
- free(threads);
- }
-}
-
-struct perf_thread_map *thread_map__get(struct perf_thread_map *map)
-{
- if (map)
- refcount_inc(&map->refcnt);
- return map;
-}
-
-void thread_map__put(struct perf_thread_map *map)
-{
- if (map && refcount_dec_and_test(&map->refcnt))
- thread_map__delete(map);
-}
-
size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp)
{
int i;
diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h
index 94a1f9565f5e..ba45c760be72 100644
--- a/tools/perf/util/thread_map.h
+++ b/tools/perf/util/thread_map.h
@@ -18,9 +18,6 @@ struct perf_thread_map *thread_map__new_all_cpus(void);
struct perf_thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid);
struct perf_thread_map *thread_map__new_event(struct thread_map_event *event);
-struct perf_thread_map *thread_map__get(struct perf_thread_map *map);
-void thread_map__put(struct perf_thread_map *map);
-
struct perf_thread_map *thread_map__new_str(const char *pid,
const char *tid, uid_t uid, bool all_threads);
@@ -38,11 +35,6 @@ static inline pid_t thread_map__pid(struct perf_thread_map *map, int thread)
return map->map[thread].pid;
}
-static inline char *thread_map__comm(struct perf_thread_map *map, int thread)
-{
- return map->map[thread].comm;
-}
-
void thread_map__read_comms(struct perf_thread_map *threads);
bool thread_map__has(struct perf_thread_map *threads, pid_t pid);
int thread_map__remove(struct perf_thread_map *threads, int idx);