perf clang: Support compiling BPF script on the fly
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest18 patches 2 repliesIn review
- v114 patches 5 repliesSuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/18 | tools build: Support compiling C++ source filetools/ tools/ | +8 | 0 replies | |
| 2/18 | perf tools: Add feature detection for g++tools/ tools/ tools/ | +25 | 0 replies | |
| 3/18 | perf tools: Add feature detection for LLVMtools/ tools/ | +16 | 0 replies | |
| 4/18 | perf tools: Add feature detection for clangtools/ tools/ | +31 | 0 replies | |
| 5/18 | perf build: Add clang and llvm compile and linking supporttools/ tools/ tools/ | +59 | 0 replies | |
| 6/18 | perf clang: Add builtin clang support ant test casetools/ tools/ tools/ +7 more | +218 | 0 replies | |
| 7/18 | perf clang: Use real file system for #includetools/ tools/ | +35 | 0 replies | |
| 8/18 | perf clang: Allow passing CFLAGS to builtin clangtools/ tools/ tools/ | +22 | 0 replies | |
| 9/18 | perf clang: Update test case to use real BPF scripttools/ tools/ tools/ +1 more | +68 | 0 replies | |
| 10/18 | perf clang: Support compile IR to BPF object and add testcasetools/ tools/ tools/ +2 more | +80 | 0 replies | |
| 11/18 | perf tools: Extract helpers in llvm-utils.ctools/ tools/ | +62 | 0 replies | |
| 12/18 | perf bpf: Compile BPF script use builtin clang supporttools/ tools/ tools/ | +66 | 0 replies | |
| 13/18 | perf clang: Pass full path to builtin clangtools/ | +6 | 0 replies | |
| 14/18 | perf clang: Pass CFLAGS to builtin clangtools/ tools/ tools/ | +116 | 0 replies | |
| 15/18 | perf clang: Link BPF functions declaration into perftools/ tools/ tools/ | +227 | 0 replies | |
| 16/18 | perf clang: Declare BPF functions for BPF scripts automaticallytools/ tools/ tools/ +1 more | +55 | 0 replies | |
| 17/18 | perf clang: Include helpers to BPF scriptstools/ tools/ tools/ +5 more | +24 | 0 replies | |
| 18/18 | perf clang: Define PERF_BUILTIN_CLANG for builtin clang compilingtools/ | +1 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 00/18] perf clang: Support compiling BPF script on the fly
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:
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/[email protected]/msg1238358.html
(should be http://lkml.kernel.org/g/[email protected]
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
Signature · 1 line
1.8.3.4