aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-12-18 17:15:48 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-01-24 14:40:12 -0500
commit876650e6c3209861a8949111140d805b3440951f (patch)
tree92923adf71a21512f20889c49ace7ed42b139f29 /tools/perf/util/session.c
parent28a6b6aa54878a6a239e901698b3fc111bbcc54f (diff)
perf machine: Introduce struct machines
That consolidates the grouping of host + guests, isolating a bit more of functionality now centered on 'perf_session' that can be used independently in tools that don't need a 'perf_session' instance, but needs to have all the thread/map/symbol machinery. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-c700rsiphpmzv8klogojpfut@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b0bcc328d1fb..046b057c8f7f 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -86,13 +86,12 @@ void perf_session__set_id_hdr_size(struct perf_session *session)
86{ 86{
87 u16 id_hdr_size = perf_evlist__id_hdr_size(session->evlist); 87 u16 id_hdr_size = perf_evlist__id_hdr_size(session->evlist);
88 88
89 session->host_machine.id_hdr_size = id_hdr_size;
90 machines__set_id_hdr_size(&session->machines, id_hdr_size); 89 machines__set_id_hdr_size(&session->machines, id_hdr_size);
91} 90}
92 91
93int perf_session__create_kernel_maps(struct perf_session *self) 92int perf_session__create_kernel_maps(struct perf_session *self)
94{ 93{
95 int ret = machine__create_kernel_maps(&self->host_machine); 94 int ret = machine__create_kernel_maps(&self->machines.host);
96 95
97 if (ret >= 0) 96 if (ret >= 0)
98 ret = machines__create_guest_kernel_maps(&self->machines); 97 ret = machines__create_guest_kernel_maps(&self->machines);
@@ -101,8 +100,7 @@ int perf_session__create_kernel_maps(struct perf_session *self)
101 100
102static void perf_session__destroy_kernel_maps(struct perf_session *self) 101static void perf_session__destroy_kernel_maps(struct perf_session *self)
103{ 102{
104 machine__destroy_kernel_maps(&self->host_machine); 103 machines__destroy_kernel_maps(&self->machines);
105 machines__destroy_guest_kernel_maps(&self->machines);
106} 104}
107 105
108struct perf_session *perf_session__new(const char *filename, int mode, 106struct perf_session *perf_session__new(const char *filename, int mode,
@@ -127,12 +125,11 @@ struct perf_session *perf_session__new(const char *filename, int mode,
127 goto out; 125 goto out;
128 126
129 memcpy(self->filename, filename, len); 127 memcpy(self->filename, filename, len);
130 self->machines = RB_ROOT;
131 self->repipe = repipe; 128 self->repipe = repipe;
132 INIT_LIST_HEAD(&self->ordered_samples.samples); 129 INIT_LIST_HEAD(&self->ordered_samples.samples);
133 INIT_LIST_HEAD(&self->ordered_samples.sample_cache); 130 INIT_LIST_HEAD(&self->ordered_samples.sample_cache);
134 INIT_LIST_HEAD(&self->ordered_samples.to_free); 131 INIT_LIST_HEAD(&self->ordered_samples.to_free);
135 machine__init(&self->host_machine, "", HOST_KERNEL_ID); 132 machines__init(&self->machines);
136 133
137 if (mode == O_RDONLY) { 134 if (mode == O_RDONLY) {
138 if (perf_session__open(self, force) < 0) 135 if (perf_session__open(self, force) < 0)
@@ -162,12 +159,12 @@ out_delete:
162 159
163static void perf_session__delete_dead_threads(struct perf_session *session) 160static void perf_session__delete_dead_threads(struct perf_session *session)
164{ 161{
165 machine__delete_dead_threads(&session->host_machine); 162 machine__delete_dead_threads(&session->machines.host);
166} 163}
167 164
168static void perf_session__delete_threads(struct perf_session *session) 165static void perf_session__delete_threads(struct perf_session *session)
169{ 166{
170 machine__delete_threads(&session->host_machine); 167 machine__delete_threads(&session->machines.host);
171} 168}
172 169
173static void perf_session_env__delete(struct perf_session_env *env) 170static void perf_session_env__delete(struct perf_session_env *env)
@@ -192,7 +189,7 @@ void perf_session__delete(struct perf_session *self)
192 perf_session__delete_dead_threads(self); 189 perf_session__delete_dead_threads(self);
193 perf_session__delete_threads(self); 190 perf_session__delete_threads(self);
194 perf_session_env__delete(&self->header.env); 191 perf_session_env__delete(&self->header.env);
195 machine__exit(&self->host_machine); 192 machines__exit(&self->machines);
196 close(self->fd); 193 close(self->fd);
197 free(self); 194 free(self);
198 vdso__exit(); 195 vdso__exit();
@@ -998,7 +995,7 @@ void perf_event_header__bswap(struct perf_event_header *self)
998 995
999struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) 996struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
1000{ 997{
1001 return machine__findnew_thread(&session->host_machine, pid); 998 return machine__findnew_thread(&session->machines.host, pid);
1002} 999}
1003 1000
1004static struct thread *perf_session__register_idle_thread(struct perf_session *self) 1001static struct thread *perf_session__register_idle_thread(struct perf_session *self)
@@ -1335,16 +1332,13 @@ int maps__set_kallsyms_ref_reloc_sym(struct map **maps,
1335 1332
1336size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp) 1333size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp)
1337{ 1334{
1338 return __dsos__fprintf(&self->host_machine.kernel_dsos, fp) + 1335 return machines__fprintf_dsos(&self->machines, fp);
1339 __dsos__fprintf(&self->host_machine.user_dsos, fp) +
1340 machines__fprintf_dsos(&self->machines, fp);
1341} 1336}
1342 1337
1343size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, 1338size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
1344 bool (skip)(struct dso *dso, int parm), int parm) 1339 bool (skip)(struct dso *dso, int parm), int parm)
1345{ 1340{
1346 size_t ret = machine__fprintf_dsos_buildid(&self->host_machine, fp, skip, parm); 1341 return machines__fprintf_dsos_buildid(&self->machines, fp, skip, parm);
1347 return ret + machines__fprintf_dsos_buildid(&self->machines, fp, skip, parm);
1348} 1342}
1349 1343
1350size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp) 1344size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
@@ -1368,7 +1362,7 @@ size_t perf_session__fprintf(struct perf_session *session, FILE *fp)
1368 * FIXME: Here we have to actually print all the machines in this 1362 * FIXME: Here we have to actually print all the machines in this
1369 * session, not just the host... 1363 * session, not just the host...
1370 */ 1364 */
1371 return machine__fprintf(&session->host_machine, fp); 1365 return machine__fprintf(&session->machines.host, fp);
1372} 1366}
1373 1367
1374void perf_session__remove_thread(struct perf_session *session, 1368void perf_session__remove_thread(struct perf_session *session,
@@ -1377,10 +1371,10 @@ void perf_session__remove_thread(struct perf_session *session,
1377 /* 1371 /*
1378 * FIXME: This one makes no sense, we need to remove the thread from 1372 * FIXME: This one makes no sense, we need to remove the thread from
1379 * the machine it belongs to, perf_session can have many machines, so 1373 * the machine it belongs to, perf_session can have many machines, so
1380 * doing it always on ->host_machine is wrong. Fix when auditing all 1374 * doing it always on ->machines.host is wrong. Fix when auditing all
1381 * the 'perf kvm' code. 1375 * the 'perf kvm' code.
1382 */ 1376 */
1383 machine__remove_thread(&session->host_machine, th); 1377 machine__remove_thread(&session->machines.host, th);
1384} 1378}
1385 1379
1386struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, 1380struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,