[PATCH 23/34] perf clang jit: Insignt BPF and JIT functions in a Module

2016-11-14 Thread Wang Nan
nkage like this so they won't be compiled into BPF objects. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jiri Olsa <jo...@kernel.org> Cc: Zefan Li &

[PATCH 25/34] perf clang jit: Export functions for jitted code

2016-11-14 Thread Wang Nan
After this patch functions attached on perf hooks is allowed to invoke external functions. Add a testcase for this feature. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...

[PATCH 09/34] perf tools: Pass context to perf hook functions

2016-11-14 Thread Wang Nan
Pass a pointer to perf hook functions so they receive context information created durnig setup. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/tests/perf-hooks.c | 14

[PATCH 27/34] perf clang jit: Collect the lowest address in maps section as map_base

2016-11-14 Thread Wang Nan
During jitting, find the lowest address in maps section and store its value to _map_base. Pass its value out through perf_clang__compile_bpf(). map_base is useful for jitted functions accessing BPF maps. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang

[PATCH 23/34] perf clang jit: Insignt BPF and JIT functions in a Module

2016-11-14 Thread Wang Nan
nkage like this so they won't be compiled into BPF objects. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/util/c++/clang.cpp | 32 tools/perf/util/c++/clan

[PATCH 25/34] perf clang jit: Export functions for jitted code

2016-11-14 Thread Wang Nan
After this patch functions attached on perf hooks is allowed to invoke external functions. Add a testcase for this feature. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/tests/Build

[PATCH 21/34] perf clang: Pass CFLAGS to builtin clang

2016-11-14 Thread Wang Nan
iled: -95, try external compiler I.e. it falls back to using the external compiler. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jiri Olsa <jo...@kernel.

[PATCH 21/34] perf clang: Pass CFLAGS to builtin clang

2016-11-14 Thread Wang Nan
iled: -95, try external compiler I.e. it falls back to using the external compiler. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/util/c++/clang.cpp | 105 +++

[PATCH 04/34] tools lib bpf: fix maps resolution

2016-11-14 Thread Wang Nan
rectly. Wang Nan added: This patch requires a name for each BPF map, so array of BPF maps is not allowed. This restriction is reasonable, because kernel verifier forbid indexing BPF map from such array unless the index is a fixed value, but if the index is fixed why not merging it int

[PATCH 28/34] perf clang jit: Access BPF map

2016-11-14 Thread Wang Nan
--- tools/perf/util/bpf-loader.c | 37 + tools/perf/util/bpf-loader.h | 19 +++ 2 files changed, 56 insertions(+) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 81c6fed..86aa99b 100644 ---

[PATCH 16/34] perf clang: Allow passing CFLAGS to builtin clang

2016-11-14 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jiri Olsa <jo...@kernel.or

[PATCH 04/34] tools lib bpf: fix maps resolution

2016-11-14 Thread Wang Nan
From: Eric Leblond It is not correct to assimilate the elf data of the maps section to an array of map definition. In fact the sizes differ. The offset provided in the symbol section has to be used instead. This patch fixes a bug causing a elf with two maps not to load correctly. Wang Nan

[PATCH 28/34] perf clang jit: Access BPF map

2016-11-14 Thread Wang Nan
--- tools/perf/util/bpf-loader.c | 37 + tools/perf/util/bpf-loader.h | 19 +++ 2 files changed, 56 insertions(+) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 81c6fed..86aa99b 100644 ---

[PATCH 16/34] perf clang: Allow passing CFLAGS to builtin clang

2016-11-14 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa Cc: Zefan Li Cc: pi3or...@163.com Link: http://lkml.kernel.org/r/1474874832-134786-9-git

[PATCH 02/34] perf record: Fix segfault when running with suid and kptr_restrict is 1

2016-11-14 Thread Wang Nan
uid. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> --- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index aecff69..420ada9 100644 --- a/tools/per

[PATCH 00/34] perf clang: Builtin clang and perfhook support

2016-11-14 Thread Wang Nan
count: 18 syscall 3 count: 11 [ perf record: Captured and wrote 0.011 MB perf.data ] Eric Leblond (1): tools lib bpf: fix maps resolution Wang Nan (33): perf tools: Fix kernel version error in ubuntu perf record: Fix segfault when running with suid and kptr_restrict is 1 tool

