perf/events: Add flag to produce nsec output

libtraceevent library prints out in usecs but perf wants to print out
in nsecs. Add a flag that lets the user decide to print out in usec
or nsec times.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arun Sharma <asharma@fb.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
This commit is contained in:
Steven Rostedt 2012-04-06 00:47:57 +02:00 committed by Frederic Weisbecker
parent aaf045f723
commit 4dc1024a7a
3 changed files with 25 additions and 3 deletions

View File

@ -3940,15 +3940,16 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
struct event_format *event; struct event_format *event;
unsigned long secs; unsigned long secs;
unsigned long usecs; unsigned long usecs;
unsigned long nsecs;
const char *comm; const char *comm;
void *data = record->data; void *data = record->data;
int type; int type;
int pid; int pid;
int len; int len;
int p;
secs = record->ts / NSECS_PER_SEC; secs = record->ts / NSECS_PER_SEC;
usecs = record->ts - secs * NSECS_PER_SEC; nsecs = record->ts - secs * NSECS_PER_SEC;
usecs = (usecs + 500) / NSECS_PER_USEC;
if (record->size < 0) { if (record->size < 0) {
do_warning("ug! negative record size %d", record->size); do_warning("ug! negative record size %d", record->size);
@ -3973,7 +3974,15 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
} else } else
trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu); trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu);
trace_seq_printf(s, " %5lu.%06lu: %s: ", secs, usecs, event->name); if (pevent->flags & PEVENT_NSEC_OUTPUT) {
usecs = nsecs;
p = 9;
} else {
usecs = (nsecs + 500) / NSECS_PER_USEC;
p = 6;
}
trace_seq_printf(s, " %5lu.%0*lu: %s: ", secs, p, usecs, event->name);
/* Space out the event names evenly. */ /* Space out the event names evenly. */
len = strlen(event->name); len = strlen(event->name);

View File

@ -334,6 +334,10 @@ enum pevent_func_arg_type {
PEVENT_FUNC_ARG_MAX_TYPES PEVENT_FUNC_ARG_MAX_TYPES
}; };
enum pevent_flag {
PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */
};
struct cmdline; struct cmdline;
struct cmdline_list; struct cmdline_list;
struct func_map; struct func_map;
@ -373,6 +377,7 @@ struct pevent {
struct printk_list *printklist; struct printk_list *printklist;
unsigned int printk_count; unsigned int printk_count;
struct event_format **events; struct event_format **events;
int nr_events; int nr_events;
struct event_format **sort_events; struct event_format **sort_events;
@ -397,6 +402,8 @@ struct pevent {
int test_filters; int test_filters;
int flags;
struct format_field *bprint_ip_field; struct format_field *bprint_ip_field;
struct format_field *bprint_fmt_field; struct format_field *bprint_fmt_field;
struct format_field *bprint_buf_field; struct format_field *bprint_buf_field;
@ -408,6 +415,11 @@ struct pevent {
struct event_format *last_event; struct event_format *last_event;
}; };
static inline void pevent_set_flag(struct pevent *pevent, int flag)
{
pevent->flags |= flag;
}
static inline unsigned short static inline unsigned short
__data2host2(struct pevent *pevent, unsigned short data) __data2host2(struct pevent *pevent, unsigned short data)
{ {

View File

@ -45,6 +45,7 @@ int read_trace_init(int file_bigendian, int host_bigendian)
perf_pevent = pevent_alloc(); perf_pevent = pevent_alloc();
pevent = perf_pevent; pevent = perf_pevent;
pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
pevent_set_file_bigendian(pevent, file_bigendian); pevent_set_file_bigendian(pevent, file_bigendian);
pevent_set_host_bigendian(pevent, host_bigendian); pevent_set_host_bigendian(pevent, host_bigendian);