1. 11 8月, 2015 2 次提交
  2. 10 8月, 2015 2 次提交
  3. 09 8月, 2015 2 次提交
  4. 07 8月, 2015 34 次提交
    • W
      perf tests: Add LLVM test for eBPF on-the-fly compiling · 9bc898c7
      Wang Nan 提交于
      Previous patches introduce llvm__compile_bpf() to compile source file to
      eBPF object. This patch adds testcase to test it. It also tests libbpf
      by opening generated object after applying next patch which introduces
      HAVE_LIBBPF_SUPPORT option.
      
      Since llvm__compile_bpf() prints long messages which users who don't
      explicitly test llvm doesn't care, this patch set verbose to -1 to
      suppress all debug, warning and error message, and hint user use 'perf
      test -v' to see the full output.
      
      For the same reason, if clang is not found in PATH and there's no [llvm]
      section in .perfconfig, skip this test.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/n/1436445342-1402-17-git-send-email-wangnan0@huawei.com
      [ Add tools/lib/bpf/ to tools/perf/MANIFEST, so that the tarball targets build ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9bc898c7
    • W
      perf tools: Auto detecting kernel include options · 0c6d18bf
      Wang Nan 提交于
      To help user find correct kernel include options, this patch extracts
      them from kbuild system by an embedded script kinc_fetch_script, which
      creates a temporary directory, generates Makefile and an empty dummy.o
      then use the Makefile to fetch $(NOSTDINC_FLAGS), $(LINUXINCLUDE) and
      $(EXTRA_CFLAGS) options. The result is passed to compiler script using
      'KERNEL_INC_OPTIONS' environment variable.
      
      Because options from kbuild contains relative path like
      'Iinclude/generated/uapi', the work directory must be changed. This is
      done by previous patch.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1436445342-1402-16-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0c6d18bf
    • W
      perf tools: Auto detecting kernel build directory · d325d788
      Wang Nan 提交于
      This patch detects kernel build directory by checking the existence of
      include/generated/autoconf.h.
      
      clang working directory is changed to kbuild directory if it is found,
      to help user use relative include path. Following patch will detect
      kernel include directory, which contains relative include patch so this
      workdir changing is needed.
      
      Users are allowed to set 'kbuild-dir = ""' manually to disable this
      checking.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/n/tip-owyfwfbemrjn0tlj6tgk2nf5@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d325d788
    • W
      perf tools: Call clang to compile C source to object code · 4cea3a9c
      Wang Nan 提交于
      This is the core patch for supporting eBPF on-the-fly compiling, does
      the following work:
      
       1. Search clang compiler using search_program().
      
       2. Run command template defined in llvm-bpf-cmd-template option in
          [llvm] config section using read_from_pipe(). Patch of clang and
          source code path is injected into shell command using environment
          variable using force_set_env().
      
        Commiter notice:
      
        When building with DEBUG=1 we get a compiler error that gets fixed with
        the same approach described in commit b2365122:
      
          perf kmem: Fix compiler warning about may be accessing uninitialized variable
      
          The last argument to strtok_r doesn't need to be initialized, its
          just a placeholder to make this routine reentrant, but gcc doesn't know
          about that and complains, breaking the build, fix it by setting it to
          NULL.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/n/1436445342-1402-14-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4cea3a9c
    • W
      perf tools: Introduce llvm config options · aa61fd05
      Wang Nan 提交于
      This patch introduces [llvm] config section with 5 options. Following
      patches will use then to config llvm dynamica compiling.
      
      'llvm-utils.[ch]' is introduced in this patch for holding all
      llvm/clang related stuffs.
      
      Example:
      
        [llvm]
              # Path to clang. If omit, search it from $PATH.
      	clang-path = "/path/to/clang"
      
              # Cmdline template. Following line shows its default value.
              # Environment variable is used to passing options.
              #
              # *NOTE*: -D__KERNEL__ MUST appears before $CLANG_OPTIONS,
              # so user have a chance to use -U__KERNEL__ in $CLANG_OPTIONS
              # to cancel it.
      	clang-bpf-cmd-template = "$CLANG_EXEC -D__KERNEL__ $CLANG_OPTIONS \
      				  $KERNEL_INC_OPTIONS -Wno-unused-value \
      				  -Wno-pointer-sign -working-directory \
      				  $WORKING_DIR  -c $CLANG_SOURCE -target \
      				  bpf -O2 -o -"
      
              # Options passed to clang, will be passed to cmdline by
              # $CLANG_OPTIONS.
      	clang-opt = "-Wno-unused-value -Wno-pointer-sign"
      
              # kbuild directory. If not set, use /lib/modules/`uname -r`/build.
              # If set to "" deliberately, skip kernel header auto-detector.
      	kbuild-dir = "/path/to/kernel/build"
      
              # Options passed to 'make' when detecting kernel header options.
      	kbuild-opts = "ARCH=x86_64"
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1437477214-149684-1-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      aa61fd05
    • W
      bpf tools: Link all bpf objects onto a list · 9a208eff
      Wang Nan 提交于
      To allow enumeration of all bpf_objects, keep them in a list (hidden to
      caller). bpf_object__for_each_safe() is introduced to do this iteration.
      It is safe even user close the object during iteration.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-23-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9a208eff
    • W
      bpf tools: Introduce accessors for struct bpf_program · aa9b1ac3
      Wang Nan 提交于
      This patch introduces accessors for user of libbpf to retrieve section
      name and fd of a opened/loaded eBPF program. 'struct bpf_prog_handler'
      is used for that purpose. Accessors of programs section name and file
      descriptor are provided. Set/get private data are also impelmented.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1435716878-189507-21-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      aa9b1ac3
    • W
      bpf tools: Load eBPF programs in object files into kernel · 55cffde2
      Wang Nan 提交于
      This patch utilizes previous introduced bpf_load_program to load
      programs in the ELF file into kernel. Result is stored in 'fd' field in
      'struct bpf_program'.
      
      During loading, it allocs a log buffer and free it before return.  Note
      that that buffer is not passed to bpf_load_program() if the first
      loading try is successful. Doesn't use a statically allocated log buffer
      to avoid potention multi-thread problem.
      
      Instructions collected during opening is cleared after loading.
      
      load_program() is created for loading a 'struct bpf_insn' array into
      kernel, bpf_program__load() calls it. By this design we have a function
      loads instructions into kernel. It will be used by further patches,
      which creates different instances from a program and load them into
      kernel.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-20-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      55cffde2
    • W
      bpf tools: Introduce bpf_load_program() to bpf.c · 7bf98369
      Wang Nan 提交于
      bpf_load_program() can be used to load bpf program into kernel. To make
      loading faster, first try to load without logbuf. Try again with logbuf
      if the first try failed.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-19-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7bf98369
    • W
      bpf tools: Relocate eBPF programs · 8a47a6c5
      Wang Nan 提交于
      If an eBPF program accesses a map, LLVM generates a load instruction
      which loads an absolute address into a register, like this:
      
        ld_64   r1, <MCOperand Expr:(mymap)>
        ...
        call    2
      
      That ld_64 instruction will be recorded in relocation section.
      To enable the usage of that map, relocation must be done by replacing
      the immediate value by real map file descriptor so it can be found by
      eBPF map functions.
      
      This patch to the relocation work based on information collected by
      patches:
      
      'bpf tools: Collect symbol table from SHT_SYMTAB section',
      'bpf tools: Collect relocation sections from SHT_REL sections'
      and
      'bpf tools: Record map accessing instructions for each program'.
      
      For each instruction which needs relocation, it inject corresponding
      file descriptor to imm field. As a part of protocol, src_reg is set to
      BPF_PSEUDO_MAP_FD to notify kernel this is a map loading instruction.
      
      This is the final part of map relocation patch. The principle of map
      relocation is described in commit message of 'bpf tools: Collect symbol
      table from SHT_SYMTAB section'.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-18-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8a47a6c5
    • W
      bpf tools: Create eBPF maps defined in an object file · 52d3352e
      Wang Nan 提交于
      This patch creates maps based on 'map' section in object file using
      bpf_create_map(), and stores the fds into an array in 'struct
      bpf_object'.
      
      Previous patches parse ELF object file and collects required data, but
      doesn't play with the kernel. They belong to the 'opening' phase. This
      patch is the first patch in 'loading' phase. The 'loaded' field is
      introduced in 'struct bpf_object' to avoid loading an object twice,
      because the loading phase clears resources collected during the opening
      which becomes useless after loading. In this patch, maps_buf is cleared.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-17-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      52d3352e
    • W
      bpf tools: Add bpf.c/h for common bpf operations · e3ed2fef
      Wang Nan 提交于
      This patch introduces bpf.c and bpf.h, which hold common functions
      issuing bpf syscall. The goal of these two files is to hide syscall
      completely from user. Note that bpf.c and bpf.h deal with kernel
      interface only. Things like structure of 'map' section in the ELF object
      is not cared by of bpf.[ch].
      
      We first introduce bpf_create_map().
      
      Note that, since functions in bpf.[ch] are wrapper of sys_bpf, they
      don't use OO style naming.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-16-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e3ed2fef
    • W
      bpf tools: Record map accessing instructions for each program · 34090915
      Wang Nan 提交于
      This patch records the indices of instructions which are needed to be
      relocated. That information is saved in the 'reloc_desc' field in
      'struct bpf_program'. In the loading phase (this patch takes effect in
      the opening phase), the collected instructions will be replaced by map
      loading instructions.
      
      Since we are going to close the ELF file and clear all data at the end
      of the 'opening' phase, the ELF information will no longer be valid in
      the 'loading' phase. We have to locate the instructions before maps are
      loaded, instead of directly modifying the instruction.
      
      'struct bpf_map_def' is introduced in this patch to let us know how many
      maps are defined in the object.
      
      This is the third part of map relocation. The principle of map relocation
      is described in commit message of 'bpf tools: Collect symbol table from
      SHT_SYMTAB section'.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-15-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      34090915
    • W
      bpf tools: Collect relocation sections from SHT_REL sections · b62f06e8
      Wang Nan 提交于
      This patch collects relocation sections into 'struct object'.  Such
      sections are used for connecting maps to bpf programs. 'reloc' field in
      'struct bpf_object' is introduced for storing such information.
      
      This patch simply store the data into 'reloc' field. Following patch
      will parse them to know the exact instructions which are needed to be
      relocated.
      
      Note that the collected data will be invalid after ELF object file is
      closed.
      
      This is the second patch related to map relocation. The first one is
      'bpf tools: Collect symbol table from SHT_SYMTAB section'. The
      principle of map relocation is described in its commit message.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-14-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b62f06e8
    • W
      bpf tools: Collect eBPF programs from their own sections · a5b8bd47
      Wang Nan 提交于
      This patch collects all programs in an object file into an array of
      'struct bpf_program' for further processing. That structure is for
      representing each eBPF program. 'bpf_prog' should be a better name, but
      it has been used by linux/filter.h. Although it is a kernel space name,
      I still prefer to call it 'bpf_program' to prevent possible confusion.
      
      bpf_object__add_program() creates a new 'struct bpf_program' object.
      It first init a variable in stack using bpf_program__init(), then if
      success, enlarges obj->programs array and copy the new object in.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-13-git-send-email-wangnan0@huawei.com
      [ Made bpf_object__add_program() propagate the error (-EINVAL or -ENOMEM) ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a5b8bd47
    • W
      bpf tools: Collect symbol table from SHT_SYMTAB section · bec7d68c
      Wang Nan 提交于
      This patch collects symbols section. This section is useful when linking
      BPF maps.
      
      What 'bpf_map_xxx()' functions actually require are map's file
      descriptors (and the internal verifier converts fds into pointers to
      'struct bpf_map'), which we don't know when compiling. Therefore, we
      should make compiler generate a 'ldr_64 r1, <imm>' instruction, and
      fill the 'imm' field with the actual file descriptor when loading in
      libbpf.
      
      BPF programs should be written in this way:
      
       struct bpf_map_def SEC("maps") my_map = {
          .type = BPF_MAP_TYPE_HASH,
          .key_size = sizeof(unsigned long),
          .value_size = sizeof(unsigned long),
          .max_entries = 1000000,
       };
      
       SEC("my_func=sys_write")
       int my_func(void *ctx)
       {
           ...
           bpf_map_update_elem(&my_map, &key, &value, BPF_ANY);
           ...
       }
      
      Compiler should convert '&my_map' into a 'ldr_64, r1, <imm>'
      instruction, where imm should be the address of 'my_map'. According to
      the address, libbpf knows which map it actually referenced, and then
      fills the imm field with the 'fd' of that map created by it.
      
      However, since we never really 'link' the object file, the imm field is
      only a record in relocation section. Therefore libbpf should do the
      relocation:
      
       1. In relocation section (type == SHT_REL), positions of each such
          'ldr_64' instruction are recorded with a reference of an entry in
          symbol table (SHT_SYMTAB);
      
       2. From records in symbol table we can find the indics of map
          variables.
      
      Libbpf first record SHT_SYMTAB and positions of each instruction which
      required bu such operation. Then create file descriptor. Finally, after
      map creation complete, replace the imm field.
      
      This is the first patch of BPF map related stuff. It records SHT_SYMTAB
      into object's efile field for further use.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-12-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bec7d68c
    • W
      bpf tools: Collect map definitions from 'maps' section · 0b3d1efa
      Wang Nan 提交于
      If maps are used by eBPF programs, corresponding object file(s) should
      contain a section named 'map'. Which contains map definitions. This
      patch copies the data of the whole section. Map data parsing should be
      acted just before map loading.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-11-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0b3d1efa
    • W
      bpf tools: Collect version and license from ELF sections · cb1e5e96
      Wang Nan 提交于
      Expand bpf_obj_elf_collect() to collect license and kernel version
      information in eBPF object file. eBPF object file should have a section
      named 'license', which contains a string. It should also have a section
      named 'version', contains a u32 LINUX_VERSION_CODE.
      
      bpf_obj_validate() is introduced to validate object file after loaded.
      Currently it only check existence of 'version' section.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-10-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cb1e5e96
    • W
      bpf tools: Iterate over ELF sections to collect information · 29603665
      Wang Nan 提交于
      bpf_obj_elf_collect() is introduced to iterate over each elf sections to
      collection information in eBPF object files. This function will futher
      enhanced to collect license, kernel version, programs, configs and map
      information.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-9-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      29603665
    • W
      bpf tools: Check endianness and make libbpf fail early · cc4228d5
      Wang Nan 提交于
      Check endianness according to EHDR. Code is taken from
      tools/perf/util/symbol-elf.c.
      
      Libbpf doesn't magically convert missmatched endianness. Even if we swap
      eBPF instructions to correct byte order, we are unable to deal with
      endianness in code logical generated by LLVM.
      
      Therefore, libbpf should simply reject missmatched ELF object, and let
      LLVM to create good code.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-8-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cc4228d5
    • W
      bpf tools: Read eBPF object from buffer · 6c956392
      Wang Nan 提交于
      To support dynamic compiling, this patch allows caller to pass a
      in-memory buffer to libbpf by bpf_object__open_buffer(). libbpf calls
      elf_memory() to open it as ELF object file.
      
      Because __bpf_object__open() collects all required data and won't need
      that buffer anymore, libbpf uses that buffer directly instead of clone a
      new buffer. Caller of libbpf can free that buffer or use it do other
      things after bpf_object__open_buffer() return.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-7-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6c956392
    • W
      bpf tools: Open eBPF object file and do basic validation · 1a5e3fb1
      Wang Nan 提交于
      This patch defines basic interface of libbpf. 'struct bpf_object' will
      be the handler of each object file. Its internal structure is hide to
      user. eBPF object files are compiled by LLVM as ELF format. In this
      patch, libelf is used to open those files, read EHDR and do basic
      validation according to e_type and e_machine.
      
      All elf related staffs are grouped together and reside in efile field of
      'struct bpf_object'. bpf_object__elf_finish() is introduced to clear it.
      
      After all eBPF programs in an object file are loaded, related ELF
      information is useless. Close the object file and free those memory.
      
      The zfree() and zclose() functions are introduced to ensure setting NULL
      pointers and negative file descriptors after resources are released.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-6-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1a5e3fb1
    • W
      bpf tools: Allow caller to set printing function · b3f59d66
      Wang Nan 提交于
      By libbpf_set_print(), users of libbpf are allowed to register he/she
      own debug, info and warning printing functions. Libbpf will use those
      functions to print messages. If not provided, default info and warning
      printing functions are fprintf(stderr, ...); default debug printing
      is NULL.
      
      This API is designed to be used by perf, enables it to register its own
      logging functions to make all logs uniform, instead of separated
      logging level control.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-5-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b3f59d66
    • W
      bpf tools: Introduce 'bpf' library and add bpf feature check · 1b76c13e
      Wang Nan 提交于
      This is the first patch of libbpf. The goal of libbpf is to create a
      standard way for accessing eBPF object files. This patch creates
      'Makefile' and 'Build' for it, allows 'make' to build libbpf.a and
      libbpf.so, 'make install' to put them into proper directories.
      Most part of Makefile is borrowed from traceevent.
      
      Before building, it checks the existence of libelf in Makefile, and deny
      to build if not found. Instead of throwing an error if libelf not found,
      the error raises in a phony target "elfdep". This design is to ensure
      'make clean' still workable even if libelf is not found.
      
      Because libbpf requires 'kern_version' field set for 'union bpf_attr'
      (bpfdep" is used for that dependency), Kernel BPF API is also checked
      by intruducing a new feature check 'bpf' into tools/build/feature,
      which checks the existence and version of linux/bpf.h. When building
      libbpf, it searches that file from include/uapi/linux in kernel source
      tree (controlled by FEATURE_CHECK_CFLAGS-bpf). Since it searches kernel
      source tree it reside, installing of newest kernel headers is not
      required, except we are trying to port these files to an old kernel.
      
      To avoid checking that file when perf building, the newly introduced
      'bpf' feature check doesn't added into FEATURE_TESTS and
      FEATURE_DISPLAY by default in tools/build/Makefile.feature, but added
      into libbpf's specific.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NAlexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Bcc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1435716878-189507-4-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1b76c13e
    • A
      perf tools: Extend the event parser maximum error index · 141b2d31
      Adrian Hunter 提交于
      Extend the event parser maximum error index from 10 to 13.  That allows
      PMU config terms of up to 10 characters to display un-truncated in the
      error message.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-17-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      141b2d31
    • A
      perf tools: Validate config term maximum value · 0efe6b67
      Adrian Hunter 提交于
      Currently the value of a PMU config term is silently truncated if it is
      too big. This is an impediment to validating the value for other
      criteria later on i.e.  the user provides an invalid value that gets
      truncated to a valid one.
      
      The maximum value validation is only done for the parser where the error
      is passed back to the user. In other cases the silent truncation
      continues so as not to affect tools that perhaps rely on it.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-16-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0efe6b67
    • A
      perf tools: Add perf_pmu__format_bits() · 09ff6071
      Adrian Hunter 提交于
      Add perf_pmu__format_bits() to get the format bits for a PMU config
      term.  Intel PT will use this to validate terms and to record format
      bits to enable later interpreting the config from the attribute stored
      in the perf.data file.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-15-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      09ff6071
    • A
      perf tools: Fix perf-with-kcore handling of arguments containing spaces · 8bd1b2d2
      Adrian Hunter 提交于
      Fix the perf-with-kcore script so that it doesn't split arguments that
      contain spaces.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-13-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8bd1b2d2
    • A
      perf auxtrace: Fix period type 'i' not working · f70cfa07
      Adrian Hunter 提交于
      PERF_ITRACE_PERIOD_INSTRUCTIONS is zero so it got overwritten by the
      default period type.
      
      Fix by checking if the period type was set rather than if the value was
      zero when applying the default.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1437150840-31811-12-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f70cfa07
    • M
      perf tools xtensa: Add DWARF register names · 74d4582f
      Max Filippov 提交于
      Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Marc Gauthier <marc@cadence.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: linux-xtensa@linux-xtensa.org
      Link: http://lkml.kernel.org/r/1437208216-15729-9-git-send-email-jcmvbkbc@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      74d4582f
    • A
      perf report: Display cycles in branch sort mode · 40997d6c
      Andi Kleen 提交于
      Display the cycles by default in branch sort mode.
      
      To make enough room for the new column I removed dso_to. It is usually
      redundant with dso_from.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1437233094-12844-9-git-send-email-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      40997d6c
    • A
      perf top: Add branch annotation code to top · a18b027e
      Andi Kleen 提交于
      Now that we can process branch data in annotate it makes sense to
      support enabling branch recording from top too. Most of the code needed
      for this is already in shared code with report. But we need to add:
      
      - The option parsing code (using shared code from the previous patch)
      - Document the options
      - Set up the IPC/cycles accounting state in the top session
      - Call the accounting code in the hist iter callback
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1437233094-12844-8-git-send-email-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a18b027e
    • A
      perf annotate: Finally display IPC and cycle accounting · f8f4aaea
      Andi Kleen 提交于
      Add two new columns to the annotate display and display the average
      cycles and the compute IPC if available.
      
      When the LBR was not in any branch mode the IPC computation is
      automatically disabled. We still display the cycle information.
      
      Example output (with made up numbers):
      
      The second column is the IPC and third average cycles.
      
                       │    __attribute__((noinline)) f2()
                       │    {
        5.15  0.07     │       push   %rbp
        0.01  0.07     │       mov    %rsp,%rbp
                       │            c = a / b;
        9.87  0.07     │       mov    a,%eax
              0.07     │       mov    b,%ecx
              0.07     │       cltd
        4.92  0.07  123│       idiv   %ecx
       70.79  0.07     │       mov    %eax,__TMC_END__
                       │    }
        9.25  0.07     │       pop    %rbp
        0.01  0.07  123│     ← retq
      
      v2: Fix display problems.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1437233094-12844-7-git-send-email-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f8f4aaea
    • A
      perf annotate: Compute IPC and basic block cycles · 30e863bb
      Andi Kleen 提交于
      Compute the IPC and the basic block cycles for the annotate display.
      
      IPC is computed by counting the instructions, and then dividing the
      accounted cycles by that count.
      
      The actual IPC computation can only be done at annotate time, because we
      need to parse the objdump output first to know the number of
      instructions in the basic block.
      
      The cycles/IPC are also put into the perf function annotation so that
      the display code can show them.
      
      Again basic block overlaps are not handled, with the longest winning,
      but there are some heuristics to hide the IPC when the longest is not
      the most common.
      
      v2: Compute IPC correctly.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1437233094-12844-6-git-send-email-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      30e863bb