[PATCH 02/34] perf record: Fix segfault when running with suid and kptr_restrict is 1

2016-11-14 Thread Wang Nan
uid. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index aecff69..420ada9 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbo

[PATCH 00/34] perf clang: Builtin clang and perfhook support

2016-11-14 Thread Wang Nan
count: 18 syscall 3 count: 11 [ perf record: Captured and wrote 0.011 MB perf.data ] Eric Leblond (1): tools lib bpf: fix maps resolution Wang Nan (33): perf tools: Fix kernel version error in ubuntu perf record: Fix segfault when running with suid and kptr_restrict is 1 tool

[PATCH] tools lib bpf: fix maps resolution

2016-11-08 Thread Wang Nan
rectly. Wang Nan added: This patch requires a name for each BPF map, so array of BPF maps is not allowed. This restriction is reasonable, because kernel verifier forbid indexing BPF map from such array unless the index is a fixed value, but if the index is fixed why not merging it int

[PATCH] tools lib bpf: fix maps resolution

2016-11-08 Thread Wang Nan
From: Eric Leblond It is not correct to assimilate the elf data of the maps section to an array of map definition. In fact the sizes differ. The offset provided in the symbol section has to be used instead. This patch fixes a bug causing a elf with two maps not to load correctly. Wang Nan

[PATCH v3][manpages 2/2] perf_event_open.2: Document write_backward

2016-10-24 Thread Wang Nan
Linux 4.7 (9ecda41acb971ebd07c8fb35faf24005c0baea12) introduces write_backward attribute to perf_event_attr. Document this feature. Signed-off-by: Wang Nan <wangn...@huawei.com> Reviewed-by: Vince Weaver <vincent.wea...@maine.edu> Cc: Michael Kerrisk <mtk.manpa...@gmail

[PATCH v3][manpages 2/2] perf_event_open.2: Document write_backward

2016-10-24 Thread Wang Nan
Linux 4.7 (9ecda41acb971ebd07c8fb35faf24005c0baea12) introduces write_backward attribute to perf_event_attr. Document this feature. Signed-off-by: Wang Nan Reviewed-by: Vince Weaver Cc: Michael Kerrisk --- man2/perf_event_open.2 | 57 -- 1 file

[PATCH v3][manpages 1/2] perf_event_open.2: Document PERF_EVENT_IOC_PAUSE_OUTPUT

2016-10-24 Thread Wang Nan
Linux 4.7 (86e7972f690c1017fd086cdfe53d8524e68c661c) introduces PERF_EVENT_IOC_PAUSE_OUTPUT feature. Document it. Signed-off-by: Wang Nan <wangn...@huawei.com> Reviewed-by: Vince Weaver <vincent.wea...@maine.edu> Cc: Michael Kerrisk <mtk.manpa...@gmail.com> --- man2/perf

[PATCH v3][manpages 0/2] Document new feature in perf_event_open

2016-10-24 Thread Wang Nan
Decribe PERF_EVENT_IOC_PAUSE_OUTPUT and write_backward in man pages. v2 -> v3: Correct words. Explain the relationship between readonly ring buffer and over-writable ring buffer in patch 1/2. Wang Nan (2): perf_event_open.2: Document PERF_EVENT_IOC_PAUSE_OUTPUT perf_event_ope

[PATCH v3][manpages 0/2] Document new feature in perf_event_open

2016-10-24 Thread Wang Nan
Decribe PERF_EVENT_IOC_PAUSE_OUTPUT and write_backward in man pages. v2 -> v3: Correct words. Explain the relationship between readonly ring buffer and over-writable ring buffer in patch 1/2. Wang Nan (2): perf_event_open.2: Document PERF_EVENT_IOC_PAUSE_OUTPUT perf_event_ope

[PATCH v3][manpages 1/2] perf_event_open.2: Document PERF_EVENT_IOC_PAUSE_OUTPUT

