aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/perf/threadmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/perf/threadmap.c')
-rw-r--r--tools/lib/perf/threadmap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/lib/perf/threadmap.c b/tools/lib/perf/threadmap.c
index 3ca9ba4987fc..db431b036f57 100644
--- a/tools/lib/perf/threadmap.c
+++ b/tools/lib/perf/threadmap.c
@@ -104,3 +104,15 @@ pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx)
return map->map[idx].pid;
}
+
+int perf_thread_map__idx(struct perf_thread_map *threads, pid_t pid)
+{
+ if (!threads)
+ return pid == -1 ? 0 : -1;
+
+ for (int i = 0; i < threads->nr; ++i) {
+ if (threads->map[i].pid == pid)
+ return i;
+ }
+ return -1;
+}