summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/machine.c
diff options
context:
space:
mode:
authorAdrian Hunter2014-07-31 08:00:45 +0200
committerArnaldo Carvalho de Melo2014-08-14 00:23:21 +0200
commitcfe1c41405fe9a559f8b3c24c904b2bb42d4a6e8 (patch)
treed0e4b647610f87702beb71287ba09dc998243ad5 /tools/perf/util/machine.c
parentperf tools: Identify which comms are from exec (diff)
downloadkernel-qcow2-linux-cfe1c41405fe9a559f8b3c24c904b2bb42d4a6e8.tar.gz
kernel-qcow2-linux-cfe1c41405fe9a559f8b3c24c904b2bb42d4a6e8.tar.xz
kernel-qcow2-linux-cfe1c41405fe9a559f8b3c24c904b2bb42d4a6e8.zip
perf machine: Add machine__thread_exec_comm()
Add machine__thread_exec_comm() to return the comm that matches the last exec, if the comm_exec flag is present, or the last comm otherwise. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> 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/r/1406786474-9306-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r--tools/perf/util/machine.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index ea3e09f6a9c6..b093b93607fb 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -31,6 +31,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
machine->symbol_filter = NULL;
machine->id_hdr_size = 0;
+ machine->comm_exec = false;
machine->root_dir = strdup(root_dir);
if (machine->root_dir == NULL)
@@ -179,6 +180,19 @@ void machines__set_symbol_filter(struct machines *machines,
}
}
+void machines__set_comm_exec(struct machines *machines, bool comm_exec)
+{
+ struct rb_node *nd;
+
+ machines->host.comm_exec = comm_exec;
+
+ for (nd = rb_first(&machines->guests); nd; nd = rb_next(nd)) {
+ struct machine *machine = rb_entry(nd, struct machine, rb_node);
+
+ machine->comm_exec = comm_exec;
+ }
+}
+
struct machine *machines__find(struct machines *machines, pid_t pid)
{
struct rb_node **p = &machines->guests.rb_node;
@@ -398,6 +412,15 @@ struct thread *machine__find_thread(struct machine *machine, pid_t pid,
return __machine__findnew_thread(machine, pid, tid, false);
}
+struct comm *machine__thread_exec_comm(struct machine *machine,
+ struct thread *thread)
+{
+ if (machine->comm_exec)
+ return thread__exec_comm(thread);
+ else
+ return thread__comm(thread);
+}
+
int machine__process_comm_event(struct machine *machine, union perf_event *event,
struct perf_sample *sample)
{
@@ -406,6 +429,9 @@ int machine__process_comm_event(struct machine *machine, union perf_event *event
event->comm.tid);
bool exec = event->header.misc & PERF_RECORD_MISC_COMM_EXEC;
+ if (exec)
+ machine->comm_exec = true;
+
if (dump_trace)
perf_event__fprintf_comm(event, stdout);