[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161005232057.GL30363@kernel.org>
Date: Wed, 5 Oct 2016 20:20:57 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Wang Nan <wangnan0@...wei.com>
Cc: alexei.starovoitov@...il.com, lizefan@...wei.com,
linux-kernel@...r.kernel.org, pi3orama@....com,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Alexei Starovoitov <ast@...com>, He Kuang <hekuang@...wei.com>,
Jiri Olsa <jolsa@...nel.org>
Subject: Re: [PATCH v2 00/18] perf clang: Support compiling BPF script on the
fly
Em Mon, Sep 26, 2016 at 07:26:54AM +0000, Wang Nan escreveu:
> This patch add builtin clang, allow perf compile BPF scripts on the fly.
> This is the first step to implement what I announced at LinuxCon 2016 NA:
Ok, so I refreshed this series to apply against my latest perf/core and
put it in a tmp.perf/builtin-clang, will continue testing it tomorrow
after checking if fedora24 has those llvm-dev and libclang-dev that can
be used with this, do you know if it works on that distro?
Cool stuff! :-)
- Arnaldo
> http://events.linuxfoundation.org/sites/events/files/slides/Performance%20Monitoring%20and%20Analysis%20Using%20perf%20and%20BPF_1.pdf
>
> Compare with v1:
> 1. Fix API usage so can be built at Ubuntu 16.04 (with llvm-dev and
> libclang-dev installed)
> 2. Introduce default include files so BPF script writer doesn't need
> define many BPF functions by their own.
>
> Test:
>
> # cat ./test_bpf_output.c
> /************************ BEGIN **************************/
> #include <uapi/linux/bpf.h>
> struct bpf_map_def SEC("maps") __bpf_stdout__ = {
> .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
> .key_size = sizeof(int),
> .value_size = sizeof(u32),
> .max_entries = __NR_CPUS__,
> };
>
> static inline int __attribute__((always_inline))
> func(void *ctx, int type)
> {
> char output_str[] = "Raise a BPF event!";
>
> bpf_perf_event_output(ctx, &__bpf_stdout__, bpf_get_smp_processor_id(),
> &output_str, sizeof(output_str));
> return 0;
> }
> SEC("func_begin=sys_nanosleep")
> int func_begin(void *ctx) {return func(ctx, 1);}
> SEC("func_end=sys_nanosleep%return")
> int func_end(void *ctx) { return func(ctx, 2);}
> char _license[] SEC("license") = "GPL";
> int _version SEC("version") = LINUX_VERSION_CODE;
> /************************* END ***************************/
> # perf trace --event ./test_bpf_output.c usleep 10
> ...
> 0.449 ( 0.002 ms): usleep/827 getuid( ) = 0
> 0.482 ( 0.006 ms): usleep/827 nanosleep(rqtp: 0x7ffecc22fa50 ) ...
> 0.482 ( ): __bpf_stdout__:Raise a BPF event!..)
> 0.555 ( ): __bpf_stdout__:Raise a BPF event!..)
> 0.557 ( 0.081 ms): usleep/827 ... [continued]: nanosleep() = 0
> 0.562 ( 0.000 ms): usleep/827 exit_group( )
>
>
> v1 can be found at:
> https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1238358.html
> (should be http://lkml.kernel.org/g/1474635001-153850-1-git-send-email-wangnan0@huawei.com
> but the link is broken)
>
> Wang Nan (18):
> tools build: Support compiling C++ source file
> perf tools: Add feature detection for g++
> perf tools: Add feature detection for LLVM
> perf tools: Add feature detection for clang
> perf build: Add clang and llvm compile and linking support
> perf clang: Add builtin clang support ant test case
> perf clang: Use real file system for #include
> perf clang: Allow passing CFLAGS to builtin clang
> perf clang: Update test case to use real BPF script
> perf clang: Support compile IR to BPF object and add testcase
> perf tools: Extract helpers in llvm-utils.c
> perf bpf: Compile BPF script use builtin clang support
> perf clang: Pass full path to builtin clang
> perf clang: Pass CFLAGS to builtin clang
> perf clang: Link BPF functions declaration into perf
> perf clang: Declare BPF functions for BPF scripts automatically
> perf clang: Include helpers to BPF scripts
> perf clang: Define PERF_BUILTIN_CLANG for builtin clang compiling
>
> tools/build/Build.include | 1 +
> tools/build/Makefile.build | 7 +
> tools/build/Makefile.feature | 2 +-
> tools/build/feature/Makefile | 28 ++-
> tools/build/feature/test-clang.cpp | 21 ++
> tools/build/feature/test-cxx.cpp | 15 ++
> tools/build/feature/test-llvm.cpp | 8 +
> tools/perf/Makefile.config | 62 ++++-
> tools/perf/Makefile.perf | 23 +-
> tools/perf/tests/Build | 1 +
> tools/perf/tests/bpf-script-example.c | 20 +-
> tools/perf/tests/bpf-script-test-kbuild.c | 2 +
> tools/perf/tests/bpf-script-test-prologue.c | 4 +
> tools/perf/tests/bpf-script-test-relocation.c | 20 +-
> tools/perf/tests/builtin-test.c | 9 +
> tools/perf/tests/clang.c | 46 ++++
> tools/perf/tests/llvm-cxx.h | 13 +
> tools/perf/tests/make | 2 +
> tools/perf/tests/tests.h | 3 +
> tools/perf/util/Build | 2 +
> tools/perf/util/bpf-loader.c | 15 +-
> tools/perf/util/c++/Build | 4 +
> tools/perf/util/c++/bpf-funcs-str.c | 214 +++++++++++++++++
> tools/perf/util/c++/bpf-helper-str.c | 13 +
> tools/perf/util/c++/clang-bpf-includes.h | 13 +
> tools/perf/util/c++/clang-c.h | 43 ++++
> tools/perf/util/c++/clang-test.cpp | 62 +++++
> tools/perf/util/c++/clang.cpp | 329 ++++++++++++++++++++++++++
> tools/perf/util/c++/clang.h | 26 ++
> tools/perf/util/llvm-utils-cxx.h | 14 ++
> tools/perf/util/llvm-utils.c | 70 +++++-
> tools/perf/util/llvm-utils.h | 7 +-
> tools/perf/util/util-cxx.h | 26 ++
> 33 files changed, 1078 insertions(+), 47 deletions(-)
> create mode 100644 tools/build/feature/test-clang.cpp
> create mode 100644 tools/build/feature/test-cxx.cpp
> create mode 100644 tools/build/feature/test-llvm.cpp
> create mode 100644 tools/perf/tests/clang.c
> create mode 100644 tools/perf/tests/llvm-cxx.h
> create mode 100644 tools/perf/util/c++/Build
> create mode 100644 tools/perf/util/c++/bpf-funcs-str.c
> create mode 100644 tools/perf/util/c++/bpf-helper-str.c
> create mode 100644 tools/perf/util/c++/clang-bpf-includes.h
> create mode 100644 tools/perf/util/c++/clang-c.h
> create mode 100644 tools/perf/util/c++/clang-test.cpp
> create mode 100644 tools/perf/util/c++/clang.cpp
> create mode 100644 tools/perf/util/c++/clang.h
> create mode 100644 tools/perf/util/llvm-utils-cxx.h
> create mode 100644 tools/perf/util/util-cxx.h
>
> Cc: Wang Nan <wangnan0@...wei.com>
> Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> Cc: Alexei Starovoitov <ast@...com>
> Cc: He Kuang <hekuang@...wei.com>
> Cc: Jiri Olsa <jolsa@...nel.org>
> --
> 1.8.3.4
Powered by blists - more mailing lists