perf thread_map: Add has() method
authorJiri Olsa <jolsa@kernel.org>
Tue, 12 Apr 2016 13:29:24 +0000 (15:29 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 13 Apr 2016 13:11:50 +0000 (10:11 -0300)
Adding thread_map__has() to return bool of pid presence in threads map.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460467771-26532-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/thread_map.c
tools/perf/util/thread_map.h

index 267112b..878ac06 100644 (file)
@@ -436,3 +436,15 @@ struct thread_map *thread_map__new_event(struct thread_map_event *event)
 
        return threads;
 }
+
+bool thread_map__has(struct thread_map *threads, pid_t pid)
+{
+       int i;
+
+       for (i = 0; i < threads->nr; ++i) {
+               if (threads->map[i].pid == pid)
+                       return true;
+       }
+
+       return false;
+}
index 85e4c7c..9a065ea 100644 (file)
@@ -55,4 +55,5 @@ static inline char *thread_map__comm(struct thread_map *map, int thread)
 }
 
 void thread_map__read_comms(struct thread_map *threads);
+bool thread_map__has(struct thread_map *threads, pid_t pid);
 #endif /* __PERF_THREAD_MAP_H */