linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wangnan (F)" <wangnan0@huawei.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: <ast@plumgrid.com>, <brendan.d.gregg@gmail.com>,
	<daniel@iogearbox.net>, <namhyung@kernel.org>,
	<masami.hiramatsu.pt@hitachi.com>, <paulus@samba.org>,
	<a.p.zijlstra@chello.nl>, <mingo@redhat.com>, <jolsa@kernel.org>,
	<dsahern@gmail.com>, <linux-kernel@vger.kernel.org>,
	<lizefan@huawei.com>, <hekuang@huawei.com>, <xiakaixu@huawei.com>,
	<pi3orama@163.com>
Subject: Re: [RFC PATCH v6 00/32] perf tools: filtering events using eBPF programs
Date: Wed, 10 Jun 2015 07:45:01 +0800	[thread overview]
Message-ID: <55777A7D.6040802@huawei.com> (raw)
In-Reply-To: <20150609135906.GA20706@kernel.org>



On 2015/6/9 21:59, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jun 09, 2015 at 05:50:04AM +0000, Wang Nan escreveu:
>> This is the 6th version which tries to introduce eBPF programs to perf.
>> It enables 'perf record' to filter events using eBPF programs like:
>>
>>   # perf record --event bpf-file.c sleep 1
> Thanks for doing this, comments below for this 00/32 file:
>   
>> and
>>
>>   # perf record --event bpf-file.o sleep 1
>>
>> This patch series is based on tip/perf/core (a3d8654).
>>
>> Compared with v5 patch, this series allows user to pass BPF
>> scriptlet source code file directly, instead of requiring user to
>> pre-compile it into an ELF object. Which is done mainly by patch 24/32.
>>
>> In addition, to help users setup LLVM, [bpf] perf config section is
>> appended. 4 command line options are also appended to 'perf record'
>> for setting pathes and options of clang and llc. Which is done by patch
>> 25/32 and 32/32.
>>
>> Other improvements:
>>
>>   1. Adjust context.
>>
>>   2. Get rid of 'trailing whitespace' and 'space before tab in indent'
>>      problems.
>>
>>   3. Error messages are improved when BPF API checking fail.
>>
>> In this series:
>>
>>   Patch 1/32 adds a feature check to check version of eBPF API.
>>
>>   Patch 2/32 - 21/32 introduce libbpf, which first parse eBPF object
>>     files then load maps and programs into kernel. These patches are
>>     already received 'Acked-by' from Alexei Starovoitov except patch
>>     5/32, which enables opening a memory-based object file image using
>>     bpf_object__open_buffer().
>>
>>   Patch 22/32 - 32/32 are perf related. Patch 24, 25 and 32 are new to
>>     support dynamical compiling.
>>
>> Here is an example shows the using of dynamic compiling:
>>
>>     # perf record --event lock_page.c ls /
>>     Added new event:
>>       perf_bpf_probe:lock_page (on __lock_page)
>>     
>>     You can now use it in all perf tools, such as:
> Can we suppress these messages? They are misleading, because we will not
> be able to " use it in all perf tools", since they will be removed right
> after this ' perf record'  session ends.
>
> They may have value as debugging aid, so that we see what probes are
> being put in place, etc, but for the default case they are just annoying
> scrolling.

Sure. I don't want to alert API of add_perf_probe_events() and 
__add_probe_trace_events(),
so in next version I'd like to introduce a new field in probe_conf to 
control these output.

>>     	perf record -e perf_bpf_probe:lock_page -aR sleep 1
>>     
>>     Added new event:
>>       perf_bpf_probe:lock_page_ret (on __lock_page%return)
>>     
>>     You can now use it in all perf tools, such as:
>>     
>>     	perf record -e perf_bpf_probe:lock_page_ret -aR sleep 1
>>     
>>     Added new event:
>>       perf_bpf_probe:unlock_page (on unlock_page)
>>     
>>     You can now use it in all perf tools, such as:
>>     
>>     	perf record -e perf_bpf_probe:unlock_page -aR sleep 1
>>     
>>     bin  boot  dev	etc  home  init  lib  lib64  linuxrc  media  mnt  proc	root  run  sbin  sys  tmp  usr	var
>>     [ perf record: Woken up 1 times to write data ]
>>     [ perf record: Captured and wrote 0.002 MB perf.data ]
>>     Removed event: perf_bpf_probe:lock_page
>>     Removed event: perf_bpf_probe:lock_page_ret
>>     Removed event: perf_bpf_probe:unlock_page
> Ditto for this.
>   
>> Where lock_page.c can be found from:
>>
>>   http://lkml.kernel.org/r/557025A2.6090903@huawei.com
> I'll try applying the patches and running this script, perhaps it would
> be a good idea to have some /examples/  directory under som of the
> tools/ directory, so that everything that is needed to test this is in
> the source tree.
>
> We need to at some point, best if right now, to make 'perf test' have an
> entry for this, is this in this patchkit?

