aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2012-04-05 18:47:57 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2012-04-25 07:35:18 -0400
commit4dc1024a7a529626de5a800b10088bcbbc1ae941 (patch)
tree53100c8ed8b599568cc6f1f023e1a709d3eeda1f /tools
parentaaf045f72335653b24784d6042be8e4aee114403 (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/traceevent/event-parse.c15
-rw-r--r--tools/lib/traceevent/event-parse.h12
-rw-r--r--tools/perf/util/trace-event-parse.c1
3 files changed, 25 insertions, 3 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 3ce75b5d7612..c799c19f9340 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3940,15 +3940,16 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
3940 struct event_format *event; 3940 struct event_format *event;
3941 unsigned long secs; 3941 unsigned long secs;
3942 unsigned long usecs; 3942 unsigned long usecs;
3943 unsigned long nsecs;
3943 const char *comm; 3944 const char *comm;
3944 void *data = record->data; 3945 void *data = record->data;
3945 int type; 3946 int type;
3946 int pid; 3947 int pid;
3947 int len; 3948 int len;
3949 int p;
3948 3950
3949 secs = record->ts / NSECS_PER_SEC; 3951 secs = record->ts / NSECS_PER_SEC;
3950 usecs = record->ts - secs * NSECS_PER_SEC; 3952 nsecs = record->ts - secs * NSECS_PER_SEC;
3951 usecs = (usecs + 500) / NSECS_PER_USEC;
3952 3953
3953 if (record->size < 0) { 3954 if (record->size < 0) {
3954 do_warning("ug! negative record size %d", record->size); 3955 do_warning("ug! negative record size %d", record->size);
@@ -3973,7 +3974,15 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
3973 } else 3974 } else
3974 trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu); 3975 trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu);
3975 3976
3976 trace_seq_printf(s, " %5lu.%06lu: %s: ", secs, usecs, event->name); 3977 if (pevent->flags & PEVENT_NSEC_OUTPUT) {
3978 usecs = nsecs;
3979 p = 9;
3980 } else {
3981 usecs = (nsecs + 500) / NSECS_PER_USEC;
3982 p = 6;
3983 }
3984
3985 trace_seq_printf(s, " %5lu.%0*lu: %s: ", secs, p, usecs, event->name);
3977 3986
3978 /* Space out the event names evenly. */ 3987 /* Space out the event names evenly. */
3979 len = strlen(event->name); 3988 len = strlen(event->name);
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 2e0222dd3a8b..88528278f9aa 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -334,6 +334,10 @@ enum pevent_func_arg_type {
334 PEVENT_FUNC_ARG_MAX_TYPES 334 PEVENT_FUNC_ARG_MAX_TYPES
335}; 335};
336 336
337enum pevent_flag {
338 PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */
339};
340
337struct cmdline; 341struct cmdline;
338struct cmdline_list; 342struct cmdline_list;
339struct func_map; 343struct func_map;
@@ -373,6 +377,7 @@ struct pevent {
373 struct printk_list *printklist; 377 struct printk_list *printklist;
374 unsigned int printk_count; 378 unsigned int printk_count;
375 379
380
376 struct event_format **events; 381 struct event_format **events;
377 int nr_events; 382 int nr_events;
378 struct event_format **sort_events; 383 struct event_format **sort_events;
@@ -397,6 +402,8 @@ struct pevent {
397 402
398 int test_filters; 403 int test_filters;
399 404
405 int flags;
406
400 struct format_field *bprint_ip_field; 407 struct format_field *bprint_ip_field;
401 struct format_field *bprint_fmt_field; 408 struct format_field *bprint_fmt_field;
402 struct format_field *bprint_buf_field; 409 struct format_field *bprint_buf_field;
@@ -408,6 +415,11 @@ struct pevent {
408 struct event_format *last_event; 415 struct event_format *last_event;
409}; 416};
410 417
418static inline void pevent_set_flag(struct pevent *pevent, int flag)
419{
420 pevent->flags |= flag;
421}
422
411static inline unsigned short 423static inline unsigned short
412__data2host2(struct pevent *pevent, unsigned short data) 424__data2host2(struct pevent *pevent, unsigned short data)
413{ 425{
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 4ec165a334e2..39f22f8843a2 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -45,6 +45,7 @@ int read_trace_init(int file_bigendian, int host_bigendian)
45 perf_pevent = pevent_alloc(); 45 perf_pevent = pevent_alloc();
46 pevent = perf_pevent; 46 pevent = perf_pevent;
47 47
48 pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
48 pevent_set_file_bigendian(pevent, file_bigendian); 49 pevent_set_file_bigendian(pevent, file_bigendian);
49 pevent_set_host_bigendian(pevent, host_bigendian); 50 pevent_set_host_bigendian(pevent, host_bigendian);
50 51