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>
This commit is contained in:
Родитель
65de51f93e
Коммит
cfe1c41405
|
@ -31,6 +31,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
|
||||||
|
|
||||||
machine->symbol_filter = NULL;
|
machine->symbol_filter = NULL;
|
||||||
machine->id_hdr_size = 0;
|
machine->id_hdr_size = 0;
|
||||||
|
machine->comm_exec = false;
|
||||||
|
|
||||||
machine->root_dir = strdup(root_dir);
|
machine->root_dir = strdup(root_dir);
|
||||||
if (machine->root_dir == NULL)
|
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 machine *machines__find(struct machines *machines, pid_t pid)
|
||||||
{
|
{
|
||||||
struct rb_node **p = &machines->guests.rb_node;
|
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);
|
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,
|
int machine__process_comm_event(struct machine *machine, union perf_event *event,
|
||||||
struct perf_sample *sample)
|
struct perf_sample *sample)
|
||||||
{
|
{
|
||||||
|
@ -406,6 +429,9 @@ int machine__process_comm_event(struct machine *machine, union perf_event *event
|
||||||
event->comm.tid);
|
event->comm.tid);
|
||||||
bool exec = event->header.misc & PERF_RECORD_MISC_COMM_EXEC;
|
bool exec = event->header.misc & PERF_RECORD_MISC_COMM_EXEC;
|
||||||
|
|
||||||
|
if (exec)
|
||||||
|
machine->comm_exec = true;
|
||||||
|
|
||||||
if (dump_trace)
|
if (dump_trace)
|
||||||
perf_event__fprintf_comm(event, stdout);
|
perf_event__fprintf_comm(event, stdout);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct machine {
|
||||||
struct rb_node rb_node;
|
struct rb_node rb_node;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
u16 id_hdr_size;
|
u16 id_hdr_size;
|
||||||
|
bool comm_exec;
|
||||||
char *root_dir;
|
char *root_dir;
|
||||||
struct rb_root threads;
|
struct rb_root threads;
|
||||||
struct list_head dead_threads;
|
struct list_head dead_threads;
|
||||||
|
@ -47,6 +48,8 @@ struct map *machine__kernel_map(struct machine *machine, enum map_type type)
|
||||||
|
|
||||||
struct thread *machine__find_thread(struct machine *machine, pid_t pid,
|
struct thread *machine__find_thread(struct machine *machine, pid_t pid,
|
||||||
pid_t tid);
|
pid_t tid);
|
||||||
|
struct comm *machine__thread_exec_comm(struct machine *machine,
|
||||||
|
struct thread *thread);
|
||||||
|
|
||||||
int machine__process_comm_event(struct machine *machine, union perf_event *event,
|
int machine__process_comm_event(struct machine *machine, union perf_event *event,
|
||||||
struct perf_sample *sample);
|
struct perf_sample *sample);
|
||||||
|
@ -88,6 +91,7 @@ char *machine__mmap_name(struct machine *machine, char *bf, size_t size);
|
||||||
|
|
||||||
void machines__set_symbol_filter(struct machines *machines,
|
void machines__set_symbol_filter(struct machines *machines,
|
||||||
symbol_filter_t symbol_filter);
|
symbol_filter_t symbol_filter);
|
||||||
|
void machines__set_comm_exec(struct machines *machines, bool comm_exec);
|
||||||
|
|
||||||
struct machine *machine__new_host(void);
|
struct machine *machine__new_host(void);
|
||||||
int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
|
int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
|
||||||
|
|
|
@ -67,6 +67,25 @@ static void perf_session__destroy_kernel_maps(struct perf_session *session)
|
||||||
machines__destroy_kernel_maps(&session->machines);
|
machines__destroy_kernel_maps(&session->machines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool perf_session__has_comm_exec(struct perf_session *session)
|
||||||
|
{
|
||||||
|
struct perf_evsel *evsel;
|
||||||
|
|
||||||
|
evlist__for_each(session->evlist, evsel) {
|
||||||
|
if (evsel->attr.comm_exec)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void perf_session__set_comm_exec(struct perf_session *session)
|
||||||
|
{
|
||||||
|
bool comm_exec = perf_session__has_comm_exec(session);
|
||||||
|
|
||||||
|
machines__set_comm_exec(&session->machines, comm_exec);
|
||||||
|
}
|
||||||
|
|
||||||
struct perf_session *perf_session__new(struct perf_data_file *file,
|
struct perf_session *perf_session__new(struct perf_data_file *file,
|
||||||
bool repipe, struct perf_tool *tool)
|
bool repipe, struct perf_tool *tool)
|
||||||
{
|
{
|
||||||
|
@ -90,6 +109,7 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
|
||||||
goto out_close;
|
goto out_close;
|
||||||
|
|
||||||
perf_session__set_id_hdr_size(session);
|
perf_session__set_id_hdr_size(session);
|
||||||
|
perf_session__set_comm_exec(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,8 +886,10 @@ static s64 perf_session__process_user_event(struct perf_session *session,
|
||||||
switch (event->header.type) {
|
switch (event->header.type) {
|
||||||
case PERF_RECORD_HEADER_ATTR:
|
case PERF_RECORD_HEADER_ATTR:
|
||||||
err = tool->attr(tool, event, &session->evlist);
|
err = tool->attr(tool, event, &session->evlist);
|
||||||
if (err == 0)
|
if (err == 0) {
|
||||||
perf_session__set_id_hdr_size(session);
|
perf_session__set_id_hdr_size(session);
|
||||||
|
perf_session__set_comm_exec(session);
|
||||||
|
}
|
||||||
return err;
|
return err;
|
||||||
case PERF_RECORD_HEADER_EVENT_TYPE:
|
case PERF_RECORD_HEADER_EVENT_TYPE:
|
||||||
/*
|
/*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче