linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Add sample types for bpf-output event
@ 2016-04-01 13:26 Wang Nan
  2016-04-01 15:16 ` Arnaldo Carvalho de Melo
  2016-04-06  7:10 ` [tip:perf/core] perf bpf: Add sample types for 'bpf-output' event tip-bot for Wang Nan
  0 siblings, 2 replies; 4+ messages in thread
From: Wang Nan @ 2016-04-01 13:26 UTC (permalink / raw)
  To: acme
  Cc: linux-kernel, pi3orama, Wang Nan, Arnaldo Carvalho de Melo,
	Adrian Hunter, David Ahern, Jiri Olsa, Milian Wolff,
	Namhyung Kim

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(-)

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;
 	}
 
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-06  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-01 13:26 [PATCH] perf tools: Add sample types for bpf-output event Wang Nan
2016-04-01 15:16 ` Arnaldo Carvalho de Melo
2016-04-01 15:19   ` Arnaldo Carvalho de Melo
2016-04-06  7:10 ` [tip:perf/core] perf bpf: Add sample types for 'bpf-output' event tip-bot for Wang Nan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).