aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 85c1e6b76f0a..a76666f17767 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -139,9 +139,6 @@ struct perf_session *perf_session__new(const char *filename, int mode,
139 goto out; 139 goto out;
140 140
141 memcpy(self->filename, filename, len); 141 memcpy(self->filename, filename, len);
142 self->threads = RB_ROOT;
143 INIT_LIST_HEAD(&self->dead_threads);
144 self->last_match = NULL;
145 /* 142 /*
146 * On 64bit we can mmap the data file in one go. No need for tiny mmap 143 * On 64bit we can mmap the data file in one go. No need for tiny mmap
147 * slices. On 32bit we use 32MB. 144 * slices. On 32bit we use 32MB.
@@ -184,17 +181,22 @@ out_delete:
184 return NULL; 181 return NULL;
185} 182}
186 183
187static void perf_session__delete_dead_threads(struct perf_session *self) 184static void machine__delete_dead_threads(struct machine *machine)
188{ 185{
189 struct thread *n, *t; 186 struct thread *n, *t;
190 187
191 list_for_each_entry_safe(t, n, &self->dead_threads, node) { 188 list_for_each_entry_safe(t, n, &machine->dead_threads, node) {
192 list_del(&t->node); 189 list_del(&t->node);
193 thread__delete(t); 190 thread__delete(t);
194 } 191 }
195} 192}
196 193
197static void perf_session__delete_threads(struct perf_session *self) 194static void perf_session__delete_dead_threads(struct perf_session *session)
195{
196 machine__delete_dead_threads(&session->host_machine);
197}
198
199static void machine__delete_threads(struct machine *self)
198{ 200{
199 struct rb_node *nd = rb_first(&self->threads); 201 struct rb_node *nd = rb_first(&self->threads);
200 202
@@ -207,6 +209,11 @@ static void perf_session__delete_threads(struct perf_session *self)
207 } 209 }
208} 210}
209 211
212static void perf_session__delete_threads(struct perf_session *session)
213{
214 machine__delete_threads(&session->host_machine);
215}
216
210void perf_session__delete(struct perf_session *self) 217void perf_session__delete(struct perf_session *self)
211{ 218{
212 perf_session__destroy_kernel_maps(self); 219 perf_session__destroy_kernel_maps(self);
@@ -217,7 +224,7 @@ void perf_session__delete(struct perf_session *self)
217 free(self); 224 free(self);
218} 225}
219 226
220void perf_session__remove_thread(struct perf_session *self, struct thread *th) 227void machine__remove_thread(struct machine *self, struct thread *th)
221{ 228{
222 self->last_match = NULL; 229 self->last_match = NULL;
223 rb_erase(&th->rb_node, &self->threads); 230 rb_erase(&th->rb_node, &self->threads);
@@ -884,6 +891,11 @@ void perf_event_header__bswap(struct perf_event_header *self)
884 self->size = bswap_16(self->size); 891 self->size = bswap_16(self->size);
885} 892}
886 893
894struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
895{
896 return machine__findnew_thread(&session->host_machine, pid);
897}
898
887static struct thread *perf_session__register_idle_thread(struct perf_session *self) 899static struct thread *perf_session__register_idle_thread(struct perf_session *self)
888{ 900{
889 struct thread *thread = perf_session__findnew(self, 0); 901 struct thread *thread = perf_session__findnew(self, 0);
@@ -1224,6 +1236,27 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
1224 return ret; 1236 return ret;
1225} 1237}
1226 1238
1239size_t perf_session__fprintf(struct perf_session *session, FILE *fp)
1240{
1241 /*
1242 * FIXME: Here we have to actually print all the machines in this
1243 * session, not just the host...
1244 */
1245 return machine__fprintf(&session->host_machine, fp);
1246}
1247
1248void perf_session__remove_thread(struct perf_session *session,
1249 struct thread *th)
1250{
1251 /*
1252 * FIXME: This one makes no sense, we need to remove the thread from
1253 * the machine it belongs to, perf_session can have many machines, so
1254 * doing it always on ->host_machine is wrong. Fix when auditing all
1255 * the 'perf kvm' code.
1256 */
1257 machine__remove_thread(&session->host_machine, th);
1258}
1259
1227struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, 1260struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
1228 unsigned int type) 1261 unsigned int type)
1229{ 1262{