Will append. Tow parts: 1. testing llvm compiling BPF source code; 2. 
loading it into kernel.

> I.e. plain running 'perf test'  will tell us if all this works fine, now
> and everytime somebody with all the needed bits runs 'perf test'.
>
> Thanks for the hard work!
>
> - Arnaldo
>   
>> Wang Nan (32):
>>    tools build: Add feature check for eBPF API
>>    bpf tools: Introduce 'bpf' library to tools
>>    bpf tools: Allow caller to set printing function
>>    bpf tools: Open eBPF object file and do basic validation
>>    bpf tools: Read eBPF object from buffer
>>    bpf tools: Check endianess and make libbpf fail early
>>    bpf tools: Iterate over ELF sections to collect information
>>    bpf tools: Collect version and license from ELF sections
>>    bpf tools: Collect map definitions from 'maps' section
>>    bpf tools: Collect symbol table from SHT_SYMTAB section
>>    bpf tools: Collect eBPF programs from their own sections
>>    bpf tools: Collect relocation sections from SHT_REL sections
>>    bpf tools: Record map accessing instructions for each program
>>    bpf tools: Add bpf.c/h for common bpf operations
>>    bpf tools: Create eBPF maps defined in an object file
>>    bpf tools: Relocate eBPF programs
>>    bpf tools: Introduce bpf_load_program() to bpf.c
>>    bpf tools: Load eBPF programs in object files into kernel
>>    bpf tools: Introduce accessors for struct bpf_program
>>    bpf tools: Introduce accessors for struct bpf_object
>>    bpf tools: Link all bpf objects onto a list
>>    perf tools: Make perf depend on libbpf
>>    perf record: Enable passing bpf object file to --event
>>    perf record: Compile scriptlets if pass '.c' to --event
>>    perf tools: Add 'bpf.' config section to perf default config
>>    perf tools: Parse probe points of eBPF programs during preparation
>>    perf probe: Attach trace_probe_event with perf_probe_event
>>    perf record: Probe at kprobe points
>>    perf record: Load all eBPF object into kernel
>>    perf tools: Add bpf_fd field to evsel and config it
>>    perf tools: Attach eBPF program to perf event
>>    perf record: Add LLVM options for compiling BPF scripts
>>
>>   tools/build/Makefile.feature   |    6 +-
>>   tools/build/feature/Makefile   |    6 +-
>>   tools/build/feature/test-bpf.c |   18 +
>>   tools/lib/bpf/.gitignore       |    2 +
>>   tools/lib/bpf/Build            |    1 +
>>   tools/lib/bpf/Makefile         |  195 ++++++++
>>   tools/lib/bpf/bpf.c            |   84 ++++
>>   tools/lib/bpf/bpf.h            |   23 +
>>   tools/lib/bpf/libbpf.c         | 1037 ++++++++++++++++++++++++++++++++++++++++
>>   tools/lib/bpf/libbpf.h         |   85 ++++
>>   tools/perf/MANIFEST            |    3 +
>>   tools/perf/Makefile.perf       |   17 +-
>>   tools/perf/builtin-probe.c     |    2 +-
>>   tools/perf/builtin-record.c    |   40 +-
>>   tools/perf/config/Makefile     |   19 +-
>>   tools/perf/tests/make          |    4 +-
>>   tools/perf/util/Build          |    1 +
>>   tools/perf/util/bpf-loader.c   |  477 ++++++++++++++++++
>>   tools/perf/util/bpf-loader.h   |   54 +++
>>   tools/perf/util/config.c       |    3 +
>>   tools/perf/util/debug.c        |    5 +
>>   tools/perf/util/debug.h        |    1 +
>>   tools/perf/util/evlist.c       |   51 ++
>>   tools/perf/util/evlist.h       |    1 +
>>   tools/perf/util/evsel.c        |   17 +
>>   tools/perf/util/evsel.h        |    1 +
>>   tools/perf/util/parse-events.c |   16 +
>>   tools/perf/util/parse-events.h |    2 +
>>   tools/perf/util/parse-events.l |    6 +
>>   tools/perf/util/parse-events.y |   29 +-
>>   tools/perf/util/probe-event.c  |   57 ++-
>>   tools/perf/util/probe-event.h  |    5 +-
>>   32 files changed, 2229 insertions(+), 39 deletions(-)
>>   create mode 100644 tools/build/feature/test-bpf.c
>>   create mode 100644 tools/lib/bpf/.gitignore
>>   create mode 100644 tools/lib/bpf/Build
>>   create mode 100644 tools/lib/bpf/Makefile
>>   create mode 100644 tools/lib/bpf/bpf.c
>>   create mode 100644 tools/lib/bpf/bpf.h
>>   create mode 100644 tools/lib/bpf/libbpf.c
>>   create mode 100644 tools/lib/bpf/libbpf.h
>>   create mode 100644 tools/perf/util/bpf-loader.c
>>   create mode 100644 tools/perf/util/bpf-loader.h
>>
>> -- 
>> 1.8.3.4



  reply	other threads:[~2015-06-09 23:46 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09  5:50 [RFC PATCH v6 00/32] perf tools: filtering events using eBPF programs Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 01/32] tools build: Add feature check for eBPF API Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 02/32] bpf tools: Introduce 'bpf' library to tools Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 03/32] bpf tools: Allow caller to set printing function Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 04/32] bpf tools: Open eBPF object file and do basic validation Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 05/32] bpf tools: Read eBPF object from buffer Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 06/32] bpf tools: Check endianess and make libbpf fail early Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 07/32] bpf tools: Iterate over ELF sections to collect information Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 08/32] bpf tools: Collect version and license from ELF sections Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 09/32] bpf tools: Collect map definitions from 'maps' section Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 10/32] bpf tools: Collect symbol table from SHT_SYMTAB section Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 11/32] bpf tools: Collect eBPF programs from their own sections Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 12/32] bpf tools: Collect relocation sections from SHT_REL sections Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 13/32] bpf tools: Record map accessing instructions for each program Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 14/32] bpf tools: Add bpf.c/h for common bpf operations Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 15/32] bpf tools: Create eBPF maps defined in an object file Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 16/32] bpf tools: Relocate eBPF programs Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 17/32] bpf tools: Introduce bpf_load_program() to bpf.c Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 18/32] bpf tools: Load eBPF programs in object files into kernel Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 19/32] bpf tools: Introduce accessors for struct bpf_program Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 20/32] bpf tools: Introduce accessors for struct bpf_object Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 21/32] bpf tools: Link all bpf objects onto a list Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 22/32] perf tools: Make perf depend on libbpf Wang Nan
