perf tools: Add support for PERF_RECORD_ITRACE_START
Add support for the PERF_RECORD_ITRACE_START event type. This event can be used to determine the pid and tid that are running when Instruction Tracing starts. Generally that information would come from a sched_switch event but, at the start, no sched_switch events may yet have been recorded. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1430404667-10593-8-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
4a96f7a02e
commit
0ad21f6869
@ -559,6 +559,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||
.exit = perf_event__repipe,
|
||||
.lost = perf_event__repipe,
|
||||
.aux = perf_event__repipe,
|
||||
.itrace_start = perf_event__repipe,
|
||||
.read = perf_event__repipe_sample,
|
||||
.throttle = perf_event__repipe,
|
||||
.unthrottle = perf_event__repipe,
|
||||
|
@ -24,6 +24,7 @@ static const char *perf_event__names[] = {
|
||||
[PERF_RECORD_READ] = "READ",
|
||||
[PERF_RECORD_SAMPLE] = "SAMPLE",
|
||||
[PERF_RECORD_AUX] = "AUX",
|
||||
[PERF_RECORD_ITRACE_START] = "ITRACE_START",
|
||||
[PERF_RECORD_HEADER_ATTR] = "ATTR",
|
||||
[PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE",
|
||||
[PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA",
|
||||
@ -704,6 +705,14 @@ int perf_event__process_aux(struct perf_tool *tool __maybe_unused,
|
||||
return machine__process_aux_event(machine, event);
|
||||
}
|
||||
|
||||
int perf_event__process_itrace_start(struct perf_tool *tool __maybe_unused,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample __maybe_unused,
|
||||
struct machine *machine)
|
||||
{
|
||||
return machine__process_itrace_start_event(machine, event);
|
||||
}
|
||||
|
||||
size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
|
||||
{
|
||||
return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %c %s\n",
|
||||
@ -776,6 +785,12 @@ size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp)
|
||||
event->aux.flags & PERF_AUX_FLAG_OVERWRITE ? "O" : "");
|
||||
}
|
||||
|
||||
size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp)
|
||||
{
|
||||
return fprintf(fp, " pid: %u tid: %u\n",
|
||||
event->itrace_start.pid, event->itrace_start.tid);
|
||||
}
|
||||
|
||||
size_t perf_event__fprintf(union perf_event *event, FILE *fp)
|
||||
{
|
||||
size_t ret = fprintf(fp, "PERF_RECORD_%s",
|
||||
@ -798,6 +813,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)
|
||||
case PERF_RECORD_AUX:
|
||||
ret += perf_event__fprintf_aux(event, fp);
|
||||
break;
|
||||
case PERF_RECORD_ITRACE_START:
|
||||
ret += perf_event__fprintf_itrace_start(event, fp);
|
||||
break;
|
||||
default:
|
||||
ret += fprintf(fp, "\n");
|
||||
}
|
||||
|
@ -330,6 +330,11 @@ struct aux_event {
|
||||
u64 flags;
|
||||
};
|
||||
|
||||
struct itrace_start_event {
|
||||
struct perf_event_header header;
|
||||
u32 pid, tid;
|
||||
};
|
||||
|
||||
union perf_event {
|
||||
struct perf_event_header header;
|
||||
struct mmap_event mmap;
|
||||
@ -349,6 +354,7 @@ union perf_event {
|
||||
struct auxtrace_event auxtrace;
|
||||
struct auxtrace_error_event auxtrace_error;
|
||||
struct aux_event aux;
|
||||
struct itrace_start_event itrace_start;
|
||||
};
|
||||
|
||||
void perf_event__print_totals(void);
|
||||
@ -388,6 +394,10 @@ int perf_event__process_aux(struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct machine *machine);
|
||||
int perf_event__process_itrace_start(struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct machine *machine);
|
||||
int perf_event__process_mmap(struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
@ -446,6 +456,7 @@ size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp);
|
||||
size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp);
|
||||
size_t perf_event__fprintf_task(union perf_event *event, FILE *fp);
|
||||
size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp);
|
||||
size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp);
|
||||
size_t perf_event__fprintf(union perf_event *event, FILE *fp);
|
||||
|
||||
u64 kallsyms__get_function_start(const char *kallsyms_filename,
|
||||
|
@ -494,6 +494,14 @@ int machine__process_aux_event(struct machine *machine __maybe_unused,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int machine__process_itrace_start_event(struct machine *machine __maybe_unused,
|
||||
union perf_event *event)
|
||||
{
|
||||
if (dump_trace)
|
||||
perf_event__fprintf_itrace_start(event, stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct map *machine__new_module(struct machine *machine, u64 start,
|
||||
const char *filename)
|
||||
{
|
||||
@ -1341,6 +1349,9 @@ int machine__process_event(struct machine *machine, union perf_event *event,
|
||||
ret = machine__process_lost_event(machine, event, sample); break;
|
||||
case PERF_RECORD_AUX:
|
||||
ret = machine__process_aux_event(machine, event); break;
|
||||
case PERF_RECORD_ITRACE_START:
|
||||
ret = machine__process_itrace_start_event(machine, event);
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
|
@ -83,6 +83,8 @@ int machine__process_lost_event(struct machine *machine, union perf_event *event
|
||||
struct perf_sample *sample);
|
||||
int machine__process_aux_event(struct machine *machine,
|
||||
union perf_event *event);
|
||||
int machine__process_itrace_start_event(struct machine *machine,
|
||||
union perf_event *event);
|
||||
int machine__process_mmap_event(struct machine *machine, union perf_event *event,
|
||||
struct perf_sample *sample);
|
||||
int machine__process_mmap2_event(struct machine *machine, union perf_event *event,
|
||||
|
@ -327,6 +327,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
|
||||
tool->lost = perf_event__process_lost;
|
||||
if (tool->aux == NULL)
|
||||
tool->aux = perf_event__process_aux;
|
||||
if (tool->itrace_start == NULL)
|
||||
tool->itrace_start = perf_event__process_itrace_start;
|
||||
if (tool->read == NULL)
|
||||
tool->read = process_event_sample_stub;
|
||||
if (tool->throttle == NULL)
|
||||
@ -455,6 +457,16 @@ static void perf_event__aux_swap(union perf_event *event, bool sample_id_all)
|
||||
swap_sample_id_all(event, &event->aux + 1);
|
||||
}
|
||||
|
||||
static void perf_event__itrace_start_swap(union perf_event *event,
|
||||
bool sample_id_all)
|
||||
{
|
||||
event->itrace_start.pid = bswap_32(event->itrace_start.pid);
|
||||
event->itrace_start.tid = bswap_32(event->itrace_start.tid);
|
||||
|
||||
if (sample_id_all)
|
||||
swap_sample_id_all(event, &event->itrace_start + 1);
|
||||
}
|
||||
|
||||
static void perf_event__throttle_swap(union perf_event *event,
|
||||
bool sample_id_all)
|
||||
{
|
||||
@ -593,6 +605,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
|
||||
[PERF_RECORD_UNTHROTTLE] = perf_event__throttle_swap,
|
||||
[PERF_RECORD_SAMPLE] = perf_event__all64_swap,
|
||||
[PERF_RECORD_AUX] = perf_event__aux_swap,
|
||||
[PERF_RECORD_ITRACE_START] = perf_event__itrace_start_swap,
|
||||
[PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap,
|
||||
[PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap,
|
||||
[PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
|
||||
@ -1044,6 +1057,8 @@ static int machines__deliver_event(struct machines *machines,
|
||||
return tool->unthrottle(tool, event, sample, machine);
|
||||
case PERF_RECORD_AUX:
|
||||
return tool->aux(tool, event, sample, machine);
|
||||
case PERF_RECORD_ITRACE_START:
|
||||
return tool->itrace_start(tool, event, sample, machine);
|
||||
default:
|
||||
++evlist->stats.nr_unknown_events;
|
||||
return -1;
|
||||
|
@ -44,6 +44,7 @@ struct perf_tool {
|
||||
exit,
|
||||
lost,
|
||||
aux,
|
||||
itrace_start,
|
||||
throttle,
|
||||
unthrottle;
|
||||
event_attr_op attr;
|
||||
|
Loading…
Reference in New Issue
Block a user