1. 07 8月, 2015 5 次提交
    • 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
  2. 24 7月, 2015 1 次提交
  3. 10 7月, 2015 1 次提交
  4. 09 7月, 2015 1 次提交
  5. 06 7月, 2015 2 次提交
    • A
      tools lib api debugfs: Check for tracefs when reporting errors · ab85785a
      Arnaldo Carvalho de Melo 提交于
      Now that we have two mountpoints, one for debugfs and another, for
      tracefs, we end up needing to check permissions for both, so, on
      a system with default config we were always asking the user to
      check the permission of the debugfs mountpoint, even when it was
      already sufficient. Fix it.
      
      E.g.:
      
        $ trace -e nanosleep usleep 1
        Error: No permissions to read /sys/kernel/debug/tracing/events/raw_syscalls/sys_(enter|exit)
        Hint:  Try 'sudo mount -o remount,mode=755 /sys/kernel/debug'
      
        $ sudo mount -o remount,mode=755 /sys/kernel/debug
        $ trace -e nanosleep usleep 1
        Error: No permissions to read /sys/kernel/debug/tracing/events/raw_syscalls/sys_(enter|exit)
        Hint:  Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'
      
        $ sudo mount -o remount,mode=755 /sys/kernel/debug/tracing
        $ trace -e nanosleep usleep 1
           0.326 ( 0.061 ms): usleep/11961 nanosleep(rqtp: 0x7ffef1081c50) = 0
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/n/tip-0viljeuhc7q84ic8kobsna43@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ab85785a
    • A
      tools: Copy lib/rbtree.c to tools/lib/ · 3f735377
      Arnaldo Carvalho de Melo 提交于
      So that we can remove kernel specific stuff we've been stubbing out via
      a tools/include/linux/export.h that gets removed in this patch and to
      avoid breakages in the future like the one fixed recently where
      rcupdate.h started being used in rbtree.h.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-rxuzfsozpb8hv1emwpx06rm6@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3f735377
  6. 08 6月, 2015 2 次提交
    • H
      tools lib traceevent: Ignore libtrace-dynamic-list file · 38e09624
      He Kuang 提交于
      The libtrace-dynamic-list file is used to export symbols used by
      traceevent plugins.
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1432819735-35040-2-git-send-email-hekuang@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      38e09624
    • H
      tools lib traceevent: Export dynamic symbols used by traceevent plugins · e3d09ec8
      He Kuang 提交于
      Traceevent plugins need dynamic symbols exported from libtraceevent.a,
      otherwise a dlopen error will occur during plugins loading.
      
      This patch uses dynamic-list-file to export dynamic symbols which will
      be used in plugins to perf executable.
      
      The problem is covered up if feature-libpython is enabled, because
      PYTHON_EMBED_LDOPTS contains '-Xlinker --export-dynamic' which adds all
      symbols to the dynamic symbol table. So we should reproduce the problem
      by setting NO_LIBPYTHON=1.
      
      Before this patch:
      
        (Prepare plugins)
        $ ls /root/.traceevent/plugins/
        plugin_sched_switch.so
        plugin_function.so
        ...
      
        $ perf record -e 'ftrace:function' ls
      
        $ perf script
          Warning: could not load plugin '/mnt/data/root/.traceevent/plugins/plugin_sched_switch.so'
          /root/.traceevent/plugins/plugin_sched_switch.so: undefined symbol: pevent_unregister_event_handler
      
          Warning: could not load plugin '/root/.traceevent/plugins/plugin_function.so'
          /root/.traceevent/plugins/plugin_function.so: undefined symbol: warning
          ...
                 :1049  1049 [000]  9666.754487: ftrace:function:  ffffffff8118bc50 <-- ffffffff8118c5b3
                 :1049  1049 [000]  9666.754487: ftrace:function:  ffffffff818e2440 <-- ffffffff8118bc75
                 :1049  1049 [000]  9666.754487: ftrace:function:  ffffffff8106eee0 <-- ffffffff811212e2
      
      After this patch:
      
        $ perf record -e 'ftrace:function' ls
        $ perf script
                 :1049  1049 [000]  9666.754487: ftrace:function: __set_task_comm
                 :1049  1049 [000]  9666.754487: ftrace:function:    _raw_spin_lock
                 :1049  1049 [000]  9666.754487: ftrace:function: task_tgid_nr_ns
                 ...
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1432819735-35040-1-git-send-email-hekuang@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e3d09ec8
  7. 18 5月, 2015 1 次提交
    • W
      tools lib traceevent: Install libtraceevent.a into libdir · bb53e176
      Wang Nan 提交于
      Before this patch, 'make install' installs libraries into bindir:
      
        $ make install DESTDIR=./tree
         INSTALL  trace_plugins
         INSTALL  libtraceevent.a
         INSTALL  libtraceevent.so
        $ find ./tree
         ./tree/
         ./tree/usr
         ./tree/usr/local
         ./tree/usr/local/bin
         ./tree/usr/local/bin/libtraceevent.a
         ./tree/usr/local/bin/libtraceevent.so
         ...
      
      /usr/local/lib( or lib64) should be a better place.
      
      This patch replaces 'bin' with libdir. For __LP64__ building, libraries
      are installed to /usr/local/lib64. For other building, to
      /usr/local/lib instead.
      
      After applying this patch:
      
        $ make install DESTDIR=./tree
         INSTALL  trace_plugins
         INSTALL  libtraceevent.a
         INSTALL  libtraceevent.so
        $ find ./tree
         ./tree
         ./tree/usr
         ./tree/usr/local
         ./tree/usr/local/lib64
         ./tree/usr/local/lib64/libtraceevent.a
         ./tree/usr/local/lib64/traceevent
         ./tree/usr/local/lib64/traceevent/plugins
         ./tree/usr/local/lib64/traceevent/plugins/plugin_mac80211.so
         ./tree/usr/local/lib64/traceevent/plugins/plugin_hrtimer.so
         ...
         ./tree/usr/local/lib64/libtraceevent.so
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Cc: Alexei 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: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: pi3orama@163.com
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1431860222-61636-4-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bb53e176
  8. 14 5月, 2015 1 次提交
  9. 13 5月, 2015 2 次提交
  10. 29 4月, 2015 1 次提交
  11. 24 4月, 2015 2 次提交
  12. 08 4月, 2015 1 次提交
    • N
      tools lib traceevent: Honor operator priority · 3201f0dc
      Namhyung Kim 提交于
      Currently it ignores operator priority and just sets processed args as a
      right operand.  But it could result in priority inversion in case that
      the right operand is also a operator arg and its priority is lower.
      
      For example, following print format is from new kmem events.
      
        "page=%p", REC->pfn != -1UL ? (((struct page *)(0xffffea0000000000UL)) + (REC->pfn)) : ((void *)0)
      
      But this was treated as below:
      
        REC->pfn != ((null - 1UL) ? ((struct page *)0xffffea0000000000UL + REC->pfn) : (void *) 0)
      
      In this case, the right arg was '?' operator which has lower priority.
      But it just sets the whole arg so making the output confusing - page was
      always 0 or 1 since that's the result of logical operation.
      
      With this patch, it can handle it properly like following:
      
        ((REC->pfn != (null - 1UL)) ? ((struct page *)0xffffea0000000000UL + REC->pfn) : (void *) 0)
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joonsoo Kim <js1304@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: linux-mm@kvack.org
      Link: http://lkml.kernel.org/r/1428298576-9785-10-git-send-email-namhyung@kernel.org
      [ Replaced 'swap' with 'rotate' in a comment as requested by Steve and agreed by Namhyung ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3201f0dc
  13. 26 3月, 2015 1 次提交
  14. 25 3月, 2015 1 次提交
  15. 24 3月, 2015 10 次提交
  16. 22 3月, 2015 1 次提交
  17. 13 2月, 2015 4 次提交
  18. 07 2月, 2015 3 次提交