2016-10-24 Thread Wang Nan
Linux 4.7 (86e7972f690c1017fd086cdfe53d8524e68c661c) introduces PERF_EVENT_IOC_PAUSE_OUTPUT feature. Document it. Signed-off-by: Wang Nan Reviewed-by: Vince Weaver Cc: Michael Kerrisk --- man2/perf_event_open.2 | 24 1 file changed, 24 insertions(+) diff --git a/man2

[PATCH 1/2] perf_event_open.2: Document PERF_EVENT_IOC_PAUSE_OUTPUT

2016-10-21 Thread Wang Nan
Linux 4.7 (86e7972f690c1017fd086cdfe53d8524e68c661c) introduces PERF_EVENT_IOC_PAUSE_OUTPUT feature. Document it. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Michael Kerrisk <mtk.manpa...@gmail.com> --- man2/perf_event_open.2 | 13 - 1 file changed, 12 insertions(+)

[PATCH 2/2] perf_event_open.2: Document write_backward

2016-10-21 Thread Wang Nan
Linux 4.7 (9ecda41acb971ebd07c8fb35faf24005c0baea12) introduces write_backward attribute to perf_event_attr. Document this feature. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Michael Kerrisk <mtk.manpa...@gmail.com> --- man2/perf_event

[PATCH 1/2] perf_event_open.2: Document PERF_EVENT_IOC_PAUSE_OUTPUT

2016-10-21 Thread Wang Nan
Linux 4.7 (86e7972f690c1017fd086cdfe53d8524e68c661c) introduces PERF_EVENT_IOC_PAUSE_OUTPUT feature. Document it. Signed-off-by: Wang Nan Cc: Michael Kerrisk --- man2/perf_event_open.2 | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/man2/perf_event_open.2 b

[PATCH 2/2] perf_event_open.2: Document write_backward

2016-10-21 Thread Wang Nan
Linux 4.7 (9ecda41acb971ebd07c8fb35faf24005c0baea12) introduces write_backward attribute to perf_event_attr. Document this feature. Signed-off-by: Wang Nan Cc: Michael Kerrisk --- man2/perf_event_open.2 | 56 +++--- 1 file changed, 53 insertions

[tip:perf/urgent] perf jevents: Handle events including .c and .o

2016-10-17 Thread tip-bot for Wang Nan
Commit-ID: 2d470b62fa24f8d0024e8d392d28814c287ee1f1 Gitweb: http://git.kernel.org/tip/2d470b62fa24f8d0024e8d392d28814c287ee1f1 Author: Wang Nan <wangn...@huawei.com> AuthorDate: Sat, 8 Oct 2016 04:16:25 + Committer: Arnaldo Carvalho de Melo <a...@redhat.com> CommitDate:

[tip:perf/urgent] perf jevents: Handle events including .c and .o

2016-10-17 Thread tip-bot for Wang Nan
Commit-ID: 2d470b62fa24f8d0024e8d392d28814c287ee1f1 Gitweb: http://git.kernel.org/tip/2d470b62fa24f8d0024e8d392d28814c287ee1f1 Author: Wang Nan AuthorDate: Sat, 8 Oct 2016 04:16:25 + Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 17 Oct 2016 11:24:18 -0300 perf jevents

[PATCH] perf, tools: Handle events including .c and .o

2016-10-07 Thread Wang Nan
-I 1000 ERROR: problems with path aaa.c: No such file or directory event syntax error: '{cycles,aaa.c}' (as expected, interperted as BPF source) Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Sukadev Bhattiprolu <suka...@linux.vnet.ibm.com> Cc: Andi Kleen <a...@linux.inte

[PATCH] perf, tools: Handle events including .c and .o

2016-10-07 Thread Wang Nan
-I 1000 ERROR: problems with path aaa.c: No such file or directory event syntax error: '{cycles,aaa.c}' (as expected, interperted as BPF source) Signed-off-by: Wang Nan Cc: Sukadev Bhattiprolu Cc: Andi Kleen Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa --- tools/perf/util/parse-events.l

[tip:perf/urgent] tools build: Support compiling C++ source file

