1. 25 1月, 2019 7 次提交
  2. 22 1月, 2019 25 次提交
    • I
      Merge tag 'perf-core-for-mingo-5.0-20190121' of... · f575494d
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo-5.0-20190121' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      BPF:
      
        Song Liu:
      
        - Introduce PERF_RECORD_KSYMBOL to allow tooling to notice the addition
          of new kernel symbols and be able to resolve samples in such symbols.
      
        - Introduce PERF_RECORD_BPF_EVENT to notify tooling about the loading
          and unloading of BPF programs, making them visible and allowing for
          the request of further information to allow for things like annotation.
      
        - Change the userspace perf tools to handle those new events and to
          synthesize them for pre-existing loaded BPF programs.
      
      Kernel:
      
        Arnaldo Carvalho de Melo:
      
        - Make perf_event_output() propagate the output() return, allowing
          users to check for -ENOSPC in the ring buffer.
      
      perf report:
      
        Thomas Richter:
      
        - Display arch specific diagnostic counter sets, starting with s390
          diagnostic counter sets.
      
      perf session:
      
        Jiri Olsa:
      
        - Introduce a reader object to prep for multithreaded processing
          of recorded events.
      
      Misc:
      
        Rasmus Villemoes:
      
        - Replace automatic const char[] variables by statics, to avoid
          initializing them at runtime, instead having them in .rodata,
          reducing code size.
      
        YueHaibing:
      
        - Remove duplicated workqueue.h include from perf_event.h
      
        Brajeswar Ghosh:
      
        - Remove some more duplicated headers.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      f575494d
    • A
      perf utils: Move perf_config using routines from color.c to separate object · 32e9136e
      Arnaldo Carvalho de Melo 提交于
      To untangle objects a bit more, avoiding rebuilding the color_fprintf
      routines when changes are made to the perf config headers.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: https://lkml.kernel.org/n/tip-8qvu2ek26antm3a8jyl4ocbq@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      32e9136e
    • A
      perf python: Remove -fstack-clash-protection when building with some clang versions · a5dcc4ca
      Arnaldo Carvalho de Melo 提交于
      These options are not present in some (all?) clang versions, so when we
      build for a distro that has a gcc new enough to have these options and
      that the distro python build config settings use them but clang doesn't
      support, b00m.
      
      This is the case with fedora rawhide (now gearing towards f30), so check
      if clang has the  and remove the missing ones from CFLAGS.
      
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Thiago Macieira <thiago.macieira@intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-5q50q9w458yawgxf9ez54jbp@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a5dcc4ca
    • S
      bpf: Add module name [bpf] to ksymbols for bpf programs · 6934058d
      Song Liu 提交于
      With this patch, /proc/kallsyms will show BPF programs as
      
        <addr> t bpf_prog_<tag>_<name> [bpf]
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-10-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6934058d
    • A
      perf top: Synthesize BPF events for pre-existing loaded BPF programs · a40b95bc
      Arnaldo Carvalho de Melo 提交于
      So that we can resolve symbols and map names.
      
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-9-songliubraving@fb.comSigned-off-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a40b95bc
    • S
      perf tools: Synthesize PERF_RECORD_* for loaded BPF programs · 7b612e29
      Song Liu 提交于
      This patch synthesize PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT for
      BPF programs loaded before perf-record. This is achieved by gathering
      information about all BPF programs via sys_bpf.
      
      Committer notes:
      
      Fix the build on some older systems such as amazonlinux:1 where it was
      breaking with:
      
        util/bpf-event.c: In function 'perf_event__synthesize_one_bpf_prog':
        util/bpf-event.c:52:9: error: missing initializer for field 'type' of 'struct bpf_prog_info' [-Werror=missing-field-initializers]
          struct bpf_prog_info info = {};
                 ^
        In file included from /git/linux/tools/lib/bpf/bpf.h:26:0,
                         from util/bpf-event.c:3:
        /git/linux/tools/include/uapi/linux/bpf.h:2699:8: note: 'type' declared here
          __u32 type;
                ^
        cc1: all warnings being treated as errors
      
      Further fix on a centos:6 system:
      
        cc1: warnings being treated as errors
        util/bpf-event.c: In function 'perf_event__synthesize_one_bpf_prog':
        util/bpf-event.c:50: error: 'func_info_rec_size' may be used uninitialized in this function
      
      The compiler is wrong, but to silence it, initialize that variable to
      zero.
      
      One more fix, this time for debian:experimental-x-mips, x-mips64 and
      x-mipsel:
      
        util/bpf-event.c: In function 'perf_event__synthesize_one_bpf_prog':
        util/bpf-event.c:93:16: error: implicit declaration of function 'calloc' [-Werror=implicit-function-declaration]
           func_infos = calloc(sub_prog_cnt, func_info_rec_size);
                        ^~~~~~
        util/bpf-event.c:93:16: error: incompatible implicit declaration of built-in function 'calloc' [-Werror]
        util/bpf-event.c:93:16: note: include '<stdlib.h>' or provide a declaration of 'calloc'
      
      Add the missing header.
      
      Committer testing:
      
        # perf record --bpf-event sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.021 MB perf.data (7 samples) ]
        # perf report -D | grep PERF_RECORD_BPF_EVENT | nl
           1	0 0x4b10 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 13
           2	0 0x4c60 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 14
           3	0 0x4db0 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 15
           4	0 0x4f00 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 16
           5	0 0x5050 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 17
           6	0 0x51a0 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 18
           7	0 0x52f0 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 21
           8	0 0x5440 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 22
        # bpftool prog
        13: cgroup_skb  tag 7be49e3934a125ba  gpl
      	loaded_at 2019-01-19T09:09:43-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 13,14
        14: cgroup_skb  tag 2a142ef67aaad174  gpl
      	loaded_at 2019-01-19T09:09:43-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 13,14
        15: cgroup_skb  tag 7be49e3934a125ba  gpl
      	loaded_at 2019-01-19T09:09:43-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 15,16
        16: cgroup_skb  tag 2a142ef67aaad174  gpl
      	loaded_at 2019-01-19T09:09:43-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 15,16
        17: cgroup_skb  tag 7be49e3934a125ba  gpl
      	loaded_at 2019-01-19T09:09:44-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 17,18
        18: cgroup_skb  tag 2a142ef67aaad174  gpl
      	loaded_at 2019-01-19T09:09:44-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 17,18
        21: cgroup_skb  tag 7be49e3934a125ba  gpl
      	loaded_at 2019-01-19T09:09:45-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 21,22
        22: cgroup_skb  tag 2a142ef67aaad174  gpl
      	loaded_at 2019-01-19T09:09:45-0300  uid 0
      	xlated 296B  jited 229B  memlock 4096B  map_ids 21,22
        #
      
        # perf report -D | grep -B22 PERF_RECORD_KSYMBOL
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 ff 44 06 c0 ff ff ff ff  ......8..D......
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 37 62 65 34 39 65 33 39 33 34 61 31 32 35 62  _7be49e3934a125b
        .  0030:  61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  a...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  7b e4 9e 39 34 a1 25 ba 00 00 00 00 00 00 00 00  {..94.%.........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x49d8 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc00644ff len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba
        --
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 48 6d 06 c0 ff ff ff ff  ......8.Hm......
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 32 61 31 34 32 65 66 36 37 61 61 61 64 31 37  _2a142ef67aaad17
        .  0030:  34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  4...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  2a 14 2e f6 7a aa d1 74 00 00 00 00 00 00 00 00  *...z..t........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x4b28 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0066d48 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174
        --
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 04 cf 03 c0 ff ff ff ff  ......8.........
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 37 62 65 34 39 65 33 39 33 34 61 31 32 35 62  _7be49e3934a125b
        .  0030:  61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  a...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  7b e4 9e 39 34 a1 25 ba 00 00 00 00 00 00 00 00  {..94.%.........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x4c78 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc003cf04 len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba
        --
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 96 28 04 c0 ff ff ff ff  ......8..(......
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 32 61 31 34 32 65 66 36 37 61 61 61 64 31 37  _2a142ef67aaad17
        .  0030:  34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  4...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  2a 14 2e f6 7a aa d1 74 00 00 00 00 00 00 00 00  *...z..t........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x4dc8 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0042896 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174
        --
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 05 13 17 c0 ff ff ff ff  ......8.........
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 37 62 65 34 39 65 33 39 33 34 61 31 32 35 62  _7be49e3934a125b
        .  0030:  61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  a...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  7b e4 9e 39 34 a1 25 ba 00 00 00 00 00 00 00 00  {..94.%.........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x4f18 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0171305 len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba
        --
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 0a 8c 23 c0 ff ff ff ff  ......8...#.....
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 32 61 31 34 32 65 66 36 37 61 61 61 64 31 37  _2a142ef67aaad17
        .  0030:  34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  4...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  2a 14 2e f6 7a aa d1 74 00 00 00 00 00 00 00 00  *...z..t........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x5068 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0238c0a len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174
        --
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 2a a5 a4 c0 ff ff ff ff  ......8.*.......
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 37 62 65 34 39 65 33 39 33 34 61 31 32 35 62  _7be49e3934a125b
        .  0030:  61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  a...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  7b e4 9e 39 34 a1 25 ba 00 00 00 00 00 00 00 00  {..94.%.........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x51b8 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0a4a52a len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba
        --
        . ... raw event: size 312 bytes
        .  0000:  11 00 00 00 00 00 38 01 9b c9 a4 c0 ff ff ff ff  ......8.........
        .  0010:  e5 00 00 00 01 00 00 00 62 70 66 5f 70 72 6f 67  ........bpf_prog
        .  0020:  5f 32 61 31 34 32 65 66 36 37 61 61 61 64 31 37  _2a142ef67aaad17
        .  0030:  34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  4...............
         <SNIP zeroes>
        .  0110:  00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00  ........!.......
        .  0120:  2a 14 2e f6 7a aa d1 74 00 00 00 00 00 00 00 00  *...z..t........
        .  0130:  00 00 00 00 00 00 00 00                          ........
      
        0 0x5308 [0x138]: PERF_RECORD_KSYMBOL ksymbol event with addr ffffffffc0a4c99b len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-8-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b612e29
    • S
      perf tools: Handle PERF_RECORD_BPF_EVENT · 45178a92
      Song Liu 提交于
      This patch adds basic handling of PERF_RECORD_BPF_EVENT.  Tracking of
      PERF_RECORD_BPF_EVENT is OFF by default. Option --bpf-event is added to
      turn it on.
      
      Committer notes:
      
      Add dummy machine__process_bpf_event() variant that returns zero for
      systems without HAVE_LIBBPF_SUPPORT, such as Alpine Linux, unbreaking
      the build in such systems.
      
      Remove the needless include <machine.h> from bpf->event.h, provide just
      forward declarations for the structs and unions in the parameters, to
      reduce compilation time and needless rebuilds when machine.h gets
      changed.
      
      Committer testing:
      
      When running with:
      
       # perf record --bpf-event
      
      On an older kernel where PERF_RECORD_BPF_EVENT and PERF_RECORD_KSYMBOL
      is not present, we fallback to removing those two bits from
      perf_event_attr, making the tool to continue to work on older kernels:
      
        perf_event_attr:
          size                             112
          { sample_period, sample_freq }   4000
          sample_type                      IP|TID|TIME|PERIOD
          read_format                      ID
          disabled                         1
          inherit                          1
          mmap                             1
          comm                             1
          freq                             1
          enable_on_exec                   1
          task                             1
          precise_ip                       3
          sample_id_all                    1
          exclude_guest                    1
          mmap2                            1
          comm_exec                        1
          ksymbol                          1
          bpf_event                        1
        ------------------------------------------------------------
        sys_perf_event_open: pid 5779  cpu 0  group_fd -1  flags 0x8
        sys_perf_event_open failed, error -22
        switching off bpf_event
        ------------------------------------------------------------
        perf_event_attr:
          size                             112
          { sample_period, sample_freq }   4000
          sample_type                      IP|TID|TIME|PERIOD
          read_format                      ID
          disabled                         1
          inherit                          1
          mmap                             1
          comm                             1
          freq                             1
          enable_on_exec                   1
          task                             1
          precise_ip                       3
          sample_id_all                    1
          exclude_guest                    1
          mmap2                            1
          comm_exec                        1
          ksymbol                          1
        ------------------------------------------------------------
        sys_perf_event_open: pid 5779  cpu 0  group_fd -1  flags 0x8
        sys_perf_event_open failed, error -22
        switching off ksymbol
        ------------------------------------------------------------
        perf_event_attr:
          size                             112
          { sample_period, sample_freq }   4000
          sample_type                      IP|TID|TIME|PERIOD
          read_format                      ID
          disabled                         1
          inherit                          1
          mmap                             1
          comm                             1
          freq                             1
          enable_on_exec                   1
          task                             1
          precise_ip                       3
          sample_id_all                    1
          exclude_guest                    1
          mmap2                            1
          comm_exec                        1
        ------------------------------------------------------------
      
      And then proceeds to work without those two features.
      
      As passing --bpf-event is an explicit action performed by the user, perhaps we
      should emit a warning telling that the kernel has no such feature, but this can
      be done on top of this patch.
      
      Now with a kernel that supports these events, start the 'record --bpf-event -a'
      and then run 'perf trace sleep 10000' that will use the BPF
      augmented_raw_syscalls.o prebuilt (for another kernel version even) and thus
      should generate PERF_RECORD_BPF_EVENT events:
      
        [root@quaco ~]# perf record -e dummy -a --bpf-event
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.713 MB perf.data ]
      
        [root@quaco ~]# bpftool prog
        13: cgroup_skb  tag 7be49e3934a125ba  gpl
        	loaded_at 2019-01-19T09:09:43-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 13,14
        14: cgroup_skb  tag 2a142ef67aaad174  gpl
        	loaded_at 2019-01-19T09:09:43-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 13,14
        15: cgroup_skb  tag 7be49e3934a125ba  gpl
        	loaded_at 2019-01-19T09:09:43-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 15,16
        16: cgroup_skb  tag 2a142ef67aaad174  gpl
        	loaded_at 2019-01-19T09:09:43-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 15,16
        17: cgroup_skb  tag 7be49e3934a125ba  gpl
        	loaded_at 2019-01-19T09:09:44-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 17,18
        18: cgroup_skb  tag 2a142ef67aaad174  gpl
        	loaded_at 2019-01-19T09:09:44-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 17,18
        21: cgroup_skb  tag 7be49e3934a125ba  gpl
        	loaded_at 2019-01-19T09:09:45-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 21,22
        22: cgroup_skb  tag 2a142ef67aaad174  gpl
        	loaded_at 2019-01-19T09:09:45-0300  uid 0
        	xlated 296B  jited 229B  memlock 4096B  map_ids 21,22
        31: tracepoint  name sys_enter  tag 12504ba9402f952f  gpl
        	loaded_at 2019-01-19T09:19:56-0300  uid 0
        	xlated 512B  jited 374B  memlock 4096B  map_ids 30,29,28
        32: tracepoint  name sys_exit  tag c1bd85c092d6e4aa  gpl
        	loaded_at 2019-01-19T09:19:56-0300  uid 0
        	xlated 256B  jited 191B  memlock 4096B  map_ids 30,29
        # perf report -D | grep PERF_RECORD_BPF_EVENT | nl
           1	0 55834574849 0x4fc8 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 13
           2	0 60129542145 0x5118 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 14
           3	0 64424509441 0x5268 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 15
           4	0 68719476737 0x53b8 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 16
           5	0 73014444033 0x5508 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 17
           6	0 77309411329 0x5658 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 18
           7	0 90194313217 0x57a8 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 21
           8	0 94489280513 0x58f8 [0x18]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 22
           9	7 620922484360 0xb6390 [0x30]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 29
          10	7 620922486018 0xb6410 [0x30]: PERF_RECORD_BPF_EVENT bpf event with type 2, flags 0, id 29
          11	7 620922579199 0xb6490 [0x30]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 30
          12	7 620922580240 0xb6510 [0x30]: PERF_RECORD_BPF_EVENT bpf event with type 2, flags 0, id 30
          13	7 620922765207 0xb6598 [0x30]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 31
          14	7 620922874543 0xb6620 [0x30]: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 32
        #
      
      There, the 31 and 32 tracepoint BPF programs put in place by 'perf trace'.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-7-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      45178a92
    • S
      perf tools: Handle PERF_RECORD_KSYMBOL · 9aa0bfa3
      Song Liu 提交于
      This patch handles PERF_RECORD_KSYMBOL in perf record/report.
      Specifically, map and symbol are created for ksymbol register, and
      removed for ksymbol unregister.
      
      This patch also sets perf_event_attr.ksymbol properly. The flag is ON by
      default.
      
      Committer notes:
      
      Use proper inttypes.h for u64, fixing the build in some environments
      like in the android NDK r15c targetting ARM 32-bit.
      
      I.e. fixing this build error:
      
        util/event.c: In function 'perf_event__fprintf_ksymbol':
        util/event.c:1489:10: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'u64' [-Werror=format=]
                  event->ksymbol_event.flags, event->ksymbol_event.name);
                  ^
        cc1: all warnings being treated as errors
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-6-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9aa0bfa3
    • S
      tools headers uapi: Sync tools/include/uapi/linux/perf_event.h · df063c83
      Song Liu 提交于
      Sync for PERF_RECORD_BPF_EVENT.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-5-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      df063c83
    • S
      perf, bpf: Introduce PERF_RECORD_BPF_EVENT · 6ee52e2a
      Song Liu 提交于
      For better performance analysis of BPF programs, this patch introduces
      PERF_RECORD_BPF_EVENT, a new perf_event_type that exposes BPF program
      load/unload information to user space.
      
      Each BPF program may contain up to BPF_MAX_SUBPROGS (256) sub programs.
      The following example shows kernel symbols for a BPF program with 7 sub
      programs:
      
          ffffffffa0257cf9 t bpf_prog_b07ccb89267cf242_F
          ffffffffa02592e1 t bpf_prog_2dcecc18072623fc_F
          ffffffffa025b0e9 t bpf_prog_bb7a405ebaec5d5c_F
          ffffffffa025dd2c t bpf_prog_a7540d4a39ec1fc7_F
          ffffffffa025fcca t bpf_prog_05762d4ade0e3737_F
          ffffffffa026108f t bpf_prog_db4bd11e35df90d4_F
          ffffffffa0263f00 t bpf_prog_89d64e4abf0f0126_F
          ffffffffa0257cf9 t bpf_prog_ae31629322c4b018__dummy_tracepoi
      
      When a bpf program is loaded, PERF_RECORD_KSYMBOL is generated for each
      of these sub programs. Therefore, PERF_RECORD_BPF_EVENT is not needed
      for simple profiling.
      
      For annotation, user space need to listen to PERF_RECORD_BPF_EVENT and
      gather more information about these (sub) programs via sys_bpf.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradeaed.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-4-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6ee52e2a
    • S
      tools headers uapi: Sync tools/include/uapi/linux/perf_event.h · d764ac64
      Song Liu 提交于
      Sync changes for PERF_RECORD_KSYMBOL.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-3-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d764ac64
    • S
      perf, bpf: Introduce PERF_RECORD_KSYMBOL · 76193a94
      Song Liu 提交于
      For better performance analysis of dynamically JITed and loaded kernel
      functions, such as BPF programs, this patch introduces
      PERF_RECORD_KSYMBOL, a new perf_event_type that exposes kernel symbol
      register/unregister information to user space.
      
      The following data structure is used for PERF_RECORD_KSYMBOL.
      
          /*
           * struct {
           *      struct perf_event_header        header;
           *      u64                             addr;
           *      u32                             len;
           *      u16                             ksym_type;
           *      u16                             flags;
           *      char                            name[];
           *      struct sample_id                sample_id;
           * };
           */
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190117161521.1341602-2-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      76193a94
    • A
      perf: Make perf_event_output() propagate the output() return · 56201969
      Arnaldo Carvalho de Melo 提交于
      For the original mode of operation it isn't needed, since we report back
      errors via PERF_RECORD_LOST records in the ring buffer, but for use in
      bpf_perf_event_output() it is convenient to return the errors, basically
      -ENOSPC.
      
      Currently bpf_perf_event_output() returns an error indication, the last
      thing it does, which is to push it to the ring buffer is that can fail
      and if so, this failure won't be reported back to its users, fix it.
      Reported-by: NJamal Hadi Salim <jhs@mojatatu.com>
      Tested-by: NJamal Hadi Salim <jhs@mojatatu.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/r/20190118150938.GN5823@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      56201969
    • T
      perf report: Dump s390 counter set data to file · 8dabe9c4
      Thomas Richter 提交于
      Add support for the new s390 PMU device cpum_cf_diag to extract the
      counter set diagnostic data. This data is available as event raw data
      and can be created with this command:
      
        [root@s35lp76 perf]# ./perf record -R -e '{rbd000,rbc000}' --
                                       ~/mytests/facultaet 2500
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.009 MB perf.data ]
        [root@s35lp76 perf]#
      
      The new event 0xbc000 generated this counter set diagnostic trace data.
      The data can be extracted using command:
      
        [root@s35lp76 perf]# ./perf report --stdio --itrace=d
        #
        # Total Lost Samples: 0
        #
        # Samples: 21  of events 'anon group { rbd000, rbc000 }'
        # Event count (approx.): 21
        #
        #         Overhead  Command    Shared Object      Symbol
        # ................  .........  .................  ........................
        #
          80.95%   0.00%  facultaet  facultaet          [.] facultaet
           4.76%   0.00%  facultaet  [kernel.kallsyms]  [k] check_chain_key
           4.76%   0.00%  facultaet  [kernel.kallsyms]  [k] ftrace_likely_update
           4.76%   0.00%  facultaet  [kernel.kallsyms]  [k] lock_release
           4.76%   0.00%  facultaet  libc-2.26.so       [.] _dl_addr
        [root@s35lp76 perf]# ll aux*
        -rw-r--r-- 1 root root 3408 Oct 16 12:40 aux.ctr.02
        -rw-r--r-- 1 root root 4096 Oct 16 12:40 aux.smp.02
        [root@s35lp76 perf]#
      
      The files named aux.ctr.## contain the counter set diagnostic data and
      the files named aux.smp.## contain the sampling diagnostic data. ##
      stand for the CPU number the data was taken from.
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20190117093003.96287-4-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8dabe9c4
    • T
      perf report: Display names in s390 diagnostic counter sets · 3e4a1c53
      Thomas Richter 提交于
      On s390 the CPU Measurement Facility diagnostic counter sets are
      displayed by counter number and value. Add the logical counter name in
      the output (if it is available). Otherwise "unknown" is shown.
      
      Output before:
      
       [root@s35lp76 perf]# ./perf report -D --stdio
       [00000000] Counterset:0 Counters:6
         Counter:000 Value:0x000000000085ec36 Counter:001 Value:0x0000000000796c94
         Counter:002 Value:0x0000000000005ada Counter:003 Value:0x0000000000092460
         Counter:004 Value:0x0000000000006073 Counter:005 Value:0x00000000001a9a73
       [0x000038] Counterset:1 Counters:2
         Counter:000 Value:0x000000000007c59f Counter:001 Value:0x000000000002fad6
       [0x000050] Counterset:2 Counters:16
         Counter:000 Value:000000000000000000 Counter:001 Value:000000000000000000
      
      Output after:
      
          [root@s35lp76 perf]# ./perf report -D --stdio
      
       [00000000] Counterset:0 Counters:6
           Counter:000 cpu_cycles Value:0x000000000085ec36
           Counter:001 instructions Value:0x0000000000796c94
           Counter:002 l1i_dir_writes Value:0x0000000000005ada
           Counter:003 l1i_penalty_cycles Value:0x0000000000092460
           Counter:004 l1d_dir_writes Value:0x0000000000006073
           Counter:005 l1d_penalty_cycles Value:0x00000000001a9a73
       [0x000038] Counterset:1 Counters:2
           Counter:000 problem_state_cpu_cycles Value:0x000000000007c59f
           Counter:001 problem_state_instructions Value:0x000000000002fad6
       [0x000050] Counterset:2 Counters:16
           Counter:000 prng_functions Value:000000000000000000
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20190117093003.96287-3-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3e4a1c53
    • T
      perf report: Display arch specific diagnostic counter sets, starting with s390 · 93115d32
      Thomas Richter 提交于
      On s390 the event bc000 (also named CF_DIAG) extracts the CPU
      Measurement Facility diagnostic counter sets and displays them as
      counter number and counter value pairs sorted by counter set number.
      
      Output:
       [root@s35lp76 perf]# ./perf report -D --stdio
      
       [00000000] Counterset:0 Counters:6
         Counter:000 Value:0x000000000085ec36 Counter:001 Value:0x0000000000796c94
         Counter:002 Value:0x0000000000005ada Counter:003 Value:0x0000000000092460
         Counter:004 Value:0x0000000000006073 Counter:005 Value:0x00000000001a9a73
       [0x000038] Counterset:1 Counters:2
         Counter:000 Value:0x000000000007c59f Counter:001 Value:0x000000000002fad6
       [0x000050] Counterset:2 Counters:16
         Counter:000 Value:000000000000000000 Counter:001 Value:000000000000000000
         Counter:002 Value:000000000000000000 Counter:003 Value:000000000000000000
         Counter:004 Value:000000000000000000 Counter:005 Value:000000000000000000
         Counter:006 Value:000000000000000000 Counter:007 Value:000000000000000000
         Counter:008 Value:000000000000000000 Counter:009 Value:000000000000000000
         Counter:010 Value:000000000000000000 Counter:011 Value:000000000000000000
         Counter:012 Value:000000000000000000 Counter:013 Value:000000000000000000
         Counter:014 Value:000000000000000000 Counter:015 Value:000000000000000000
       [0x0000d8] Counterset:3 Counters:128
         Counter:000 Value:0x000000000000020f Counter:001 Value:0x00000000000001d8
         Counter:002 Value:0x000000000000d7fa Counter:003 Value:0x000000000000008b
         ...
      
      The number in brackets is the offset into the raw data field of the
      sample.
      
      New functions trace_event_sample_raw__init() and s390_sample_raw() are
      introduced in the code path to enable interpretation on non s390
      platforms. This event bc000 attached raw data is generated only on s390
      platform. Correct display on other platforms requires correct endianness
      handling.
      
      Committer notes:
      
      Added a init function that sets up a evlist function pointer to avoid
      repeated tests on evlist->env and calls to perf_env__name() that
      involves normalizing, etc, for each PERF_RECORD_SAMPLE.
      
      Removed needless __maybe_unused from the trace_event_raw()
      prototype in session.h, move it to be an static function in evlist.
      
      The 'offset' variable is a size_t, not an u64, fix it to avoid this on
      some arches:
      
          CC       /tmp/build/perf/util/s390-sample-raw.o
        util/s390-sample-raw.c: In function 's390_cpumcfdg_testctr':
        util/s390-sample-raw.c:77:4: error: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'size_t' [-Werror=format=]
            pr_err("Invalid counter set entry at %#"  PRIx64 "\n",
            ^
        cc1: all warnings being treated as errors
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.ibm.com>
      Link: https://lkml.kernel.org/r/9c856ac0-ef23-72b5-901d-a1f815508976@linux.ibm.com
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Link: https://lkml.kernel.org/n/tip-s3jhif06et9ug78qhclw41z1@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      93115d32
    • B
      perf tools: Remove duplicate headers · 3eb03a52
      Brajeswar Ghosh 提交于
      Remove duplicate headers which are included more than once in the same
      file.
      Signed-off-by: NBrajeswar Ghosh <brajeswar.linux@gmail.com>
      Acked-by: NSouptick Joarder <jrdr.linux@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Colin King <colin.king@canonical.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
      Link: http://lkml.kernel.org/r/20190115135916.GA3629@hp-pavilion-15-notebook-pc-brajeswarSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3eb03a52
    • Y
      perf: Remove duplicated workqueue.h include from perf_event.h · cf5c6c21
      YueHaibing 提交于
      It is already included a little bit higher up in that file.
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190117072504.14428-1-yuehaibing@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cf5c6c21
    • J
      perf session: Add reader__process_events function · 3c7b67b2
      Jiri Olsa 提交于
      The reader object is defined by file's fd, data offset and data size.
      
      Now we can simply define a reader object for an arbitrary file data
      portion and pass it to reader__process_events().
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190110101301.6196-7-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3c7b67b2
    • J
      perf session: Add 'data_offset' member to reader object · 71002bd2
      Jiri Olsa 提交于
      Add 'data_offset' member to reader object.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190110101301.6196-6-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      71002bd2
    • J
      perf session: Add 'data_size' member to reader object · f66f0950
      Jiri Olsa 提交于
      Add a  'data_size' member to the reader object. Keep the 'data_size'
      variable instead of replacing it with rd.data_size as it will be used in
      the following patch.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190110101301.6196-5-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f66f0950
    • J
      perf session: Add reader object · 82715eb1
      Jiri Olsa 提交于
      Add a session private reader object to encapsulate the reading of the
      event data block. Starting with a 'fd' field.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190110101301.6196-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      82715eb1
    • J
      perf session: Get rid of file_size variable · 4f5a473d
      Jiri Olsa 提交于
      It's not needed and removing it makes the code a little simpler for the
      upcoming changes.
      
      It's safe to replace file_size with data_size, because the
      perf_data__size() value is never smaller than data_offset + data_size.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190110101301.6196-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4f5a473d
    • J
      perf session: Rearrange perf_session__process_events function · 7ba4da10
      Jiri Olsa 提交于
      To reduce function arguments and the code.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190110101301.6196-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7ba4da10
    • R
      perf tools: Replace automatic const char[] variables by statics · 49b8e2be
      Rasmus Villemoes 提交于
      An automatic const char[] variable gets initialized at runtime, just
      like any other automatic variable. For long strings, that uses a lot of
      stack and wastes time building the string; e.g. for the "No %s
      allocation events..." case one has:
      
        444516:       48 b8 4e 6f 20 25 73 20 61 6c   movabs $0x6c61207325206f4e,%rax # "No %s al"
        ...
        444674:       48 89 45 80                     mov    %rax,-0x80(%rbp)
        444678:       48 b8 6c 6f 63 61 74 69 6f 6e   movabs $0x6e6f697461636f6c,%rax # "location"
        444682:       48 89 45 88                     mov    %rax,-0x78(%rbp)
        444686:       48 b8 20 65 76 65 6e 74 73 20   movabs $0x2073746e65766520,%rax # " events "
        444690:       66 44 89 55 c4                  mov    %r10w,-0x3c(%rbp)
        444695:       48 89 45 90                     mov    %rax,-0x70(%rbp)
        444699:       48 b8 66 6f 75 6e 64 2e 20 20   movabs $0x20202e646e756f66,%rax
      
      Make them all static so that the compiler just references objects in .rodata.
      
      Committer testing:
      
      Ok, using dwarves's codiff tool:
      
          $ codiff --functions /tmp/perf.before ~/bin/perf
        builtin-sched.c:
          cmd_sched                 |  -48
         1 function changed, 48 bytes removed, diff: -48
      
        builtin-report.c:
          cmd_report                |  -32
         1 function changed, 32 bytes removed, diff: -32
      
        builtin-kmem.c:
          cmd_kmem                  |  -64
          build_alloc_func_list     |  -50
         2 functions changed, 114 bytes removed, diff: -114
      
        builtin-c2c.c:
          perf_c2c__report          | -390
         1 function changed, 390 bytes removed, diff: -390
      
        ui/browsers/header.c:
          tui__header_window        | -104
         1 function changed, 104 bytes removed, diff: -104
      
        /home/acme/bin/perf:
         9 functions changed, 688 bytes removed, diff: -688
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20181102230624.20064-1-linux@rasmusvillemoes.dkSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      49b8e2be
  3. 21 1月, 2019 8 次提交
    • A
      perf/core: Remove unused perf_flags · ad07c8ce
      Andrew Murray 提交于
      Now that perf_flags is not used we remove it.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-13-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ad07c8ce
    • A
      perf/core, arch/x86: Strengthen exclusion checks with PERF_PMU_CAP_NO_EXCLUDE · 88dbe3c9
      Andrew Murray 提交于
      For x86 PMUs that do not support context exclusion let's advertise the
      PERF_PMU_CAP_NO_EXCLUDE capability. This ensures that perf will
      prevent us from handling events where any exclusion flags are set.
      Let's also remove the now unnecessary check for exclusion flags.
      
      This change means that amd/iommu and amd/uncore will now also
      indicate that they do not support exclude_{hv|idle} and intel/uncore
      that it does not support exclude_{guest|host}.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-12-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      88dbe3c9
    • A
      perf/core, arch/x86: Use PERF_PMU_CAP_NO_EXCLUDE for exclusion incapable PMUs · 2ff40250
      Andrew Murray 提交于
      For drivers that do not support context exclusion let's advertise the
      PERF_PMU_CAP_NOEXCLUDE capability. This ensures that perf will
      prevent us from handling events where any exclusion flags are set.
      Let's also remove the now unnecessary check for exclusion flags.
      
      PMU drivers that support at least one exclude flag won't have the
      PERF_PMU_CAP_NOEXCLUDE capability set - these PMU drivers should still
      check and fail on unsupported exclude flags. These missing tests are
      not added in this patch.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-11-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      2ff40250
    • A
      perf/core, arch/powerpc: use PERF_PMU_CAP_NO_EXCLUDE for exclusion incapable PMUs · c2c9091d
      Andrew Murray 提交于
      For PowerPC PMUs that do not support context exclusion let's
      advertise the PERF_PMU_CAP_NO_EXCLUDE capability. This ensures that
      perf will prevent us from handling events where any exclusion flags
      are set. Let's also remove the now unnecessary check for exclusion
      flags.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Acked-by: NMichael Ellerman <mpe@ellerman.id.au>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-10-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c2c9091d
    • A
      perf/drivers: Strengthen exclusion checks with PERF_PMU_CAP_NO_EXCLUDE · a66b0010
      Andrew Murray 提交于
      For drivers that do not support context exclusion let's advertise the
      PERF_PMU_CAP_NO_EXCLUDE capability. This ensures that perf will
      prevent us from handling events where any exclusion flags are set.
      Let's also remove the now unnecessary check for exclusion flags.
      
      This change means that qcom_{l2|l3}_pmu will now also indicate that
      they do not support exclude_{host|guest} and that xgene_pmu does
      not also support exclude_idle and exclude_hv.
      
      Note that for qcom_l2_pmu we now implictly return -EINVAL instead
      of -EOPNOTSUPP. This change will result in the perf userspace
      utility retrying the perf_event_open system call with fallback
      event attributes that do not fail.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-9-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a66b0010
    • A
      For drivers that do not support context exclusion let's advertise the · 30656398
      Andrew Murray 提交于
      PERF_PMU_CAP_NO_EXCLUDE capability. This ensures that perf will
      prevent us from handling events where any exclusion flags are set.
      Let's also remove the now unnecessary check for exclusion flags.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-8-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      30656398
    • A
      perf/core, arch/arm: Use PERF_PMU_CAP_NO_EXCLUDE for exclusion incapable PMUs · cafa780e
      Andrew Murray 提交于
      For drivers that do not support context exclusion let's advertise the
      PERF_PMU_CAP_NO_EXCLUDE capability. This ensures that perf will
      prevent us from handling events where any exclusion flags are set.
      Let's also remove the now unnecessary check for exclusion flags.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NShawn Guo <shawnguo@kernel.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-7-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      cafa780e
    • A
      perf/core, arch/arm: Use PERF_PMU_CAP_NO_EXCLUDE conditionally · 1d899c0e
      Andrew Murray 提交于
      The ARM PMU driver can be used to represent a variety of ARM based
      PMUs. Some of these PMUs do not provide support for context
      exclusion, where this is the case we advertise the
      PERF_PMU_CAP_NO_EXCLUDE capability to ensure that perf prevents us
      from handling events where any exclusion flags are set.
      
      Where an ARM PMU driver has the set_event_filter function implemented,
      we rely on it to perform exclusion checks. At present some of these
      functions do not test for all of the available exclude flags.
      Signed-off-by: NAndrew Murray <andrew.murray@arm.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: robin.murphy@arm.com
      Cc: suzuki.poulose@arm.com
      Link: https://lkml.kernel.org/r/1547128414-50693-6-git-send-email-andrew.murray@arm.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1d899c0e