* [tip:perf/core] perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set
2017-06-20 18:32 [PATCH] perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set Wang Nan
@ 2017-06-20 9:03 ` tip-bot for Wang Nan
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Wang Nan @ 2017-06-20 9:03 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, alexei.starovoitov, hpa, brueckner, lizefan, mingo, acme,
linux-kernel, tmricht, wangnan0
Commit-ID: 9b57fb7e35957c6838f89f4ed7e3f8433a4bbfc5
Gitweb: http://git.kernel.org/tip/9b57fb7e35957c6838f89f4ed7e3f8433a4bbfc5
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Wed, 21 Jun 2017 02:32:03 +0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 19 Jun 2017 16:11:26 -0300
perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set
The 'if' keyword is a define that expands to complex code when
CONFIG_PROFILE_ALL_BRANCHES is selected, which causes a 'perf test LLVM'
failure like:
$ ./perf test LLVM
35: LLVM search and compile :
35.1: Basic BPF llvm compile : Ok
35.2: kbuild searching : Ok
35.3: Compile source for BPF prologue generation: FAILED!
35.4: Compile source for BPF relocation : Skip
The only affected test case is bpf-script-test-prologue.c
because it uses kernel headers and has 'if' inside.
This patch undefines 'if' to make it passes perf test.
More detailed analysis from a message in this thread, also by Wang:
The problem is caused by following relocation information:
$ readelf -a ./llvmsubtest3
...
[ 5] _ftrace_branch PROGBITS 0000000000000000 00000260
00000000000000a0 0000000000000000 WA 0 0 4
...
Relocation section '.relfunc=null_lseek file->f_mode offset orig' at
offset 0x490 contains 4 entries:
Offset Info Type Sym. Value Sym. Name
000000000038 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch
0000000000b0 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch
000000000128 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch
0000000001c0 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch
Relocation section '.rel_ftrace_branch' at offset 0x4d0 contains 8 entries:
Offset Info Type Sym. Value Sym. Name
000000000000 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n
000000000008 000100000001 unrecognized: 1 0000000000000015 .L.str
000000000028 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n
000000000030 000100000001 unrecognized: 1 0000000000000015 .L.str
000000000050 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n
000000000058 000100000001 unrecognized: 1 0000000000000015 .L.str
000000000078 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n
000000000080 000100000001 unrecognized: 1 0000000000000015 .L.str
...
So I think the failure is because you enabled CONFIG_PROFILE_ALL_BRANCHES.
I can reproduce your buggy result by selecting
CONFIG_PROFILE_ALL_BRANCHES in my kbuild:
$ ./perf test LLVM
35: LLVM search and compile :
35.1: Basic BPF llvm compile : Ok
35.2: kbuild searching : Ok
35.3: Compile source for BPF prologue generation: FAILED!
35.4: Compile source for BPF relocation : Skip
Simply undef CONFIG_PROFILE_ALL_BRANCHES in clang opts not working
because it is introduced by "#include <uapi/linux/fs.h>", which override
cmdline options. So I think the best way is to undefine 'if' inside BPF
script.
Reported-and-Tested-by: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/20170620183203.2517-1-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/bpf-script-test-prologue.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/perf/tests/bpf-script-test-prologue.c b/tools/perf/tests/bpf-script-test-prologue.c
index 7230e62..b4ebc75 100644
--- a/tools/perf/tests/bpf-script-test-prologue.c
+++ b/tools/perf/tests/bpf-script-test-prologue.c
@@ -10,6 +10,15 @@
#include <uapi/linux/fs.h>
+/*
+ * If CONFIG_PROFILE_ALL_BRANCHES is selected,
+ * 'if' is redefined after include kernel header.
+ * Recover 'if' for BPF object code.
+ */
+#ifdef if
+# undef if
+#endif
+
#define FMODE_READ 0x1
#define FMODE_WRITE 0x2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set
@ 2017-06-20 18:32 Wang Nan
2017-06-20 9:03 ` [tip:perf/core] " tip-bot for Wang Nan
0 siblings, 1 reply; 2+ messages in thread
From: Wang Nan @ 2017-06-20 18:32 UTC (permalink / raw)
To: acme, tmricht
Cc: linux-kernel, Wang Nan, Arnaldo Carvalho de Melo,
Hendrik Brueckner, Alexei Starovoitov, Li Zefan
'if' is defined to complex code when CONFIG_PROFILE_ALL_BRANCHES is
selected, which cause a 'perf test LLVM' failure like:
$ ./perf test LLVM
35: LLVM search and compile :
35.1: Basic BPF llvm compile : Ok
35.2: kbuild searching : Ok
35.3: Compile source for BPF prologue generation: FAILED!
35.4: Compile source for BPF relocation : Skip
The only affected test case is bpf-script-test-prologue.c
because it uses kernel headers and has 'if' inside.
This patch undefines 'if' to make it passes perf test.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Li Zefan <lizefan@huawei.com>
---
tools/perf/tests/bpf-script-test-prologue.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/perf/tests/bpf-script-test-prologue.c b/tools/perf/tests/bpf-script-test-prologue.c
index 7230e62..b4ebc75 100644
--- a/tools/perf/tests/bpf-script-test-prologue.c
+++ b/tools/perf/tests/bpf-script-test-prologue.c
@@ -10,6 +10,15 @@
#include <uapi/linux/fs.h>
+/*
+ * If CONFIG_PROFILE_ALL_BRANCHES is selected,
+ * 'if' is redefined after include kernel header.
+ * Recover 'if' for BPF object code.
+ */
+#ifdef if
+# undef if
+#endif
+
#define FMODE_READ 0x1
#define FMODE_WRITE 0x2
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-20 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-20 18:32 [PATCH] perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set Wang Nan
2017-06-20 9:03 ` [tip:perf/core] " tip-bot for Wang Nan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).