2016-10-06 Thread tip-bot for Wang Nan
Commit-ID: f61bdc3304281e9ff9eec4f1ed9fb15bcf4d8a5e Gitweb: http://git.kernel.org/tip/f61bdc3304281e9ff9eec4f1ed9fb15bcf4d8a5e Author: Wang Nan <wangn...@huawei.com> AuthorDate: Mon, 26 Sep 2016 07:26:55 + Committer: Arnaldo Carvalho de Melo <a...@redhat.com> CommitDate

[tip:perf/urgent] tools build: Support compiling C++ source file

2016-10-06 Thread tip-bot for Wang Nan
Commit-ID: f61bdc3304281e9ff9eec4f1ed9fb15bcf4d8a5e Gitweb: http://git.kernel.org/tip/f61bdc3304281e9ff9eec4f1ed9fb15bcf4d8a5e Author: Wang Nan AuthorDate: Mon, 26 Sep 2016 07:26:55 + Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 5 Oct 2016 19:58:51 -0300 tools build

[tip:perf/urgent] tools build: Add feature detection for g++

2016-10-06 Thread tip-bot for Wang Nan
Commit-ID: 87095f7ddeff3038a0cf8e6574922f9c11688619 Gitweb: http://git.kernel.org/tip/87095f7ddeff3038a0cf8e6574922f9c11688619 Author: Wang Nan <wangn...@huawei.com> AuthorDate: Mon, 26 Sep 2016 07:26:56 + Committer: Arnaldo Carvalho de Melo <a...@redhat.com> CommitDate

[tip:perf/urgent] tools build: Add feature detection for g++

2016-10-06 Thread tip-bot for Wang Nan
Commit-ID: 87095f7ddeff3038a0cf8e6574922f9c11688619 Gitweb: http://git.kernel.org/tip/87095f7ddeff3038a0cf8e6574922f9c11688619 Author: Wang Nan AuthorDate: Mon, 26 Sep 2016 07:26:56 + Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 5 Oct 2016 19:59:35 -0300 tools build: Add

[tip:perf/core] perf data: Fix building in 32 bit platform with libbabeltrace

2016-09-29 Thread tip-bot for Wang Nan
Commit-ID: f2c8852e6e990fcab0d9e68de9d86e5fbea0b5dc Gitweb: http://git.kernel.org/tip/f2c8852e6e990fcab0d9e68de9d86e5fbea0b5dc Author: Wang Nan <wangn...@huawei.com> AuthorDate: Wed, 28 Sep 2016 03:58:46 + Committer: Arnaldo Carvalho de Melo <a...@redhat.com> CommitDate:

[tip:perf/core] perf data: Fix building in 32 bit platform with libbabeltrace

2016-09-29 Thread tip-bot for Wang Nan
Commit-ID: f2c8852e6e990fcab0d9e68de9d86e5fbea0b5dc Gitweb: http://git.kernel.org/tip/f2c8852e6e990fcab0d9e68de9d86e5fbea0b5dc Author: Wang Nan AuthorDate: Wed, 28 Sep 2016 03:58:46 + Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 28 Sep 2016 10:38:20 -0300 perf data: Fix

[PATCH] perf tools: Fix building in 32 bit platform

2016-09-27 Thread Wang Nan
as errors Fix it by changing %lu to %zu. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Jiri Olsa <jo...@kernel.org> --- tools/perf/util/data-convert-bt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf

[PATCH] perf tools: Fix building in 32 bit platform

2016-09-27 Thread Wang Nan
as errors Fix it by changing %lu to %zu. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa --- tools/perf/util/data-convert-bt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 4f979bb

[PATCH v2 09/18] perf clang: Update test case to use real BPF script

2016-09-26 Thread Wang Nan
Allow C++ code to use util.h and tests/llvm.h. Let perf test to compile a real BPF script. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jir

[PATCH v2 09/18] perf clang: Update test case to use real BPF script

2016-09-26 Thread Wang Nan
Allow C++ code to use util.h and tests/llvm.h. Let perf test to compile a real BPF script. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/Makefile.config | 27 +++ tools/perf/tests/llvm

[PATCH v2 06/18] perf clang: Add builtin clang support ant test case