2015-06-09 10:29   ` Wangnan (F)
2015-06-09  5:50 ` [RFC PATCH v6 23/32] perf record: Enable passing bpf object file to --event Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 24/32] perf record: Compile scriptlets if pass '.c' " Wang Nan
2015-06-09 21:48   ` Alexei Starovoitov
2015-06-10  0:06     ` Wangnan (F)
2015-06-10  0:28       ` Alexei Starovoitov
2015-06-11  7:19       ` Namhyung Kim
2015-06-11  7:35         ` Wangnan (F)
2015-06-11 17:42           ` Alexei Starovoitov
2015-06-09  5:50 ` [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config Wang Nan
2015-06-09 23:43   ` Alexei Starovoitov
2015-06-10  0:47     ` Wangnan (F)
2015-06-10  1:09       ` Alexei Starovoitov
2015-06-10  2:23         ` Wangnan (F)
2015-06-10  3:55           ` Alexei Starovoitov
2015-06-11  7:45     ` Namhyung Kim
2015-06-11  8:09       ` Wangnan (F)
2015-06-11 14:50         ` Namhyung Kim
2015-06-09  5:50 ` [RFC PATCH v6 26/32] perf tools: Parse probe points of eBPF programs during preparation Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 27/32] perf probe: Attach trace_probe_event with perf_probe_event Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 28/32] perf record: Probe at kprobe points Wang Nan
2015-06-11 14:32   ` Namhyung Kim
2015-06-09  5:50 ` [RFC PATCH v6 29/32] perf record: Load all eBPF object into kernel Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 30/32] perf tools: Add bpf_fd field to evsel and config it Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 31/32] perf tools: Attach eBPF program to perf event Wang Nan
2015-06-09  5:50 ` [RFC PATCH v6 32/32] perf record: Add LLVM options for compiling BPF scripts Wang Nan
2015-06-09 13:32   ` Wangnan (F)
2015-06-10  0:02   ` Alexei Starovoitov
2015-06-10  0:17     ` Wangnan (F)
2015-06-10  1:34       ` Alexei Starovoitov
2015-06-09 13:59 ` [RFC PATCH v6 00/32] perf tools: filtering events using eBPF programs Arnaldo Carvalho de Melo
2015-06-09 23:45   ` Wangnan (F) [this message]
2015-06-09 21:30 ` Alexei Starovoitov
2015-06-09 21:44   ` Arnaldo Carvalho de Melo
2015-06-09 23:16     ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55777A7D.6040802@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ast@plumgrid.com \
    --cc=brendan.d.gregg@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@gmail.com \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    --cc=pi3orama@163.com \
    --cc=xiakaixu@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).