aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/thread.c')
-rw-r--r--tools/perf/util/thread.c41
1 files changed, 1 insertions, 40 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 8b3e5939afb6..df59623ac763 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -7,7 +7,7 @@
7#include "util.h" 7#include "util.h"
8#include "debug.h" 8#include "debug.h"
9 9
10static struct thread *thread__new(pid_t pid) 10struct thread *thread__new(pid_t pid)
11{ 11{
12 struct thread *self = zalloc(sizeof(*self)); 12 struct thread *self = zalloc(sizeof(*self));
13 13
@@ -60,45 +60,6 @@ static size_t thread__fprintf(struct thread *self, FILE *fp)
60 map_groups__fprintf(&self->mg, verbose, fp); 60 map_groups__fprintf(&self->mg, verbose, fp);
61} 61}
62 62
63struct thread *machine__findnew_thread(struct machine *self, pid_t pid)
64{
65 struct rb_node **p = &self->threads.rb_node;
66 struct rb_node *parent = NULL;
67 struct thread *th;
68
69 /*
70 * Font-end cache - PID lookups come in blocks,
71 * so most of the time we dont have to look up
72 * the full rbtree:
73 */
74 if (self->last_match && self->last_match->pid == pid)
75 return self->last_match;
76
77 while (*p != NULL) {
78 parent = *p;
79 th = rb_entry(parent, struct thread, rb_node);
80
81 if (th->pid == pid) {
82 self->last_match = th;
83 return th;
84 }
85
86 if (pid < th->pid)
87 p = &(*p)->rb_left;
88 else
89 p = &(*p)->rb_right;
90 }
91
92 th = thread__new(pid);
93 if (th != NULL) {
94 rb_link_node(&th->rb_node, parent, p);
95 rb_insert_color(&th->rb_node, &self->threads);
96 self->last_match = th;
97 }
98
99 return th;
100}
101
102void thread__insert_map(struct thread *self, struct map *map) 63void thread__insert_map(struct thread *self, struct map *map)
103{ 64{
104 map_groups__fixup_overlappings(&self->mg, map, verbose, stderr); 65 map_groups__fixup_overlappings(&self->mg, map, verbose, stderr);