2016-09-26 Thread Wang Nan
Add basic clang support in clang.cpp and test__clang() testcase. The first testcase checks if builtin clang is able to generate LLVM IR. tests/clang.c is a proxy. Real testcase resides in utils/c++/clang-test.cpp in c++ and exports C interface to perf test subsystem. Signed-off-by: Wang Nan

[PATCH v2 01/18] tools build: Support compiling C++ source file

2016-09-26 Thread Wang Nan
Add new rule to compile .cpp file to .o use g++. C++ support is required for built-in clang and LLVM support. Linker side support will be introduced by following commits. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei

[PATCH v2 07/18] perf clang: Use real file system for #include

2016-09-26 Thread Wang Nan
Utilize clang's OverlayFileSystem facility to enable VFS passed to CompilerInstance can access files in real file system, so '#include' directive can be used. Add a new getModuleFromSource for real file. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@r

[PATCH v2 01/18] tools build: Support compiling C++ source file

2016-09-26 Thread Wang Nan
Add new rule to compile .cpp file to .o use g++. C++ support is required for built-in clang and LLVM support. Linker side support will be introduced by following commits. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build

[PATCH v2 07/18] perf clang: Use real file system for #include

2016-09-26 Thread Wang Nan
Utilize clang's OverlayFileSystem facility to enable VFS passed to CompilerInstance can access files in real file system, so '#include' directive can be used. Add a new getModuleFromSource for real file. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang

[PATCH v2 06/18] perf clang: Add builtin clang support ant test case

2016-09-26 Thread Wang Nan
Add basic clang support in clang.cpp and test__clang() testcase. The first testcase checks if builtin clang is able to generate LLVM IR. tests/clang.c is a proxy. Real testcase resides in utils/c++/clang-test.cpp in c++ and exports C interface to perf test subsystem. Signed-off-by: Wang Nan Cc

[PATCH v2 10/18] perf clang: Support compile IR to BPF object and add testcase

2016-09-26 Thread Wang Nan
getBPFObjectFromModule() is introduced to use LLVM to convert Module (LLVM IR) to BPF object code. Add new testcase for it. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...

[PATCH v2 12/18] perf bpf: Compile BPF script use builtin clang support

2016-09-26 Thread Wang Nan
e.c >> ./test.c $ ./perf record -v --dry-run -e ./test.c 2>&1 | grep builtin bpf: builtin compiling successful Can't pass cflags so unable to include kernel headers now. Will be fixed by following commits. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a.

[PATCH v2 13/18] perf clang: Pass full path to builtin clang

2016-09-26 Thread Wang Nan
If clang changes its working directory, filename passed to perf_clang__compile_bpf() becomes invalid. Before running clang, convert it to absolute path so file can be found even working directory is changed. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho d

[PATCH v2 16/18] perf clang: Declare BPF functions for BPF scripts automatically

2016-09-26 Thread Wang Nan
Use Clang's OverlayFileSystem, add '-include' options to make builtin clang define BPF functions. After this patch BPF script writer needn't define BPF functions by their own. Test cases are updated to avoid redefine these functions. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: A

[PATCH v2 14/18] perf clang: Pass CFLAGS to builtin clang

2016-09-26 Thread Wang Nan
ls 2>&1 | grep built bpf: builtin compiling successful Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jiri Olsa <jo...@kernel.org> --- t

[PATCH v2 10/18] perf clang: Support compile IR to BPF object and add testcase

2016-09-26 Thread Wang Nan
getBPFObjectFromModule() is introduced to use LLVM to convert Module (LLVM IR) to BPF object code. Add new testcase for it. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/tests/clang.c | 6 - tools/perf

[PATCH v2 12/18] perf bpf: Compile BPF script use builtin clang support

2016-09-26 Thread Wang Nan
e.c >> ./test.c $ ./perf record -v --dry-run -e ./test.c 2>&1 | grep builtin bpf: builtin compiling successful Can't pass cflags so unable to include kernel headers now. Will be fixed by following commits. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

[PATCH v2 13/18] perf clang: Pass full path to builtin clang

2016-09-26 Thread Wang Nan
If clang changes its working directory, filename passed to perf_clang__compile_bpf() becomes invalid. Before running clang, convert it to absolute path so file can be found even working directory is changed. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

