diff options
Diffstat (limited to 'tools/perf/util/thread.c')
-rw-r--r-- | tools/perf/util/thread.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 5c0ab14f3dba..634b7f7140d5 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -2,13 +2,11 @@ | |||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include "session.h" | ||
5 | #include "thread.h" | 6 | #include "thread.h" |
6 | #include "util.h" | 7 | #include "util.h" |
7 | #include "debug.h" | 8 | #include "debug.h" |
8 | 9 | ||
9 | static struct rb_root threads; | ||
10 | static struct thread *last_match; | ||
11 | |||
12 | void map_groups__init(struct map_groups *self) | 10 | void map_groups__init(struct map_groups *self) |
13 | { | 11 | { |
14 | int i; | 12 | int i; |
@@ -122,9 +120,9 @@ static size_t thread__fprintf(struct thread *self, FILE *fp) | |||
122 | map_groups__fprintf(&self->mg, fp); | 120 | map_groups__fprintf(&self->mg, fp); |
123 | } | 121 | } |
124 | 122 | ||
125 | struct thread *threads__findnew(pid_t pid) | 123 | struct thread *perf_session__findnew(struct perf_session *self, pid_t pid) |
126 | { | 124 | { |
127 | struct rb_node **p = &threads.rb_node; | 125 | struct rb_node **p = &self->threads.rb_node; |
128 | struct rb_node *parent = NULL; | 126 | struct rb_node *parent = NULL; |
129 | struct thread *th; | 127 | struct thread *th; |
130 | 128 | ||
@@ -133,15 +131,15 @@ struct thread *threads__findnew(pid_t pid) | |||
133 | * so most of the time we dont have to look up | 131 | * so most of the time we dont have to look up |
134 | * the full rbtree: | 132 | * the full rbtree: |
135 | */ | 133 | */ |
136 | if (last_match && last_match->pid == pid) | 134 | if (self->last_match && self->last_match->pid == pid) |
137 | return last_match; | 135 | return self->last_match; |
138 | 136 | ||
139 | while (*p != NULL) { | 137 | while (*p != NULL) { |
140 | parent = *p; | 138 | parent = *p; |
141 | th = rb_entry(parent, struct thread, rb_node); | 139 | th = rb_entry(parent, struct thread, rb_node); |
142 | 140 | ||
143 | if (th->pid == pid) { | 141 | if (th->pid == pid) { |
144 | last_match = th; | 142 | self->last_match = th; |
145 | return th; | 143 | return th; |
146 | } | 144 | } |
147 | 145 | ||
@@ -154,8 +152,8 @@ struct thread *threads__findnew(pid_t pid) | |||
154 | th = thread__new(pid); | 152 | th = thread__new(pid); |
155 | if (th != NULL) { | 153 | if (th != NULL) { |
156 | rb_link_node(&th->rb_node, parent, p); | 154 | rb_link_node(&th->rb_node, parent, p); |
157 | rb_insert_color(&th->rb_node, &threads); | 155 | rb_insert_color(&th->rb_node, &self->threads); |
158 | last_match = th; | 156 | self->last_match = th; |
159 | } | 157 | } |
160 | 158 | ||
161 | return th; | 159 | return th; |
@@ -269,12 +267,12 @@ int thread__fork(struct thread *self, struct thread *parent) | |||
269 | return 0; | 267 | return 0; |
270 | } | 268 | } |
271 | 269 | ||
272 | size_t threads__fprintf(FILE *fp) | 270 | size_t perf_session__fprintf(struct perf_session *self, FILE *fp) |
273 | { | 271 | { |
274 | size_t ret = 0; | 272 | size_t ret = 0; |
275 | struct rb_node *nd; | 273 | struct rb_node *nd; |
276 | 274 | ||
277 | for (nd = rb_first(&threads); nd; nd = rb_next(nd)) { | 275 | for (nd = rb_first(&self->threads); nd; nd = rb_next(nd)) { |
278 | struct thread *pos = rb_entry(nd, struct thread, rb_node); | 276 | struct thread *pos = rb_entry(nd, struct thread, rb_node); |
279 | 277 | ||
280 | ret += thread__fprintf(pos, fp); | 278 | ret += thread__fprintf(pos, fp); |