aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/thread.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-13 16:50:28 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-14 10:57:16 -0500
commitb3165f414416a717f72a376720564012af5a2e01 (patch)
treeb066e4ae00b7d4bdb7386f4054e6e3ace0b976c3 /tools/perf/util/thread.c
parentec913369733923dbfd6bdff5953a918107059701 (diff)
perf session: Move the global threads list to perf_session
So that we can process two perf.data files. We still need to add a O_MMAP mode for perf_session so that we can do all the mmap stuff in it. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1260741029-4430-5-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/thread.c')
-rw-r--r--tools/perf/util/thread.c22
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
9static struct rb_root threads;
10static struct thread *last_match;
11
12void map_groups__init(struct map_groups *self) 10void 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
125struct thread *threads__findnew(pid_t pid) 123struct 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
272size_t threads__fprintf(FILE *fp) 270size_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);