[PATCH v2 16/18] perf clang: Declare BPF functions for BPF scripts automatically

2016-09-26 Thread Wang Nan
Use Clang's OverlayFileSystem, add '-include' options to make builtin clang define BPF functions. After this patch BPF script writer needn't define BPF functions by their own. Test cases are updated to avoid redefine these functions. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc

[PATCH v2 14/18] perf clang: Pass CFLAGS to builtin clang

2016-09-26 Thread Wang Nan
ls 2>&1 | grep built bpf: builtin compiling successful Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/util/c++/clang.cpp| 105 +-- tools/perf/util/llvm-utils-cxx.

[PATCH v2 18/18] perf clang: Define PERF_BUILTIN_CLANG for builtin clang compiling

2016-09-26 Thread Wang Nan
By this macro BPF script knows what compiler it is being built with. Scripts prefer external clang can force fall back to it by: #ifdef PERF_BUILTIN_CLANG # error I prefer external clang compiler #endif Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho d

[PATCH v2 15/18] perf clang: Link BPF functions declaration into perf

2016-09-26 Thread Wang Nan
Use a shell script to generate BPF functions declarations from kernel source code, embedded the generated header into a C string. Following commits will utilizes clang's virtual file system to automatically include this header to all BPF scripts. Signed-off-by: Wang Nan <wangn...@huawei.com&

[PATCH v2 05/18] perf build: Add clang and llvm compile and linking support

2016-09-26 Thread Wang Nan
Add necessary c++ flags and link libraries to support builtin clang and LLVM. Add all llvm and clang libraries, so don't need to worry about clang changes its libraries setting. However, linking perf would take much longer than usual. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: A

[PATCH v2 00/18] perf clang: Support compiling BPF script on the fly

