diff mbox

perf tools: Add sample types for bpf-output event

Message ID 1459517202-42320-1-git-send-email-wangnan0@huawei.com
State Accepted
Commit d37ba880598654fda10b312331377cdca3edd574
Headers show

Commit Message

Wang Nan April 1, 2016, 1:26 p.m. UTC
Before this patch we can see very large time in the events before
bpf-output event. For example:

 # ./perf trace -vv -T --ev sched:sched_switch \
                       --ev bpf-output/no-inherit,name=evt/ \
                       --ev ./test_bpf_trace.c/map:channel.event=evt/ \
                       usleep 10
 ...
 18446744073709.551 (18446564645918.480 ms): usleep/4157 nanosleep(rqtp: 0x7ffd3f0dc4e0                                        ) ...
 18446744073709.551 (         ): evt:Raise a BPF event!..)
 179427791.076 (         ): perf_bpf_probe:func_begin:(ffffffff810eb9a0))
 179427791.081 (         ): sched:sched_switch:usleep:4157 [120] S ==> swapper/2:0 [120])
 ...

We can also see the differences between bpf-output events and
breakpoint events:

For bpf output event:
   sample_type                    IP|TID|RAW|IDENTIFIER

For tracepoint events:
   sample_type                    IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER

This patch fix this differences by adding more sample type for
bpf-output events.

After this patch:

 # ./perf trace -vv -T --ev sched:sched_switch \
                       --ev bpf-output/no-inherit,name=evt/ \
                       --ev ./test_bpf_trace.c/map:channel.event=evt/ \
                       usleep 10
 ...
 179877370.878 ( 0.003 ms): usleep/5336 nanosleep(rqtp: 0x7ffff866c450                                        ) ...
 179877370.878 (         ): evt:Raise a BPF event!..)
 179877370.878 (         ): perf_bpf_probe:func_begin:(ffffffff810eb9a0))
 179877370.882 (         ): sched:sched_switch:usleep:5336 [120] S ==> swapper/4:0 [120])
 179877370.945 (         ): evt:Raise a BPF event!..)
 ...

 # ./perf trace -vv -T --ev sched:sched_switch \
                       --ev bpf-output/no-inherit,name=evt/ \
                       --ev ./test_bpf_trace.c/map:channel.event=evt/ \
                       usleep 10 2>&1 | grep sample_type
  sample_type                      IP|TID|TIME|ID|CPU|PERIOD|RAW
  sample_type                      IP|TID|TIME|ID|CPU|PERIOD|RAW
  sample_type                      IP|TID|TIME|ID|CPU|PERIOD|RAW
  sample_type                      IP|TID|TIME|ID|CPU|PERIOD|RAW
  sample_type                      IP|TID|TIME|ID|CPU|PERIOD|RAW
  sample_type                      IP|TID|TIME|ID|CPU|PERIOD|RAW

The 'IDENTIFIER' is not required because all events have the
same sample_type.

Signed-off-by: Wang Nan <wangnan0@huawei.com>

Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/evsel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
1.8.3.4
diff mbox

Patch

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 738ce22..3fd7c2c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -226,7 +226,8 @@  struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx)
 		perf_evsel__init(evsel, attr, idx);
 
 	if (perf_evsel__is_bpf_output(evsel)) {
-		evsel->attr.sample_type |= PERF_SAMPLE_RAW;
+		evsel->attr.sample_type |= (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
+					    PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD),
 		evsel->attr.sample_period = 1;
 	}