• W
    perf bpf: Add sample types for 'bpf-output' event · d37ba880
    Wang Nan 提交于
    Before this patch we can see very large time in the events before the
    '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' info is not required because all events have the same
    sample_type.
    
    Committer notes:
    
    Further testing, on top of the changes making 'perf trace' avoid samples
    from events without PERF_SAMPLE_TIME:
    
    Before:
    
      # trace --ev bpf-output/no-inherit,name=evt/ --ev /home/acme/bpf/test_bpf_trace.c/map:channel.event=evt/ usleep 10
      <SNIP>
        0.560 ( 0.001 ms): brk(                                                   ) = 0x55e5a1df8000
        18446640227439.430 (18446640227438.859 ms): nanosleep(rqtp: 0x7ffc96643370) ...
        18446640227439.430 (         ): evt:Raise a BPF event!..)
        0.576 (         ): perf_bpf_probe:func_begin:(ffffffff81112460))
        18446640227439.430 (         ): evt:Raise a BPF event!..)
        0.645 (         ): perf_bpf_probe:func_end:(ffffffff81112460 <- ffffffff81003d92))
        0.646 ( 0.076 ms):  ... [continued]: nanosleep()) = 0
      #
    
    After:
    
      # trace --ev bpf-output/no-inherit,name=evt/ --ev /home/acme/bpf/test_bpf_trace.c/map:channel.event=evt/ usleep 10
      <SNIP>
         0.292 ( 0.001 ms): brk(                          ) = 0x55c7cd6e1000
         0.302 ( 0.004 ms): nanosleep(rqtp: 0x7ffedd8bc0f0) ...
         0.302 (         ): evt:Raise a BPF event!..)
         0.303 (         ): perf_bpf_probe:func_begin:(ffffffff81112460))
         0.397 (         ): evt:Raise a BPF event!..)
         0.397 (         ): perf_bpf_probe:func_end:(ffffffff81112460 <- ffffffff81003d92))
         0.398 ( 0.100 ms):  ... [continued]: nanosleep()) = 0
    Signed-off-by: NWang Nan <wangnan0@huawei.com>
    Reported-and-Tested-by: NArnaldo 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>
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1459517202-42320-1-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    d37ba880
evsel.c 58.9 KB