2016-09-26 Thread Wang Nan
ww.mail-archive.com/linux-kernel@vger.kernel.org/msg1238358.html (should be http://lkml.kernel.org/g/1474635001-153850-1-git-send-email-wangn...@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

[PATCH v2 02/18] perf tools: Add feature detection for g++

2016-09-26 Thread Wang Nan
Check if g++ is available. The result will be used by builtin clang and LLVM support. Since LLVM requires C++11, this feature detector checks std::move(). Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@plumg

[PATCH v2 11/18] perf tools: Extract helpers in llvm-utils.c

2016-09-26 Thread Wang Nan
Following commits will use builtin clang to compile BPF script. llvm__get_kbuild_opts() and llvm__get_nr_cpus() are extracted to help building '-DKERNEL_VERSION_CODE' and '-D__NR_CPUS__' macros. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redha

[PATCH v2 18/18] perf clang: Define PERF_BUILTIN_CLANG for builtin clang compiling

2016-09-26 Thread Wang Nan
By this macro BPF script knows what compiler it is being built with. Scripts prefer external clang can force fall back to it by: #ifdef PERF_BUILTIN_CLANG # error I prefer external clang compiler #endif Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

[PATCH v2 15/18] perf clang: Link BPF functions declaration into perf

2016-09-26 Thread Wang Nan
Use a shell script to generate BPF functions declarations from kernel source code, embedded the generated header into a C string. Following commits will utilizes clang's virtual file system to automatically include this header to all BPF scripts. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de

[PATCH v2 05/18] perf build: Add clang and llvm compile and linking support

2016-09-26 Thread Wang Nan
Add necessary c++ flags and link libraries to support builtin clang and LLVM. Add all llvm and clang libraries, so don't need to worry about clang changes its libraries setting. However, linking perf would take much longer than usual. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc

[PATCH v2 00/18] perf clang: Support compiling BPF script on the fly

2016-09-26 Thread Wang Nan
ww.mail-archive.com/linux-kernel@vger.kernel.org/msg1238358.html (should be http://lkml.kernel.org/g/1474635001-153850-1-git-send-email-wangn...@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

[PATCH v2 02/18] perf tools: Add feature detection for g++

2016-09-26 Thread Wang Nan
Check if g++ is available. The result will be used by builtin clang and LLVM support. Since LLVM requires C++11, this feature detector checks std::move(). Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/Makefile.feature

[PATCH v2 11/18] perf tools: Extract helpers in llvm-utils.c

2016-09-26 Thread Wang Nan
Following commits will use builtin clang to compile BPF script. llvm__get_kbuild_opts() and llvm__get_nr_cpus() are extracted to help building '-DKERNEL_VERSION_CODE' and '-D__NR_CPUS__' macros. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri

[PATCH v2 17/18] perf clang: Include helpers to BPF scripts

2016-09-26 Thread Wang Nan
Automatically include common used macros and struct definitions into BPF scripts. Script writers are no longer required to define 'SEC' and 'struct bpf_map_def' in each of their scripts. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com>

[PATCH v2 17/18] perf clang: Include helpers to BPF scripts

2016-09-26 Thread Wang Nan
Automatically include common used macros and struct definitions into BPF scripts. Script writers are no longer required to define 'SEC' and 'struct bpf_map_def' in each of their scripts. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa

[PATCH v2 03/18] perf tools: Add feature detection for LLVM

2016-09-26 Thread Wang Nan
enough. Old LLVM doesn't support BPF backend. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jiri Olsa <jo...@kernel.org> --- tools/build/feature/Mak

[PATCH v2 04/18] perf tools: Add feature detection for clang

2016-09-26 Thread Wang Nan
libraries ordering, use --start-group and --end-group. In this test case, manually identify required clang libs and hope it to be stable. Putting all clang libraries here is possible (use make's wildcard), but then feature checking becomes very slow. Signed-off-by: Wang Nan <wangn...@huawei.

[PATCH v2 03/18] perf tools: Add feature detection for LLVM

2016-09-26 Thread Wang Nan
enough. Old LLVM doesn't support BPF backend. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/feature/Makefile | 8 tools/build/feature/test-llvm.cpp | 8 2 files changed, 16 insertions(+) create mode

[PATCH v2 04/18] perf tools: Add feature detection for clang

2016-09-26 Thread Wang Nan
libraries ordering, use --start-group and --end-group. In this test case, manually identify required clang libs and hope it to be stable. Putting all clang libraries here is possible (use make's wildcard), but then feature checking becomes very slow. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho

[PATCH v2 08/18] perf clang: Allow passing CFLAGS to builtin clang

2016-09-26 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <h

[PATCH v2 08/18] perf clang: Allow passing CFLAGS to builtin clang

2016-09-26 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/util/c++/clang-test.cpp | 5 +++-- tools/perf

[PATCH 03/14] perf tools: Add feature detection for LLVM

2016-09-23 Thread Wang Nan
enough. Old LLVM doesn't support BPF backend. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jiri Olsa <jo...@kernel.org> --- tools/build/feature/Mak

[PATCH 03/14] perf tools: Add feature detection for LLVM

2016-09-23 Thread Wang Nan
enough. Old LLVM doesn't support BPF backend. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/feature/Makefile | 8 tools/build/feature/test-llvm.cpp | 8 2 files changed, 16 insertions(+) create mode

[PATCH 08/14] perf clang: Allow passing CFLAGS to builtin clang

2016-09-23 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <h

[PATCH 05/14] perf build: Add clang and llvm compile and linking support

2016-09-23 Thread Wang Nan
Add necessary c++ flags and link libraries to support builtin clang and LLVM. Add all llvm and clang libraries, so don't need to worry about clang changes its libraries setting. However, linking perf would take much longer than usual. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: A

[PATCH 08/14] perf clang: Allow passing CFLAGS to builtin clang

2016-09-23 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/util/c++/clang-test.cpp | 5 +++-- tools/perf

[PATCH 05/14] perf build: Add clang and llvm compile and linking support

2016-09-23 Thread Wang Nan
Add necessary c++ flags and link libraries to support builtin clang and LLVM. Add all llvm and clang libraries, so don't need to worry about clang changes its libraries setting. However, linking perf would take much longer than usual. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc

[PATCH 14/14] perf clang: Pass correct CFLAGS to builtin clang

2016-09-23 Thread Wang Nan
Pass CFLAGS detected by kbuild detector to builtin clang so BPF scripts can use kernel headers like external clang compiler. Test: # perf record --dry-run -e tools/perf/tests/bpf-script-test-kbuild.c ls 2>&1 | grep built bpf: builtin compiling successful Signed-off-by: Wang Nan

[PATCH 04/14] perf tools: Add feature detection for clang

2016-09-23 Thread Wang Nan
libraries ordering, use --start-group and --end-group. In this test case, manually identify required clang libs and hope it to be stable. Putting all clang libraries here is possible (use make's wildcard), but then feature checking becomes very slow. Signed-off-by: Wang Nan <wangn...@huawei.

[PATCH 10/14] perf clang: Support compile IR to BPF object and add testcase

2016-09-23 Thread Wang Nan
getBPFObjectFromModule() is introduced to use LLVM to convert Module (LLVM IR) to BPF object code. Add new testcase for it. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...

[PATCH 02/14] perf tools: Add feature detection for g++

2016-09-23 Thread Wang Nan
Check if g++ is available. The result will be used by builtin clang and LLVM support. Since LLVM requires C++11, this feature detector checks std::move(). Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@plumg

[PATCH 07/14] perf clang: Use real file system for #include

2016-09-23 Thread Wang Nan
Utilize clang's OverlayFileSystem facility to enable VFS passed to CompilerInstance can access files in real file system, so '#include' directive can be used. Add a new getModuleFromSource for real file. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@r

[PATCH 09/14] perf clang: Update test case to use real BPF script

2016-09-23 Thread Wang Nan
Allow C++ code to use util.h and tests/llvm.h. Let perf test to compile a real BPF script. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Alexei Starovoitov <a...@fb.com> Cc: He Kuang <heku...@huawei.com> Cc: Jir

[PATCH 13/14] perf clang: Pass fill path compiler

2016-09-23 Thread Wang Nan
If clang changes its working directory, filename passed to perf_clang__compile_bpf() becomes invalid. Before running clang, convert it to absolute path so file can be found even working directory is different. Signed-off-by: Wang Nan <wangn...@huawei.com> Cc: Arnaldo Carvalho d

[PATCH 02/14] perf tools: Add feature detection for g++

2016-09-23 Thread Wang Nan
Check if g++ is available. The result will be used by builtin clang and LLVM support. Since LLVM requires C++11, this feature detector checks std::move(). Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/Makefile.feature

[PATCH 07/14] perf clang: Use real file system for #include

2016-09-23 Thread Wang Nan
Utilize clang's OverlayFileSystem facility to enable VFS passed to CompilerInstance can access files in real file system, so '#include' directive can be used. Add a new getModuleFromSource for real file. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang

[PATCH 09/14] perf clang: Update test case to use real BPF script

2016-09-23 Thread Wang Nan
Allow C++ code to use util.h and tests/llvm.h. Let perf test to compile a real BPF script. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/Makefile.config | 27 +++ tools/perf/tests/llvm

[PATCH 14/14] perf clang: Pass correct CFLAGS to builtin clang

2016-09-23 Thread Wang Nan
Pass CFLAGS detected by kbuild detector to builtin clang so BPF scripts can use kernel headers like external clang compiler. Test: # perf record --dry-run -e tools/perf/tests/bpf-script-test-kbuild.c ls 2>&1 | grep built bpf: builtin compiling successful Signed-off-by: Wang Nan Cc:

[PATCH 04/14] perf tools: Add feature detection for clang

2016-09-23 Thread Wang Nan
libraries ordering, use --start-group and --end-group. In this test case, manually identify required clang libs and hope it to be stable. Putting all clang libraries here is possible (use make's wildcard), but then feature checking becomes very slow. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho

[PATCH 10/14] perf clang: Support compile IR to BPF object and add testcase

2016-09-23 Thread Wang Nan
getBPFObjectFromModule() is introduced to use LLVM to convert Module (LLVM IR) to BPF object code. Add new testcase for it. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/tests/clang.c | 6 - tools/perf

[PATCH 13/14] perf clang: Pass fill path compiler

2016-09-23 Thread Wang Nan
If clang changes its working directory, filename passed to perf_clang__compile_bpf() becomes invalid. Before running clang, convert it to absolute path so file can be found even working directory is different. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

<    1   2   3   4   5   6   7   8   9   10   >