Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1270078 > unrolled thread
| Started by | Wang Nan <wangnan0@huawei.com> |
|---|---|
| First post | 2015-11-16 13:50 +0100 |
| Last post | 2015-11-16 15:20 +0100 |
| Articles | 20 on this page of 56 — 7 participants |
Back to article view | Back to linux.kernel
[PATCH 00/13] perf tools: bpf: Improve BPF program ability Wang Nan <wangnan0@huawei.com> - 2015-11-16 13:50 +0100
[PATCH 03/13] perf tools: Allow BPF program attach to uprobe events Wang Nan <wangnan0@huawei.com> - 2015-11-16 13:50 +0100
Re: [PATCH 03/13] perf tools: Allow BPF program attach to uprobe events Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-16 15:20 +0100
[tip:perf/core] perf bpf: Allow BPF program attach to uprobe events tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 10/13] perf tools: Add prologue for BPF programs for fetching arguments Wang Nan <wangnan0@huawei.com> - 2015-11-16 13:50 +0100
[tip:perf/core] perf bpf: Add prologue for BPF programs for fetching arguments tip-bot for He Kuang <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 04/13] perf tools: Allow BPF program attach to modules Wang Nan <wangnan0@huawei.com> - 2015-11-16 13:50 +0100
[tip:perf/core] perf bpf: Allow attaching BPF programs to modules symbols tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 07/13] bpf tools: Load a program with different instances using preprocessor Wang Nan <wangnan0@huawei.com> - 2015-11-16 13:50 +0100
Re: [PATCH 07/13] bpf tools: Load a program with different instances using preprocessor Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-16 20:10 +0100
Re: [PATCH 07/13] bpf tools: Load a program with different instances using preprocessor "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-17 05:00 +0100
[tip:perf/core] bpf tools: Load a program with different instances using preprocessor tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 13/13] perf tools: Use same BPF program if arguments are identical Wang Nan <wangnan0@huawei.com> - 2015-11-16 14:00 +0100
Re: [PATCH 13/13] perf tools: Use same BPF program if arguments are identical "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-17 04:10 +0100
Re: [PATCH 13/13] perf tools: Use same BPF program if arguments are identical Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 14:20 +0100
[PATCH 12/13] perf test: Test BPF prologue Wang Nan <wangnan0@huawei.com> - 2015-11-16 14:00 +0100
Re: [PATCH 12/13] perf test: Test BPF prologue Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 02:30 +0100
Re: [PATCH 12/13] perf test: Test BPF prologue "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-17 02:40 +0100
Re: [PATCH 12/13] perf test: Test BPF prologue "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-17 05:40 +0100
Re: [PATCH 12/13] perf test: Test BPF prologue Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 13:30 +0100
[PATCH 0/5] perf tools: Improve BPF support Wang Nan <wangnan0@huawei.com> - 2015-11-17 09:40 +0100
[PATCH 5/5] perf test: Mute test cases if verbose == 0 Wang Nan <wangnan0@huawei.com> - 2015-11-17 09:40 +0100
Re: [PATCH 5/5] perf test: Mute test cases if verbose == 0 Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 14:20 +0100
[tip:perf/core] perf test: Mute test cases error messages if verbose == 0 tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:20 +0100
[PATCH 2/5] perf tools: Use same BPF program if arguments are identical Wang Nan <wangnan0@huawei.com> - 2015-11-17 09:40 +0100
[tip:perf/core] perf bpf: Use same BPF program if arguments are identical tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 4/5] perf test: Print result for each subtest for BPF Wang Nan <wangnan0@huawei.com> - 2015-11-17 09:40 +0100
[tip:perf/core] perf test: Print result for each BPF subtest tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:20 +0100
[PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' Wang Nan <wangnan0@huawei.com> - 2015-11-17 09:40 +0100
Re: [PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 14:00 +0100
Re: [PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' pi3orama <pi3orama@163.com> - 2015-11-17 14:10 +0100
Re: [PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 14:40 +0100
[tip:perf/core] perf test: Fix 'perf test BPF' when it fails to find a suitable vmlinux tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 3/5] perf test: Print result for each subtest for llvm Wang Nan <wangnan0@huawei.com> - 2015-11-17 09:40 +0100
Re: [PATCH 3/5] perf test: Print result for each subtest for llvm Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 14:10 +0100
[tip:perf/core] perf test: Print result for each LLVM subtest tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:20 +0100
Re: [PATCH 12/13] perf test: Test BPF prologue "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-17 09:50 +0100
[PATCH] perf record: Support custom vmlinux path Wang Nan <wangnan0@huawei.com> - 2015-11-17 11:00 +0100
Re: [PATCH] perf record: Support custom vmlinux path Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 13:40 +0100
Re: [PATCH] perf record: Support custom vmlinux path Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-17 13:50 +0100
Re: [PATCH] perf record: Support custom vmlinux path pi3orama <pi3orama@163.com> - 2015-11-17 13:50 +0100
[PATCH 0/2] perf tools: Builtin options related improvements Wang Nan <wangnan0@huawei.com> - 2015-11-19 15:10 +0100
[PATCH 2/2] perf record: Support custom vmlinux path Wang Nan <wangnan0@huawei.com> - 2015-11-19 15:10 +0100
[PATCH 1/2] perf tools: Always give options even it not compiled Wang Nan <wangnan0@huawei.com> - 2015-11-19 15:10 +0100
RE: [PATCH 1/2] perf tools: Always give options even it not compiled 平松雅巳 / HIRAMATU,MASAMI <masami.hiramatsu.pt@hitachi.com> - 2015-11-20 12:00 +0100
Re: [PATCH 1/2] perf tools: Always give options even it not compiled "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-26 09:10 +0100
Re: [PATCH 1/2] perf tools: Always give options even it not compiled "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-26 10:10 +0100
[tip:perf/core] perf test: Test the BPF prologue adding infrastructure tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 06/13] perf tools: Allow BPF program config probing options Wang Nan <wangnan0@huawei.com> - 2015-11-16 14:00 +0100
[tip:perf/core] perf bpf: Allow BPF program config probing options tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 08/13] perf tools: Add BPF_PROLOGUE config options for further patches Wang Nan <wangnan0@huawei.com> - 2015-11-16 14:00 +0100
[tip:perf/core] perf bpf: Add BPF_PROLOGUE config options for further patches tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 11/13] perf tools: Generate prologue for BPF programs Wang Nan <wangnan0@huawei.com> - 2015-11-16 14:00 +0100
[tip:perf/core] perf bpf: Generate prologue for BPF programs tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-23 17:10 +0100
[PATCH 02/13] perf probe: Clear probe_trace_event when add_probe_trace_event() fails Wang Nan <wangnan0@huawei.com> - 2015-11-16 14:00 +0100
Re: [PATCH 00/13] perf tools: bpf: Improve BPF program ability Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-16 15:20 +0100
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 09:40 +0100 |
| Subject | [PATCH 0/5] perf tools: Improve BPF support |
| Message-ID | <qvJXX-2zA-1@gated-at.bofh.it> |
| In reply to | #1270748 |
This patchset is based on Arnaldo's perf/ebpf branch (commit 14dcf0ba2a26f680776093a7a61e74526713f9b2). In response to Arnaldo's comment in [1], in this patch set: Patch 1/5 fixes a bug in BPF testcase which incorrectly returns TEST_OK when failure; Patch 2/5 is resent with some coding style improvements. Patch 3/5 - 4/5 provide improvements for 'perf test' to support sub-tests output which Arnaldo looks forward [2]. Patch 5/5 mutes all testcases during testing to ensure outupt of 'perf test' is clean when verbose is not set. [1] http://lkml.kernel.org/g/1447675815-166222-1-git-send-email-wangnan0@huawei.com [2] http://lkml.kernek.org/g/20151117012924.GA22729@kernel.org Wang Nan (5): perf test: Fix 2 bugs in 'perf test BPF' perf tools: Use same BPF program if arguments are identical perf test: Print result for each subtest for llvm perf test: Print result for each subtest for BPF perf test: Mute test cases if verbose == 0 tools/perf/tests/bpf.c | 45 +++++++++---- tools/perf/tests/builtin-test.c | 134 ++++++++++++++++++++++++++++++++------ tools/perf/tests/llvm.c | 65 +++++++++---------- tools/perf/tests/tests.h | 27 +++++++- tools/perf/util/bpf-loader.c | 138 ++++++++++++++++++++++++++++++++++++++-- 5 files changed, 330 insertions(+), 79 deletions(-) -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 09:40 +0100 |
| Subject | [PATCH 5/5] perf test: Mute test cases if verbose == 0 |
| Message-ID | <qvJXX-2zA-9@gated-at.bofh.it> |
| In reply to | #1270953 |
Sometimes error messages in breaks the pretty output of 'perf test'.
For example:
# mv /lib/modules/4.3.0-rc4+/build/vmlinux{,.bak}
# ./perf test LLVM BPF
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Ok
35.2: Test kbuild searching : Ok
35.3: Compile source for BPF prologue generation test : Ok
37: Test BPF filter :
37.1: Test basic BPF filtering : Ok
37.2: Test BPF prologue generation :Failed to find the path for kernel: No such file or directory
FAILED!
This patch mute test cases thoroughly by redirect their stdout and
stderr to /dev/null when verbose == 0. After applying this patch:
# ./perf test LLVM BPF
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Ok
35.2: Test kbuild searching : Ok
35.3: Compile source for BPF prologue generation test : Ok
37: Test BPF filter :
37.1: Test basic BPF filtering : Ok
37.2: Test BPF prologue generation : FAILED!
# ./perf test -v LLVM BPF
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test :
--- start ---
test child forked, pid 13183
Kernel build dir is set to /lib/modules/4.3.0-rc4+/build
set env: KBUILD_DIR=/lib/modules/4.3.0-rc4+/build
...
bpf: config 'func=null_lseek file->f_mode offset orig' is ok
Looking at the vmlinux_path (7 entries long)
Failed to find the path for kernel: No such file or directory
bpf_probe: failed to convert perf probe eventsFailed to add events selected by BPF
test child finished with -1
---- end ----
Test BPF filter subtest 1: FAILED!
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/builtin-test.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 9914412..799edad 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -227,7 +227,22 @@ static int run_test(struct test *test, int subtest)
}
if (!child) {
+ int nullfd;
+
pr_debug("test child forked, pid %d\n", getpid());
+
+ if (!verbose) {
+ nullfd = open("/dev/null", O_WRONLY);
+ if (nullfd >= 0) {
+ close(STDERR_FILENO);
+ close(STDOUT_FILENO);
+
+ dup2(nullfd, STDOUT_FILENO);
+ dup2(STDOUT_FILENO, STDERR_FILENO);
+ close(nullfd);
+ }
+ }
+
if (!test->need_subtests)
err = test->func();
else
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-11-17 14:20 +0100 |
| Subject | Re: [PATCH 5/5] perf test: Mute test cases if verbose == 0 |
| Message-ID | <qvOkW-5vY-17@gated-at.bofh.it> |
| In reply to | #1270954 |
Em Tue, Nov 17, 2015 at 08:32:50AM +0000, Wang Nan escreveu:
> Sometimes error messages in breaks the pretty output of 'perf test'.
> For example:
Ok, great, nevermind my report about this, thanks for fixing it!
- Arnaldo
> # mv /lib/modules/4.3.0-rc4+/build/vmlinux{,.bak}
> # ./perf test LLVM BPF
> 35: Test LLVM searching and compiling :
> 35.1: Basic BPF llvm compiling test : Ok
> 35.2: Test kbuild searching : Ok
> 35.3: Compile source for BPF prologue generation test : Ok
> 37: Test BPF filter :
> 37.1: Test basic BPF filtering : Ok
> 37.2: Test BPF prologue generation :Failed to find the path for kernel: No such file or directory
> FAILED!
>
> This patch mute test cases thoroughly by redirect their stdout and
> stderr to /dev/null when verbose == 0. After applying this patch:
>
> # ./perf test LLVM BPF
> 35: Test LLVM searching and compiling :
> 35.1: Basic BPF llvm compiling test : Ok
> 35.2: Test kbuild searching : Ok
> 35.3: Compile source for BPF prologue generation test : Ok
> 37: Test BPF filter :
> 37.1: Test basic BPF filtering : Ok
> 37.2: Test BPF prologue generation : FAILED!
>
> # ./perf test -v LLVM BPF
> 35: Test LLVM searching and compiling :
> 35.1: Basic BPF llvm compiling test :
> --- start ---
> test child forked, pid 13183
> Kernel build dir is set to /lib/modules/4.3.0-rc4+/build
> set env: KBUILD_DIR=/lib/modules/4.3.0-rc4+/build
> ...
> bpf: config 'func=null_lseek file->f_mode offset orig' is ok
> Looking at the vmlinux_path (7 entries long)
> Failed to find the path for kernel: No such file or directory
> bpf_probe: failed to convert perf probe eventsFailed to add events selected by BPF
> test child finished with -1
> ---- end ----
> Test BPF filter subtest 1: FAILED!
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
> tools/perf/tests/builtin-test.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index 9914412..799edad 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -227,7 +227,22 @@ static int run_test(struct test *test, int subtest)
> }
>
> if (!child) {
> + int nullfd;
> +
> pr_debug("test child forked, pid %d\n", getpid());
> +
> + if (!verbose) {
> + nullfd = open("/dev/null", O_WRONLY);
> + if (nullfd >= 0) {
> + close(STDERR_FILENO);
> + close(STDOUT_FILENO);
> +
> + dup2(nullfd, STDOUT_FILENO);
> + dup2(STDOUT_FILENO, STDERR_FILENO);
> + close(nullfd);
> + }
> + }
> +
> if (!test->need_subtests)
> err = test->func();
> else
> --
> 1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-23 17:20 +0100 |
| Subject | [tip:perf/core] perf test: Mute test cases error messages if verbose == 0 |
| Message-ID | <qy20r-4cV-65@gated-at.bofh.it> |
| In reply to | #1270954 |
Commit-ID: 5bcf2fe05318deb6fec209b4028d8a31f9f47221
Gitweb: http://git.kernel.org/tip/5bcf2fe05318deb6fec209b4028d8a31f9f47221
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Tue, 17 Nov 2015 08:32:50 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 19 Nov 2015 13:19:17 -0300
perf test: Mute test cases error messages if verbose == 0
Sometimes error messages in breaks the pretty output of 'perf test'.
For example:
# mv /lib/modules/4.3.0-rc4+/build/vmlinux{,.bak}
# perf test LLVM BPF
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Ok
35.2: Test kbuild searching : Ok
35.3: Compile source for BPF prologue generation test : Ok
37: Test BPF filter :
37.1: Test basic BPF filtering : Ok
37.2: Test BPF prologue generation :Failed to find the path for kernel: No such file or directory FAILED!
This patch mute test cases thoroughly by redirect their stdout and
stderr to /dev/null when verbose == 0. After applying this patch:
# ./perf test LLVM BPF
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Ok
35.2: Test kbuild searching : Ok
35.3: Compile source for BPF prologue generation test : Ok
37: Test BPF filter :
37.1: Test basic BPF filtering : Ok
37.2: Test BPF prologue generation : FAILED!
# ./perf test -v LLVM BPF
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test :
--- start ---
test child forked, pid 13183
Kernel build dir is set to /lib/modules/4.3.0-rc4+/build
set env: KBUILD_DIR=/lib/modules/4.3.0-rc4+/build
...
bpf: config 'func=null_lseek file->f_mode offset orig' is ok
Looking at the vmlinux_path (7 entries long)
Failed to find the path for kernel: No such file or directory
bpf_probe: failed to convert perf probe eventsFailed to add events selected by BPF
test child finished with -1
---- end ----
Test BPF filter subtest 1: FAILED!
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447749170-175898-6-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/builtin-test.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 146ae98..2b1ade1 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -226,6 +226,18 @@ static int run_test(struct test *test, int subtest)
if (!child) {
pr_debug("test child forked, pid %d\n", getpid());
+ if (!verbose) {
+ int nullfd = open("/dev/null", O_WRONLY);
+ if (nullfd >= 0) {
+ close(STDERR_FILENO);
+ close(STDOUT_FILENO);
+
+ dup2(nullfd, STDOUT_FILENO);
+ dup2(STDOUT_FILENO, STDERR_FILENO);
+ close(nullfd);
+ }
+ }
+
err = test->func(subtest);
exit(err);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 09:40 +0100 |
| Subject | [PATCH 2/5] perf tools: Use same BPF program if arguments are identical |
| Message-ID | <qvJXY-2zA-19@gated-at.bofh.it> |
| In reply to | #1270953 |
This patch allows creating only one BPF program for different
'probe_trace_event'(tev) generated by one 'perf_probe_event'(pev), if
their prologues are identical.
This is done by comparing argument list of different tev, and maps type
of prologue and tev using a mapping array. This patch utilizes qsort to
sort tevs. After sorting, tevs with identical argument list will be
grouped together.
Test result:
Sample BPF program:
#define SEC(NAME) __attribute__((section(NAME), used))
SEC("inlines=no;"
"func=SyS_dup? oldfd")
int func(void *ctx)
{
return 1;
}
It would probe at SyS_dup2 and SyS_dup3, extracts oldfd as its argument.
Following cmdline shows BPF program loaded into kernel by perf:
# ./perf record -e ./test_bpf_arg.c sleep 4 & sleep 1 && ls /proc/$!/fd/ -l | grep bpf-prog
Before this patch:
# ./perf record -e ./test_bpf_arg.c sleep 4 & sleep 1 && ls /proc/$!/fd/ -l | grep bpf-prog
[1] 24858
lrwx------ 1 root root 64 Nov 14 04:09 3 -> anon_inode:bpf-prog
lrwx------ 1 root root 64 Nov 14 04:09 4 -> anon_inode:bpf-prog
...
After this patch:
# ./perf record -e ./test_bpf_arg.c sleep 4 & sleep 1 && ls /proc/$!/fd/ -l | grep bpf-prog
[1] 25699
lrwx------ 1 root root 64 Nov 14 04:10 3 -> anon_inode:bpf-prog
...
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
tools/perf/util/bpf-loader.c | 138 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 131 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 190a1c7..36544e5 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -38,6 +38,8 @@ struct bpf_prog_priv {
struct perf_probe_event pev;
bool need_prologue;
struct bpf_insn *insns_buf;
+ int nr_types;
+ int *type_mapping;
};
static bool libbpf_initialized;
@@ -113,6 +115,7 @@ bpf_prog_priv__clear(struct bpf_program *prog __maybe_unused,
cleanup_perf_probe_events(&priv->pev, 1);
zfree(&priv->insns_buf);
+ zfree(&priv->type_mapping);
free(priv);
}
@@ -381,7 +384,7 @@ preproc_gen_prologue(struct bpf_program *prog, int n,
struct bpf_prog_priv *priv;
struct bpf_insn *buf;
size_t prologue_cnt = 0;
- int err;
+ int i, err;
err = bpf_program__get_private(prog, (void **)&priv);
if (err || !priv)
@@ -389,10 +392,21 @@ preproc_gen_prologue(struct bpf_program *prog, int n,
pev = &priv->pev;
- if (n < 0 || n >= pev->ntevs)
+ if (n < 0 || n >= priv->nr_types)
goto errout;
- tev = &pev->tevs[n];
+ /* Find a tev belongs to that type */
+ for (i = 0; i < pev->ntevs; i++) {
+ if (priv->type_mapping[i] == n)
+ break;
+ }
+
+ if (i >= pev->ntevs) {
+ pr_debug("Internal error: prologue type %d not found\n", n);
+ return -BPF_LOADER_ERRNO__PROLOGUE;
+ }
+
+ tev = &pev->tevs[i];
buf = priv->insns_buf;
err = bpf__gen_prologue(tev->args, tev->nargs,
@@ -423,6 +437,101 @@ errout:
return -BPF_LOADER_ERRNO__PROLOGUE;
}
+/*
+ * compare_tev_args is reflexive, transitive and antisymmetric.
+ * I can proof it but this margin is too narrow to contain.
+ */
+static int compare_tev_args(const void *ptev1, const void *ptev2)
+{
+ int i, ret;
+ const struct probe_trace_event *tev1 =
+ *(const struct probe_trace_event **)ptev1;
+ const struct probe_trace_event *tev2 =
+ *(const struct probe_trace_event **)ptev2;
+
+ ret = tev2->nargs - tev1->nargs;
+ if (ret)
+ return ret;
+
+ for (i = 0; i < tev1->nargs; i++) {
+ struct probe_trace_arg *arg1, *arg2;
+ struct probe_trace_arg_ref *ref1, *ref2;
+
+ arg1 = &tev1->args[i];
+ arg2 = &tev2->args[i];
+
+ ret = strcmp(arg1->value, arg2->value);
+ if (ret)
+ return ret;
+
+ ref1 = arg1->ref;
+ ref2 = arg2->ref;
+
+ while (ref1 && ref2) {
+ ret = ref2->offset - ref1->offset;
+ if (ret)
+ return ret;
+
+ ref1 = ref1->next;
+ ref2 = ref2->next;
+ }
+
+ if (ref1 || ref2)
+ return ref2 ? 1 : -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Assign a type number to each tevs in a pev.
+ * mapping is an array with same slots as tevs in that pev.
+ * nr_types will be set to number of types.
+ */
+static int map_prologue(struct perf_probe_event *pev, int *mapping,
+ int *nr_types)
+{
+ int i, type = 0;
+ struct probe_trace_event **ptevs;
+
+ size_t array_sz = sizeof(*ptevs) * pev->ntevs;
+
+ ptevs = malloc(array_sz);
+ if (!ptevs) {
+ pr_debug("No ehough memory: alloc ptevs failed\n");
+ return -ENOMEM;
+ }
+
+ pr_debug("In map_prologue, ntevs=%d\n", pev->ntevs);
+ for (i = 0; i < pev->ntevs; i++)
+ ptevs[i] = &pev->tevs[i];
+
+ qsort(ptevs, pev->ntevs, sizeof(*ptevs),
+ compare_tev_args);
+
+ for (i = 0; i < pev->ntevs; i++) {
+ int n;
+
+ n = ptevs[i] - pev->tevs;
+ if (i == 0) {
+ mapping[n] = type;
+ pr_debug("mapping[%d]=%d\n", n, type);
+ continue;
+ }
+
+ if (compare_tev_args(ptevs + i, ptevs + i - 1) == 0)
+ mapping[n] = type;
+ else
+ mapping[n] = ++type;
+
+ pr_debug("mapping[%d]=%d\n", n, mapping[n]);
+ }
+ free(ptevs);
+ *nr_types = type + 1;
+
+ return 0;
+}
+
static int hook_load_preprocessor(struct bpf_program *prog)
{
struct perf_probe_event *pev;
@@ -462,7 +571,19 @@ static int hook_load_preprocessor(struct bpf_program *prog)
return -ENOMEM;
}
- err = bpf_program__set_prep(prog, pev->ntevs,
+ priv->type_mapping = malloc(sizeof(int) * pev->ntevs);
+ if (!priv->type_mapping) {
+ pr_debug("No enough memory: alloc type_mapping failed\n");
+ return -ENOMEM;
+ }
+ memset(priv->type_mapping, -1,
+ sizeof(int) * pev->ntevs);
+
+ err = map_prologue(pev, priv->type_mapping, &priv->nr_types);
+ if (err)
+ return err;
+
+ err = bpf_program__set_prep(prog, priv->nr_types,
preproc_gen_prologue);
return err;
}
@@ -596,10 +717,13 @@ int bpf__foreach_tev(struct bpf_object *obj,
for (i = 0; i < pev->ntevs; i++) {
tev = &pev->tevs[i];
- if (priv->need_prologue)
- fd = bpf_program__nth_fd(prog, i);
- else
+ if (priv->need_prologue) {
+ int type = priv->type_mapping[i];
+
+ fd = bpf_program__nth_fd(prog, type);
+ } else {
fd = bpf_program__fd(prog);
+ }
if (fd < 0) {
pr_debug("bpf: failed to get file descriptor\n");
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-23 17:10 +0100 |
| Subject | [tip:perf/core] perf bpf: Use same BPF program if arguments are identical |
| Message-ID | <qy1QM-48K-65@gated-at.bofh.it> |
| In reply to | #1270958 |
Commit-ID: d35b32891a61f1d3909bdc5280badf309adc4693
Gitweb: http://git.kernel.org/tip/d35b32891a61f1d3909bdc5280badf309adc4693
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Tue, 17 Nov 2015 08:32:47 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 18 Nov 2015 17:51:05 -0300
perf bpf: Use same BPF program if arguments are identical
This patch allows creating only one BPF program for different
'probe_trace_event'(tev) entries generated by one
'perf_probe_event'(pev) if their prologues are identical.
This is done by comparing the argument list of different tev instances,
and the maps type of prologue and tev using a mapping array. This patch
utilizes qsort to sort the tevs. After sorting, tevs with identical
argument lists will be grouped together.
Test result:
Sample BPF program:
#define SEC(NAME) __attribute__((section(NAME), used))
SEC("inlines=no;"
"func=SyS_dup? oldfd")
int func(void *ctx)
{
return 1;
}
It would probe at SyS_dup2 and SyS_dup3, obtaining oldfd as its
argument.
The following cmdline shows a BPF program being loaded into the kernel
by perf:
# perf record -e ./test_bpf_arg.c sleep 4 & sleep 1 && ls /proc/$!/fd/ -l | grep bpf-prog
Before this patch:
# perf record -e ./test_bpf_arg.c sleep 4 & sleep 1 && ls /proc/$!/fd/ -l | grep bpf-prog
[1] 24858
lrwx------ 1 root root 64 Nov 14 04:09 3 -> anon_inode:bpf-prog
lrwx------ 1 root root 64 Nov 14 04:09 4 -> anon_inode:bpf-prog
...
After this patch:
# perf record -e ./test_bpf_arg.c sleep 4 & sleep 1 && ls /proc/$!/fd/ -l | grep bpf-prog
[1] 25699
lrwx------ 1 root root 64 Nov 14 04:10 3 -> anon_inode:bpf-prog
...
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447749170-175898-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/bpf-loader.c | 138 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 131 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 190a1c7..36544e5 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -38,6 +38,8 @@ struct bpf_prog_priv {
struct perf_probe_event pev;
bool need_prologue;
struct bpf_insn *insns_buf;
+ int nr_types;
+ int *type_mapping;
};
static bool libbpf_initialized;
@@ -113,6 +115,7 @@ bpf_prog_priv__clear(struct bpf_program *prog __maybe_unused,
cleanup_perf_probe_events(&priv->pev, 1);
zfree(&priv->insns_buf);
+ zfree(&priv->type_mapping);
free(priv);
}
@@ -381,7 +384,7 @@ preproc_gen_prologue(struct bpf_program *prog, int n,
struct bpf_prog_priv *priv;
struct bpf_insn *buf;
size_t prologue_cnt = 0;
- int err;
+ int i, err;
err = bpf_program__get_private(prog, (void **)&priv);
if (err || !priv)
@@ -389,10 +392,21 @@ preproc_gen_prologue(struct bpf_program *prog, int n,
pev = &priv->pev;
- if (n < 0 || n >= pev->ntevs)
+ if (n < 0 || n >= priv->nr_types)
goto errout;
- tev = &pev->tevs[n];
+ /* Find a tev belongs to that type */
+ for (i = 0; i < pev->ntevs; i++) {
+ if (priv->type_mapping[i] == n)
+ break;
+ }
+
+ if (i >= pev->ntevs) {
+ pr_debug("Internal error: prologue type %d not found\n", n);
+ return -BPF_LOADER_ERRNO__PROLOGUE;
+ }
+
+ tev = &pev->tevs[i];
buf = priv->insns_buf;
err = bpf__gen_prologue(tev->args, tev->nargs,
@@ -423,6 +437,101 @@ errout:
return -BPF_LOADER_ERRNO__PROLOGUE;
}
+/*
+ * compare_tev_args is reflexive, transitive and antisymmetric.
+ * I can proof it but this margin is too narrow to contain.
+ */
+static int compare_tev_args(const void *ptev1, const void *ptev2)
+{
+ int i, ret;
+ const struct probe_trace_event *tev1 =
+ *(const struct probe_trace_event **)ptev1;
+ const struct probe_trace_event *tev2 =
+ *(const struct probe_trace_event **)ptev2;
+
+ ret = tev2->nargs - tev1->nargs;
+ if (ret)
+ return ret;
+
+ for (i = 0; i < tev1->nargs; i++) {
+ struct probe_trace_arg *arg1, *arg2;
+ struct probe_trace_arg_ref *ref1, *ref2;
+
+ arg1 = &tev1->args[i];
+ arg2 = &tev2->args[i];
+
+ ret = strcmp(arg1->value, arg2->value);
+ if (ret)
+ return ret;
+
+ ref1 = arg1->ref;
+ ref2 = arg2->ref;
+
+ while (ref1 && ref2) {
+ ret = ref2->offset - ref1->offset;
+ if (ret)
+ return ret;
+
+ ref1 = ref1->next;
+ ref2 = ref2->next;
+ }
+
+ if (ref1 || ref2)
+ return ref2 ? 1 : -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Assign a type number to each tevs in a pev.
+ * mapping is an array with same slots as tevs in that pev.
+ * nr_types will be set to number of types.
+ */
+static int map_prologue(struct perf_probe_event *pev, int *mapping,
+ int *nr_types)
+{
+ int i, type = 0;
+ struct probe_trace_event **ptevs;
+
+ size_t array_sz = sizeof(*ptevs) * pev->ntevs;
+
+ ptevs = malloc(array_sz);
+ if (!ptevs) {
+ pr_debug("No ehough memory: alloc ptevs failed\n");
+ return -ENOMEM;
+ }
+
+ pr_debug("In map_prologue, ntevs=%d\n", pev->ntevs);
+ for (i = 0; i < pev->ntevs; i++)
+ ptevs[i] = &pev->tevs[i];
+
+ qsort(ptevs, pev->ntevs, sizeof(*ptevs),
+ compare_tev_args);
+
+ for (i = 0; i < pev->ntevs; i++) {
+ int n;
+
+ n = ptevs[i] - pev->tevs;
+ if (i == 0) {
+ mapping[n] = type;
+ pr_debug("mapping[%d]=%d\n", n, type);
+ continue;
+ }
+
+ if (compare_tev_args(ptevs + i, ptevs + i - 1) == 0)
+ mapping[n] = type;
+ else
+ mapping[n] = ++type;
+
+ pr_debug("mapping[%d]=%d\n", n, mapping[n]);
+ }
+ free(ptevs);
+ *nr_types = type + 1;
+
+ return 0;
+}
+
static int hook_load_preprocessor(struct bpf_program *prog)
{
struct perf_probe_event *pev;
@@ -462,7 +571,19 @@ static int hook_load_preprocessor(struct bpf_program *prog)
return -ENOMEM;
}
- err = bpf_program__set_prep(prog, pev->ntevs,
+ priv->type_mapping = malloc(sizeof(int) * pev->ntevs);
+ if (!priv->type_mapping) {
+ pr_debug("No enough memory: alloc type_mapping failed\n");
+ return -ENOMEM;
+ }
+ memset(priv->type_mapping, -1,
+ sizeof(int) * pev->ntevs);
+
+ err = map_prologue(pev, priv->type_mapping, &priv->nr_types);
+ if (err)
+ return err;
+
+ err = bpf_program__set_prep(prog, priv->nr_types,
preproc_gen_prologue);
return err;
}
@@ -596,10 +717,13 @@ int bpf__foreach_tev(struct bpf_object *obj,
for (i = 0; i < pev->ntevs; i++) {
tev = &pev->tevs[i];
- if (priv->need_prologue)
- fd = bpf_program__nth_fd(prog, i);
- else
+ if (priv->need_prologue) {
+ int type = priv->type_mapping[i];
+
+ fd = bpf_program__nth_fd(prog, type);
+ } else {
fd = bpf_program__fd(prog);
+ }
if (fd < 0) {
pr_debug("bpf: failed to get file descriptor\n");
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 09:40 +0100 |
| Subject | [PATCH 4/5] perf test: Print result for each subtest for BPF |
| Message-ID | <qvJXY-2zA-35@gated-at.bofh.it> |
| In reply to | #1270953 |
This patch prints each sub-tests results for BPF testcases.
Before:
# ./perf test BPF
37: Test BPF filter : Ok
After:
# ./perf test BPF
37: Test BPF filter :
37.1: Test basic BPF filtering : Ok
37.2: Test BPF prologue generation : Ok
When failure:
# cat ~/.perfconfig
[llvm]
clang-path = "/bin/false"
# ./perf test BPF
37: Test BPF filter :
37.1: Test basic BPF filtering : Skip
37.2: Test BPF prologue generation : Skip
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/bpf.c | 38 ++++++++++++++++++++++++++++----------
tools/perf/tests/builtin-test.c | 8 +++++++-
tools/perf/tests/tests.h | 5 ++++-
3 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index dca3998..8c2262d 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -215,28 +215,46 @@ out:
return ret;
}
-int test__bpf(void)
+int test__bpf_subtest_get_nr(void)
+{
+ return (int)ARRAY_SIZE(bpf_testcase_table);
+}
+
+const char *test__bpf_subtest_get_desc(int i)
+{
+ if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table))
+ return NULL;
+ return bpf_testcase_table[i].desc;
+}
+
+int test__bpf_subtest(int i)
{
- unsigned int i;
int err;
+ if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table))
+ return TEST_FAIL;
+
if (geteuid() != 0) {
pr_debug("Only root can run BPF test\n");
return TEST_SKIP;
}
- for (i = 0; i < ARRAY_SIZE(bpf_testcase_table); i++) {
- err = __test__bpf(i);
+ err = __test__bpf(i);
+ return err;
+}
- if (err != TEST_OK)
- return err;
- }
+#else
+int test__bpf_subtest_get_nr(void)
+{
+ return 0;
+}
- return TEST_OK;
+const char *test__bpf_subtest_get_desc(int i __maybe_unused)
+{
+ return NULL;
}
-#else
-int test__bpf(void)
+int test__bpf_subtest(int i __maybe_unused)
{
pr_debug("Skip BPF test because BPF support is not compiled\n");
return TEST_SKIP;
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 29225142..9914412 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -173,7 +173,13 @@ static struct test generic_tests[] = {
},
{
.desc = "Test BPF filter",
- .func = test__bpf,
+ .need_subtests = true,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__bpf_subtest_get_nr,
+ .get_desc = test__bpf_subtest_get_desc,
+ .func = test__bpf_subtest,
+ },
},
{
.func = NULL,
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index f8f9eb6..2ce66b2 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -84,7 +84,10 @@ const char *test__llvm_subtest_get_desc(int i);
int test__llvm_subtest_get_nr(void);
int test__llvm_subtest(int i);
-int test__bpf(void);
+const char *test__bpf_subtest_get_desc(int i);
+int test__bpf_subtest_get_nr(void);
+int test__bpf_subtest(int i);
+
int test_session_topology(void);
#if defined(__arm__) || defined(__aarch64__)
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-23 17:20 +0100 |
| Subject | [tip:perf/core] perf test: Print result for each BPF subtest |
| Message-ID | <qy20r-4cV-45@gated-at.bofh.it> |
| In reply to | #1270960 |
Commit-ID: 77a0cf682f7979554e10a6c605a1fef4f4197654
Gitweb: http://git.kernel.org/tip/77a0cf682f7979554e10a6c605a1fef4f4197654
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Tue, 17 Nov 2015 08:32:49 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 19 Nov 2015 13:19:16 -0300
perf test: Print result for each BPF subtest
This patch prints each sub-tests results for BPF testcases.
Before:
# ./perf test BPF
37: Test BPF filter : Ok
After:
# ./perf test BPF
37: Test BPF filter :
37.1: Test basic BPF filtering : Ok
37.2: Test BPF prologue generation : Ok
When a failure happens:
# cat ~/.perfconfig
[llvm]
clang-path = "/bin/false"
# ./perf test BPF
37: Test BPF filter :
37.1: Test basic BPF filtering : Skip
37.2: Test BPF prologue generation : Skip
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447749170-175898-5-git-send-email-wangnan0@huawei.com
[ Fixed up not to use .func in an anonymous union ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/bpf.c | 38 ++++++++++++++++++++++++++++----------
tools/perf/tests/builtin-test.c | 5 +++++
tools/perf/tests/tests.h | 2 ++
3 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 4efdc16..33689a0 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -215,28 +215,46 @@ out:
return ret;
}
-int test__bpf(int subtest __maybe_unused)
+int test__bpf_subtest_get_nr(void)
+{
+ return (int)ARRAY_SIZE(bpf_testcase_table);
+}
+
+const char *test__bpf_subtest_get_desc(int i)
+{
+ if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table))
+ return NULL;
+ return bpf_testcase_table[i].desc;
+}
+
+int test__bpf(int i)
{
- unsigned int i;
int err;
+ if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table))
+ return TEST_FAIL;
+
if (geteuid() != 0) {
pr_debug("Only root can run BPF test\n");
return TEST_SKIP;
}
- for (i = 0; i < ARRAY_SIZE(bpf_testcase_table); i++) {
- err = __test__bpf(i);
+ err = __test__bpf(i);
+ return err;
+}
- if (err != TEST_OK)
- return err;
- }
+#else
+int test__bpf_subtest_get_nr(void)
+{
+ return 0;
+}
- return TEST_OK;
+const char *test__bpf_subtest_get_desc(int i __maybe_unused)
+{
+ return NULL;
}
-#else
-int test__bpf(void)
+int test__bpf(int i __maybe_unused)
{
pr_debug("Skip BPF test because BPF support is not compiled\n");
return TEST_SKIP;
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 8136609..146ae98 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -173,6 +173,11 @@ static struct test generic_tests[] = {
{
.desc = "Test BPF filter",
.func = test__bpf,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__bpf_subtest_get_nr,
+ .get_desc = test__bpf_subtest_get_desc,
+ },
},
{
.func = NULL,
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index f92af52..a0733aa 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -76,6 +76,8 @@ int test__llvm(int subtest);
const char *test__llvm_subtest_get_desc(int subtest);
int test__llvm_subtest_get_nr(void);
int test__bpf(int subtest);
+const char *test__bpf_subtest_get_desc(int subtest);
+int test__bpf_subtest_get_nr(void);
int test_session_topology(int subtest);
#if defined(__arm__) || defined(__aarch64__)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 09:40 +0100 |
| Subject | [PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' |
| Message-ID | <qvJXY-2zA-37@gated-at.bofh.it> |
| In reply to | #1270953 |
Two bugs in 'perf test BPF' are found when testing BPF prologue without
vmlinux:
# mv /lib/modules/4.3.0-rc4+/build/vmlinux{,.bak}
# ./perf test BPF
37: Test BPF filter :Failed to find the path for kernel: No such file or directory
Ok
Test BPF should fail in this case.
This patch fixes two bugs in 'perf test BPF'. After this patch:
# ./perf test BPF
37: Test BPF filter :Failed to find the path for kernel: No such file or directory
FAILED!
# mv /lib/modules/4.3.0-rc4+/build/vmlinux{.bak,}
# ./perf test BPF
37: Test BPF filter : Ok
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/bpf.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index c7131fa..dca3998 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -102,8 +102,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj);
if (err || list_empty(&parse_evlist.list)) {
pr_debug("Failed to add events selected by BPF\n");
- if (!err)
- return TEST_FAIL;
+ return TEST_FAIL;
}
snprintf(pid, sizeof(pid), "%d", getpid());
@@ -157,8 +156,10 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
}
}
- if (count != expect)
+ if (count != expect) {
pr_debug("BPF filter result incorrect\n");
+ goto out_delete_evlist;
+ }
ret = TEST_OK;
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-11-17 14:00 +0100 |
| Subject | Re: [PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' |
| Message-ID | <qvO1z-58e-7@gated-at.bofh.it> |
| In reply to | #1270962 |
Em Tue, Nov 17, 2015 at 08:32:46AM +0000, Wang Nan escreveu:
> Two bugs in 'perf test BPF' are found when testing BPF prologue without
> vmlinux:
>
> # mv /lib/modules/4.3.0-rc4+/build/vmlinux{,.bak}
> # ./perf test BPF
> 37: Test BPF filter :Failed to find the path for kernel: No such file or directory
> Ok
>
> Test BPF should fail in this case.
>
> This patch fixes two bugs in 'perf test BPF'. After this patch:
>
> # ./perf test BPF
> 37: Test BPF filter :Failed to find the path for kernel: No such file or directory
> FAILED!
> # mv /lib/modules/4.3.0-rc4+/build/vmlinux{.bak,}
> # ./perf test BPF
> 37: Test BPF filter : Ok
Applied, it is a clear improvement, but:
[root@zoo ~]# perf test
1: vmlinux symtab matches kallsyms : Skip
2: detect openat syscall event : Ok
<SNIP>
5: parse events tests : Ok
6: Validate PERF_RECORD_* events & perf_sample fields : FAILED!
7: Test perf pmu format parsing : Ok
<SNIP>
37: Test BPF filter :Failed to find the path for kernel: Invalid ELF file
FAILED!
38: x86 rdpmc test : Ok
39: Test converting perf time to TSC : FAILED!
40: Test dwarf unwind : Ok
41: Test x86 instruction decoder - new instructions : Ok
42: Test intel cqm nmi context read : Skip
[root@zoo ~]#
------------------------
It is now the only test to emit some message in non-verbose mode that is not
"Ok", "FAILED!" or "Skip" :-)
- Arnaldo
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
> tools/perf/tests/bpf.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
> index c7131fa..dca3998 100644
> --- a/tools/perf/tests/bpf.c
> +++ b/tools/perf/tests/bpf.c
> @@ -102,8 +102,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
> err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj);
> if (err || list_empty(&parse_evlist.list)) {
> pr_debug("Failed to add events selected by BPF\n");
> - if (!err)
> - return TEST_FAIL;
> + return TEST_FAIL;
> }
>
> snprintf(pid, sizeof(pid), "%d", getpid());
> @@ -157,8 +156,10 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
> }
> }
>
> - if (count != expect)
> + if (count != expect) {
> pr_debug("BPF filter result incorrect\n");
> + goto out_delete_evlist;
> + }
>
> ret = TEST_OK;
>
> --
> 1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | pi3orama <pi3orama@163.com> |
|---|---|
| Date | 2015-11-17 14:10 +0100 |
| Subject | Re: [PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' |
| Message-ID | <qvObg-5rX-5@gated-at.bofh.it> |
| In reply to | #1271152 |
发自我的 iPhone
> 在 2015年11月17日,下午8:56,Arnaldo Carvalho de Melo <acme@kernel.org> 写道:
>
> Em Tue, Nov 17, 2015 at 08:32:46AM +0000, Wang Nan escreveu:
>> Two bugs in 'perf test BPF' are found when testing BPF prologue without
>> vmlinux:
>>
>> # mv /lib/modules/4.3.0-rc4+/build/vmlinux{,.bak}
>> # ./perf test BPF
>> 37: Test BPF filter :Failed to find the path for kernel: No such file or directory
>> Ok
>>
>> Test BPF should fail in this case.
>>
>> This patch fixes two bugs in 'perf test BPF'. After this patch:
>>
>> # ./perf test BPF
>> 37: Test BPF filter :Failed to find the path for kernel: No such file or directory
>> FAILED!
>> # mv /lib/modules/4.3.0-rc4+/build/vmlinux{.bak,}
>> # ./perf test BPF
>> 37: Test BPF filter : Ok
>
> Applied, it is a clear improvement, but:
>
> [root@zoo ~]# perf test
> 1: vmlinux symtab matches kallsyms : Skip
> 2: detect openat syscall event : Ok
> <SNIP>
> 5: parse events tests : Ok
> 6: Validate PERF_RECORD_* events & perf_sample fields : FAILED!
> 7: Test perf pmu format parsing : Ok
> <SNIP>
> 37: Test BPF filter :Failed to find the path for kernel: Invalid ELF file
> FAILED!
> 38: x86 rdpmc test : Ok
> 39: Test converting perf time to TSC : FAILED!
> 40: Test dwarf unwind : Ok
> 41: Test x86 instruction decoder - new instructions : Ok
> 42: Test intel cqm nmi context read : Skip
> [root@zoo ~]#
>
> ------------------------
>
> It is now the only test to emit some message in non-verbose mode that is not
> "Ok", "FAILED!" or "Skip" :-)
>
Please see 5/5. In that patch I try to fix it throughly by output redirection.
Thank you.
> - Arnaldo
>
>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
>> ---
>> tools/perf/tests/bpf.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
>> index c7131fa..dca3998 100644
>> --- a/tools/perf/tests/bpf.c
>> +++ b/tools/perf/tests/bpf.c
>> @@ -102,8 +102,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
>> err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj);
>> if (err || list_empty(&parse_evlist.list)) {
>> pr_debug("Failed to add events selected by BPF\n");
>> - if (!err)
>> - return TEST_FAIL;
>> + return TEST_FAIL;
>> }
>>
>> snprintf(pid, sizeof(pid), "%d", getpid());
>> @@ -157,8 +156,10 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
>> }
>> }
>>
>> - if (count != expect)
>> + if (count != expect) {
>> pr_debug("BPF filter result incorrect\n");
>> + goto out_delete_evlist;
>> + }
>>
>> ret = TEST_OK;
>>
>> --
>> 1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-11-17 14:40 +0100 |
| Subject | Re: [PATCH 1/5] perf test: Fix 2 bugs in 'perf test BPF' |
| Message-ID | <qvOEk-5DR-35@gated-at.bofh.it> |
| In reply to | #1271168 |
Em Tue, Nov 17, 2015 at 09:01:41PM +0800, pi3orama escreveu: > 发自我的 iPhone > > 在 2015年11月17日,下午8:56,Arnaldo Carvalho de Melo <acme@kernel.org> 写道: > > It is now the only test to emit some message in non-verbose mode that is not > > "Ok", "FAILED!" or "Skip" :-) > Please see 5/5. In that patch I try to fix it throughly by output redirection. Yeah, I saw it, perhaps next time you could have it in a different order, i.e. as soon as you saw that this message was out of place, needing a fix, you back off a bit from what you're doing, do the fix, then resume work, so that when someone goes on testing your patches one by one, the message doesn't appear. Anyway, all patches applied, doing a build-test on a few distros now, will go to Ingo today, thanks! - Arnaldo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-23 17:10 +0100 |
| Subject | [tip:perf/core] perf test: Fix 'perf test BPF' when it fails to find a suitable vmlinux |
| Message-ID | <qy1QM-48K-59@gated-at.bofh.it> |
| In reply to | #1270962 |
Commit-ID: ad0dd7aed5df8009b3ffa39bec73ad93283332c9
Gitweb: http://git.kernel.org/tip/ad0dd7aed5df8009b3ffa39bec73ad93283332c9
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Tue, 17 Nov 2015 08:32:46 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 18 Nov 2015 17:51:04 -0300
perf test: Fix 'perf test BPF' when it fails to find a suitable vmlinux
Two bugs in 'perf test BPF' are found when testing BPF prologue without
vmlinux:
# mv /lib/modules/4.3.0-rc4+/build/vmlinux{,.bak}
# ./perf test BPF
37: Test BPF filter :Failed to find the path for kernel: No such file or directory
Ok
Test BPF should fail in this case.
After this patch:
# ./perf test BPF
37: Test BPF filter :Failed to find the path for kernel: No such file or directory
FAILED!
# mv /lib/modules/4.3.0-rc4+/build/vmlinux{.bak,}
# ./perf test BPF
37: Test BPF filter : Ok
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447749170-175898-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/bpf.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index d584422..232043c 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -102,8 +102,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj);
if (err || list_empty(&parse_evlist.list)) {
pr_debug("Failed to add events selected by BPF\n");
- if (!err)
- return TEST_FAIL;
+ return TEST_FAIL;
}
snprintf(pid, sizeof(pid), "%d", getpid());
@@ -157,8 +156,10 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
}
}
- if (count != expect)
+ if (count != expect) {
pr_debug("BPF filter result incorrect\n");
+ goto out_delete_evlist;
+ }
ret = TEST_OK;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 09:40 +0100 |
| Subject | [PATCH 3/5] perf test: Print result for each subtest for llvm |
| Message-ID | <qvJXX-2zA-7@gated-at.bofh.it> |
| In reply to | #1270953 |
Currently 'perf test llvm' and 'perf test BPF' are combined by multiple
sub-tests, but the result is only one line:
# perf test LLVM
35: Test LLVM searching and compiling : Ok
This patch introduces sub-tests support, allows perf test to report
result for each sub-tests:
# ./perf test LLVM
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Ok
35.2: Test kbuild searching : Ok
35.3: Compile source for BPF prologue generation test : Ok
When failure:
# cat ~/.perfconfig
[llvm]
clang-path = "/bin/false"
# ./perf test LLVM
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : FAILED!
35.2: Test kbuild searching : Skip
35.3: Compile source for BPF prologue generation test : Skip
And:
# rm ~/.perfconfig
# ./perf test LLVM
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Skip
35.2: Test kbuild searching : Skip
35.3: Compile source for BPF prologue generation test : Skip
Skip by user:
# ./perf test -s 1,`seq -s , 3 42`
1: vmlinux symtab matches kallsyms : Skip (user override)
2: detect openat syscall event : Ok
...
35: Test LLVM searching and compiling : Skip (user override)
...
Signed-off-by: Wang Nan <wangnan0@hauwei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/builtin-test.c | 111 ++++++++++++++++++++++++++++++++--------
tools/perf/tests/llvm.c | 65 +++++++++++------------
tools/perf/tests/tests.h | 22 +++++++-
3 files changed, 141 insertions(+), 57 deletions(-)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 80c442e..29225142 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -159,7 +159,13 @@ static struct test generic_tests[] = {
},
{
.desc = "Test LLVM searching and compiling",
- .func = test__llvm,
+ .need_subtests = true,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__llvm_subtest_get_nr,
+ .get_desc = test__llvm_subtest_get_desc,
+ .func = test__llvm_subtest,
+ },
},
{
.desc = "Test topology in session",
@@ -203,7 +209,7 @@ static bool perf_test__matches(struct test *test, int curr, int argc, const char
return false;
}
-static int run_test(struct test *test)
+static int run_test(struct test *test, int subtest)
{
int status, err = -1, child = fork();
char sbuf[STRERR_BUFSIZE];
@@ -216,7 +222,10 @@ static int run_test(struct test *test)
if (!child) {
pr_debug("test child forked, pid %d\n", getpid());
- err = test->func();
+ if (!test->need_subtests)
+ err = test->func();
+ else
+ err = test->subtest.func(subtest);
exit(err);
}
@@ -234,8 +243,48 @@ static int run_test(struct test *test)
}
#define for_each_test(j, t) \
- for (j = 0; j < ARRAY_SIZE(tests); j++) \
- for (t = &tests[j][0]; t->func; t++)
+ for (j = 0; j < ARRAY_SIZE(tests); j++) \
+ for (t = &tests[j][0]; \
+ (!t->need_subtests && t->func) || \
+ (t->need_subtests && \
+ t->subtest.get_nr && \
+ t->subtest.get_desc && \
+ t->subtest.func); \
+ t++)
+
+static int test_and_print(struct test *t, bool force_skip, int subtest)
+{
+ int err;
+
+ if (!force_skip) {
+ pr_debug("\n--- start ---\n");
+ err = run_test(t, subtest);
+ pr_debug("---- end ----\n");
+ } else {
+ pr_debug("\n--- force skipped ---\n");
+ err = TEST_SKIP;
+ }
+
+ if (!t->need_subtests)
+ pr_debug("%s:", t->desc);
+ else
+ pr_debug("%s subtest %d:", t->desc, subtest);
+
+ switch (err) {
+ case TEST_OK:
+ pr_info(" Ok\n");
+ break;
+ case TEST_SKIP:
+ color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
+ break;
+ case TEST_FAIL:
+ default:
+ color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n");
+ break;
+ }
+
+ return err;
+}
static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
{
@@ -264,21 +313,43 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
continue;
}
- pr_debug("\n--- start ---\n");
- err = run_test(t);
- pr_debug("---- end ----\n%s:", t->desc);
-
- switch (err) {
- case TEST_OK:
- pr_info(" Ok\n");
- break;
- case TEST_SKIP:
- color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
- break;
- case TEST_FAIL:
- default:
- color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n");
- break;
+ if (!t->need_subtests) {
+ test_and_print(t, false, -1);
+ } else {
+ int subn = t->subtest.get_nr();
+ /*
+ * minus 2 to align with normal testcases.
+ * For subtest we print additional '.x' in number.
+ * for example:
+ *
+ * 35: Test LLVM searching and compiling :
+ * 35.1: Basic BPF llvm compiling test : Ok
+ */
+ int subw = width > 2 ? width - 2 : width;
+ bool skip = false;
+ int subi;
+
+ if (subn <= 0) {
+ color_fprintf(stderr, PERF_COLOR_YELLOW,
+ " Skip (not compiled in)\n");
+ continue;
+ }
+ pr_info("\n");
+
+ for (subi = 0; subi < subn; subi++) {
+ int len = strlen(t->subtest.get_desc(subi));
+
+ if (subw < len)
+ subw = len;
+ }
+
+ for (subi = 0; subi < subn; subi++) {
+ pr_info("%2d.%1d: %-*s:", i, subi + 1, subw,
+ t->subtest.get_desc(subi));
+ err = test_and_print(t, skip, subi);
+ if (err != TEST_OK && t->subtest.skip_if_fail)
+ skip = true;
+ }
}
}
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 7f4f7f7..cebb593 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -46,7 +46,7 @@ static struct {
},
[LLVM_TESTCASE_BPF_PROLOGUE] = {
.source = test_llvm__bpf_test_prologue_prog,
- .desc = "Test BPF prologue generation",
+ .desc = "Compile source for BPF prologue generation test",
},
};
@@ -131,44 +131,39 @@ out:
return ret;
}
-int test__llvm(void)
+int test__llvm_subtest(int i)
{
- enum test_llvm__testcase i;
+ int ret;
+ void *obj_buf = NULL;
+ size_t obj_buf_sz = 0;
- for (i = 0; i < __LLVM_TESTCASE_MAX; i++) {
- int ret;
- void *obj_buf = NULL;
- size_t obj_buf_sz = 0;
+ if ((i < 0) || (i >= __LLVM_TESTCASE_MAX))
+ return TEST_FAIL;
- ret = test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz,
- i, false);
+ ret = test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz,
+ i, false);
- if (ret == TEST_OK) {
- ret = test__bpf_parsing(obj_buf, obj_buf_sz);
- if (ret != TEST_OK)
- pr_debug("Failed to parse test case '%s'\n",
- bpf_source_table[i].desc);
- }
- free(obj_buf);
-
- switch (ret) {
- case TEST_SKIP:
- return TEST_SKIP;
- case TEST_OK:
- break;
- default:
- /*
- * Test 0 is the basic LLVM test. If test 0
- * fail, the basic LLVM support not functional
- * so the whole test should fail. If other test
- * case fail, it can be fixed by adjusting
- * config so don't report error.
- */
- if (i == 0)
- return TEST_FAIL;
- else
- return TEST_SKIP;
+ if (ret == TEST_OK) {
+ ret = test__bpf_parsing(obj_buf, obj_buf_sz);
+ if (ret != TEST_OK) {
+ pr_debug("Failed to parse test case '%s'\n",
+ bpf_source_table[i].desc);
}
}
- return TEST_OK;
+ free(obj_buf);
+
+ return ret;
+}
+
+int test__llvm_subtest_get_nr(void)
+{
+ return __LLVM_TESTCASE_MAX;
+}
+
+const char *test__llvm_subtest_get_desc(int i)
+{
+ if ((i < 0) || (i >= __LLVM_TESTCASE_MAX))
+ return NULL;
+
+ return bpf_source_table[i].desc;
}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 3c8734a..f8f9eb6 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -1,6 +1,8 @@
#ifndef TESTS_H
#define TESTS_H
+#include <stdbool.h>
+
#define TEST_ASSERT_VAL(text, cond) \
do { \
if (!(cond)) { \
@@ -26,7 +28,19 @@ enum {
struct test {
const char *desc;
- int (*func)(void);
+
+ bool need_subtests;
+
+ union {
+ int (*func)(void);
+
+ struct {
+ bool skip_if_fail;
+ int (*get_nr)(void);
+ const char *(*get_desc)(int i);
+ int (*func)(int i);
+ } subtest;
+ };
};
/* Tests */
@@ -65,7 +79,11 @@ int test__fdarray__filter(void);
int test__fdarray__add(void);
int test__kmod_path__parse(void);
int test__thread_map(void);
-int test__llvm(void);
+
+const char *test__llvm_subtest_get_desc(int i);
+int test__llvm_subtest_get_nr(void);
+int test__llvm_subtest(int i);
+
int test__bpf(void);
int test_session_topology(void);
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-11-17 14:10 +0100 |
| Subject | Re: [PATCH 3/5] perf test: Print result for each subtest for llvm |
| Message-ID | <qvObg-5rX-17@gated-at.bofh.it> |
| In reply to | #1270964 |
Em Tue, Nov 17, 2015 at 08:32:48AM +0000, Wang Nan escreveu: > Currently 'perf test llvm' and 'perf test BPF' are combined by multiple > sub-tests, but the result is only one line: Thanks for working on this! I'm fixing this: [acme@zoo linux]$ am /wb/1.patch Applying: perf test: Print result for each subtest for llvm /home/acme/git/linux/.git/rebase-apply/patch:56: space before tab in indent. (t->need_subtests && \ warning: 1 line adds whitespace errors. tools/perf/tests/builtin-test.c:249: space before tab in indent. + (t->need_subtests && \ [acme@zoo linux]$ Please check your .git/hooks/ files so that you can catch this while commiting your work. - Arnaldo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2015-11-23 17:20 +0100 |
| Subject | [tip:perf/core] perf test: Print result for each LLVM subtest |
| Message-ID | <qy20r-4cV-53@gated-at.bofh.it> |
| In reply to | #1270964 |
Commit-ID: e8c6d500447c577e669c24ec04cd4173fe9f9afb
Gitweb: http://git.kernel.org/tip/e8c6d500447c577e669c24ec04cd4173fe9f9afb
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Tue, 17 Nov 2015 08:32:48 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 19 Nov 2015 13:19:16 -0300
perf test: Print result for each LLVM subtest
Currently 'perf test llvm' and 'perf test BPF' have multiple sub-tests,
but the result is provided in only one line:
# perf test LLVM
35: Test LLVM searching and compiling : Ok
This patch introduces sub-tests support, allowing 'perf test' to report
result for each sub-tests:
# perf test LLVM
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Ok
35.2: Test kbuild searching : Ok
35.3: Compile source for BPF prologue generation test : Ok
When a failure happens:
# cat ~/.perfconfig
[llvm]
clang-path = "/bin/false"
# perf test LLVM
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : FAILED!
35.2: Test kbuild searching : Skip
35.3: Compile source for BPF prologue generation test : Skip
And:
# rm ~/.perfconfig
# ./perf test LLVM
35: Test LLVM searching and compiling :
35.1: Basic BPF llvm compiling test : Skip
35.2: Test kbuild searching : Skip
35.3: Compile source for BPF prologue generation test : Skip
Skip by user:
# ./perf test -s 1,`seq -s , 3 42`
1: vmlinux symtab matches kallsyms : Skip (user override)
2: detect openat syscall event : Ok
...
35: Test LLVM searching and compiling : Skip (user override)
...
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447749170-175898-4-git-send-email-wangnan0@huawei.com
[ Changed so that func is not on an anonymous union ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/builtin-test.c | 91 ++++++++++++++++++++++++++++++++++-------
tools/perf/tests/llvm.c | 65 ++++++++++++++---------------
tools/perf/tests/tests.h | 9 ++++
3 files changed, 115 insertions(+), 50 deletions(-)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 9cf4892..8136609 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -160,6 +160,11 @@ static struct test generic_tests[] = {
{
.desc = "Test LLVM searching and compiling",
.func = test__llvm,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__llvm_subtest_get_nr,
+ .get_desc = test__llvm_subtest_get_desc,
+ },
},
{
.desc = "Test topology in session",
@@ -237,6 +242,40 @@ static int run_test(struct test *test, int subtest)
for (j = 0; j < ARRAY_SIZE(tests); j++) \
for (t = &tests[j][0]; t->func; t++)
+static int test_and_print(struct test *t, bool force_skip, int subtest)
+{
+ int err;
+
+ if (!force_skip) {
+ pr_debug("\n--- start ---\n");
+ err = run_test(t, subtest);
+ pr_debug("---- end ----\n");
+ } else {
+ pr_debug("\n--- force skipped ---\n");
+ err = TEST_SKIP;
+ }
+
+ if (!t->subtest.get_nr)
+ pr_debug("%s:", t->desc);
+ else
+ pr_debug("%s subtest %d:", t->desc, subtest);
+
+ switch (err) {
+ case TEST_OK:
+ pr_info(" Ok\n");
+ break;
+ case TEST_SKIP:
+ color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
+ break;
+ case TEST_FAIL:
+ default:
+ color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n");
+ break;
+ }
+
+ return err;
+}
+
static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
{
struct test *t;
@@ -264,21 +303,43 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
continue;
}
- pr_debug("\n--- start ---\n");
- err = run_test(t, i);
- pr_debug("---- end ----\n%s:", t->desc);
-
- switch (err) {
- case TEST_OK:
- pr_info(" Ok\n");
- break;
- case TEST_SKIP:
- color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
- break;
- case TEST_FAIL:
- default:
- color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n");
- break;
+ if (!t->subtest.get_nr) {
+ test_and_print(t, false, -1);
+ } else {
+ int subn = t->subtest.get_nr();
+ /*
+ * minus 2 to align with normal testcases.
+ * For subtest we print additional '.x' in number.
+ * for example:
+ *
+ * 35: Test LLVM searching and compiling :
+ * 35.1: Basic BPF llvm compiling test : Ok
+ */
+ int subw = width > 2 ? width - 2 : width;
+ bool skip = false;
+ int subi;
+
+ if (subn <= 0) {
+ color_fprintf(stderr, PERF_COLOR_YELLOW,
+ " Skip (not compiled in)\n");
+ continue;
+ }
+ pr_info("\n");
+
+ for (subi = 0; subi < subn; subi++) {
+ int len = strlen(t->subtest.get_desc(subi));
+
+ if (subw < len)
+ subw = len;
+ }
+
+ for (subi = 0; subi < subn; subi++) {
+ pr_info("%2d.%1d: %-*s:", i, subi + 1, subw,
+ t->subtest.get_desc(subi));
+ err = test_and_print(t, skip, subi);
+ if (err != TEST_OK && t->subtest.skip_if_fail)
+ skip = true;
+ }
}
}
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 4350c45..06f45c1 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -46,7 +46,7 @@ static struct {
},
[LLVM_TESTCASE_BPF_PROLOGUE] = {
.source = test_llvm__bpf_test_prologue_prog,
- .desc = "Test BPF prologue generation",
+ .desc = "Compile source for BPF prologue generation test",
},
};
@@ -131,44 +131,39 @@ out:
return ret;
}
-int test__llvm(int subtest __maybe_unused)
+int test__llvm(int subtest)
{
- enum test_llvm__testcase i;
+ int ret;
+ void *obj_buf = NULL;
+ size_t obj_buf_sz = 0;
- for (i = 0; i < __LLVM_TESTCASE_MAX; i++) {
- int ret;
- void *obj_buf = NULL;
- size_t obj_buf_sz = 0;
+ if ((subtest < 0) || (subtest >= __LLVM_TESTCASE_MAX))
+ return TEST_FAIL;
- ret = test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz,
- i, false);
+ ret = test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz,
+ subtest, false);
- if (ret == TEST_OK) {
- ret = test__bpf_parsing(obj_buf, obj_buf_sz);
- if (ret != TEST_OK)
- pr_debug("Failed to parse test case '%s'\n",
- bpf_source_table[i].desc);
- }
- free(obj_buf);
-
- switch (ret) {
- case TEST_SKIP:
- return TEST_SKIP;
- case TEST_OK:
- break;
- default:
- /*
- * Test 0 is the basic LLVM test. If test 0
- * fail, the basic LLVM support not functional
- * so the whole test should fail. If other test
- * case fail, it can be fixed by adjusting
- * config so don't report error.
- */
- if (i == 0)
- return TEST_FAIL;
- else
- return TEST_SKIP;
+ if (ret == TEST_OK) {
+ ret = test__bpf_parsing(obj_buf, obj_buf_sz);
+ if (ret != TEST_OK) {
+ pr_debug("Failed to parse test case '%s'\n",
+ bpf_source_table[subtest].desc);
}
}
- return TEST_OK;
+ free(obj_buf);
+
+ return ret;
+}
+
+int test__llvm_subtest_get_nr(void)
+{
+ return __LLVM_TESTCASE_MAX;
+}
+
+const char *test__llvm_subtest_get_desc(int subtest)
+{
+ if ((subtest < 0) || (subtest >= __LLVM_TESTCASE_MAX))
+ return NULL;
+
+ return bpf_source_table[subtest].desc;
}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 204e4ee..f92af52 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -1,6 +1,8 @@
#ifndef TESTS_H
#define TESTS_H
+#include <stdbool.h>
+
#define TEST_ASSERT_VAL(text, cond) \
do { \
if (!(cond)) { \
@@ -27,6 +29,11 @@ enum {
struct test {
const char *desc;
int (*func)(int subtest);
+ struct {
+ bool skip_if_fail;
+ int (*get_nr)(void);
+ const char *(*get_desc)(int subtest);
+ } subtest;
};
/* Tests */
@@ -66,6 +73,8 @@ int test__fdarray__add(int subtest);
int test__kmod_path__parse(int subtest);
int test__thread_map(int subtest);
int test__llvm(int subtest);
+const char *test__llvm_subtest_get_desc(int subtest);
+int test__llvm_subtest_get_nr(void);
int test__bpf(int subtest);
int test_session_topology(int subtest);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 09:50 +0100 |
| Subject | Re: [PATCH 12/13] perf test: Test BPF prologue |
| Message-ID | <qvK7E-2Dd-11@gated-at.bofh.it> |
| In reply to | #1270748 |
Hi Arnaldo, On 2015/11/17 9:29, Arnaldo Carvalho de Melo wrote: [SNIP] > I've pushed everything to my perf/ebpf branch, please let me know if > what is there is acceptable, then it will be up to Ingo to decide where > to put this, if in perf/urgent for this merge window, or in perf/core, > for the next one. I have checked and tested your changes in your perf/ebpf and they are okay to me. > > Ah, to extract the output for these BPF sub-tests I had to use -v, i.e. > just: > > # perf test BPF > 37: Test BPF filter : Ok > # > > Ditto for the LLVM one. > > Doesn't tell us too much about all those nice sub-tests... > > How about: > > # perf test -v BPF > 37: Test BPF filter: > 37.1: test a : Ok > 37.2: test b : Ok > 37.3: Test BPF prologue generation : Ok > 37.4: Another... : Ok > 37: Test BPF filter : Ok > # I have sent a cset based on perf/ebpf in [1]. With the last 3 patch you will see 'perf test' output information in this way. Please have a try: # ./perf test LLVM BPF 35: Test LLVM searching and compiling : 35.1: Basic BPF llvm compiling test : Ok 35.2: Test kbuild searching : Ok 35.3: Compile source for BPF prologue generation test : Ok 37: Test BPF filter : 37.1: Test basic BPF filtering : Ok 37.2: Test BPF prologue generation : Ok Thank you. [1] http://lkml.kernel.org/g/1447749170-175898-1-git-send-email-wangnan0@huawei.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2015-11-17 11:00 +0100 |
| Subject | [PATCH] perf record: Support custom vmlinux path |
| Message-ID | <qvLdo-3kN-19@gated-at.bofh.it> |
| In reply to | #1270748 |
From: He Kuang <hekuang@huawei.com>
Make perf-record command support --vmlinux option if BPF_PROLOGUE is on.
'perf record' needs vmlinux as the source of DWARF info to generate
prologue for BPF programs, so path of vmlinux should be specified.
Short name 'k' has been taken by 'clockid'. This patch skips the short
option name and use '--vmlinux' for vmlinux path.
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
Hi Arnaldo,
This patch is a standalone improvement to support BPF argument fetching
better. Without this patch vmlinux must be reside in standard path
for BPF loader finding it. I think you can review this patch with other
patch I send today. Other patch on my local tree is not belong to this
topic.
Thank you.
---
tools/perf/builtin-record.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 199fc31..cfd0e14 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1118,6 +1118,10 @@ struct option __record_options[] = {
"clang binary to use for compiling BPF scriptlets"),
OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
"options passed to clang when compiling BPF scriptlets"),
+#ifdef HAVE_BPF_PROLOGUE
+ OPT_STRING(0, "vmlinux", &symbol_conf.vmlinux_name,
+ "file", "vmlinux pathname"),
+#endif
#endif
OPT_END()
};
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-11-17 13:40 +0100 |
| Subject | Re: [PATCH] perf record: Support custom vmlinux path |
| Message-ID | <qvNIe-50X-3@gated-at.bofh.it> |
| In reply to | #1271026 |
Em Tue, Nov 17, 2015 at 09:44:44AM +0000, Wang Nan escreveu:
> From: He Kuang <hekuang@huawei.com>
>
> Make perf-record command support --vmlinux option if BPF_PROLOGUE is on.
>
> 'perf record' needs vmlinux as the source of DWARF info to generate
> prologue for BPF programs, so path of vmlinux should be specified.
>
> Short name 'k' has been taken by 'clockid'. This patch skips the short
> option name and use '--vmlinux' for vmlinux path.
>
> Signed-off-by: He Kuang <hekuang@huawei.com>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Zefan Li <lizefan@huawei.com>
> Cc: pi3orama@163.com
> ---
>
> Hi Arnaldo,
>
> This patch is a standalone improvement to support BPF argument fetching
> better. Without this patch vmlinux must be reside in standard path
> for BPF loader finding it. I think you can review this patch with other
> patch I send today. Other patch on my local tree is not belong to this
> topic.
Thanks, applying.
> Thank you.
>
> ---
> tools/perf/builtin-record.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 199fc31..cfd0e14 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1118,6 +1118,10 @@ struct option __record_options[] = {
> "clang binary to use for compiling BPF scriptlets"),
> OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
> "options passed to clang when compiling BPF scriptlets"),
> +#ifdef HAVE_BPF_PROLOGUE
> + OPT_STRING(0, "vmlinux", &symbol_conf.vmlinux_name,
> + "file", "vmlinux pathname"),
> +#endif
> #endif
> OPT_END()
> };
> --
> 1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2015-11-17 13:50 +0100 |
| Subject | Re: [PATCH] perf record: Support custom vmlinux path |
| Message-ID | <qvNRU-54p-17@gated-at.bofh.it> |
| In reply to | #1271140 |
Em Tue, Nov 17, 2015 at 09:33:40AM -0300, Arnaldo Carvalho de Melo escreveu: > Em Tue, Nov 17, 2015 at 09:44:44AM +0000, Wang Nan escreveu: > > Thanks, applying. I take that back, I think this is questionable, we should instead always have the --vmlinux option, and when the feature it deals with is not built in, warn the user about it, something like: # perf record --vmlinux /a/b/c ... WARNING: --vmlinux being ignored, as BPF prologue not built-in... <output that can be produced while ignoring --vmlinux> And please consider that for other options that are surrounded by ifdefs related to the eBPF support, there are a few more, clang related. Also this isn't updating the perf-record man page, please do so and please put this in a separate section for BPF related options, something like: -------------------- BPF: These options can be used when BPF support is built-in. ... --------------------- This way the user gets to know that the tool can be used with BPF while reading its documentation and if they decide to try it, then the warnings will be presented if the feature is not built-in. - Arnaldo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 2 of 3 — ← Prev page 1 [2] 3 Next page →
Back to top | Article view | linux.kernel
csiph-web