linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
To: "Wangnan (F)" <wangnan0@huawei.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>,
	linux-perf-users@vger.kernel.org,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>
Subject: Re: perf test LLVM failure
Date: Mon, 19 Jun 2017 09:45:47 +0200	[thread overview]
Message-ID: <3fddab50-c06d-452a-3447-970e3c368bcd@linux.vnet.ibm.com> (raw)
In-Reply-To: <9df6cb52-345d-1e16-96af-fe7dd6bcbc2c@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 4036 bytes --]

On 06/19/2017 02:34 AM, Wangnan (F) wrote:
> Hi,
> 
> I made a quick test on my ubuntu system, unable to reproduce.
> 
> My clang environment:
> 
> $ clang --version
> clang version 3.8.1-12ubuntu1 (tags/RELEASE_381/final)
> Target: x86_64-pc-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin
> 
> My source code:
> $ git show
> commit a351e9b9fc24e982ec2f0e76379a49826036da12
> Author: Linus Torvalds <torvalds@linux-foundation.org>
> Date:   Sun Apr 30 19:47:48 2017 -0700
> 
>     Linux 4.11
> 
> 
> Test result:
> 
> $ ./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: Ok
> 35.4: Compile source for BPF relocation         : Ok
> 
> 
> 
> In your environment, clang produces a buggy BPF object file during
> 'perf test LLVM', but produces a correct BPF object when you compile
> it manually. I think the cmdline you provided to clang is different
> from the cmdline 'perf test' generated.
> 
> Could you please provide the result of 'perf test -vv LLVM'
> and the cmdline you use for manual testing?
> 
> Also, it would be thankful if you provide the '.o' file produced
> by perf test and by your manually testing. Following are steps
> to get it.
> 
> If you build perf from source, please apply the following patch:
> 
> ################### BEGIN ###################
> 
> diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
> index 482b536..e0694e0 100644
> --- a/tools/perf/tests/llvm.c
> +++ b/tools/perf/tests/llvm.c
> @@ -138,6 +138,8 @@ int test__llvm(int subtest)
>      void *obj_buf = NULL;
>      size_t obj_buf_sz = 0;
>      bool should_load_fail = false;
> +    FILE *fp;
> +    char fn[64];
> 
>      if ((subtest < 0) || (subtest >= __LLVM_TESTCASE_MAX))
>          return TEST_FAIL;
> @@ -152,6 +154,14 @@ int test__llvm(int subtest)
>                   bpf_source_table[subtest].desc);
>          }
>      }
> +
> +    snprintf(fn, sizeof(fn), "/tmp/perf-test-llvm-%d.o", subtest);
> +    fp = fopen(fn, "wb");
> +    if (fp) {
> +        fwrite(obj_buf, obj_buf_sz, 1, fp);
> +        fclose(fp);
> +    }
> +
>      free(obj_buf);
> 
>      return ret;
> ################### END ###################
> 
> then do 'perf test LLVM', and give me /tmp/perf-test-llvm-2.o
> 
> If you can't change perf's source code, you can use strace to capture
> the content of it:
> $ strace -f -o /tmp/out  -s 8192 ./perf test -vv LLVM
> 
> In resulting /tmp/out, search 'write.*ELF.*null_lseek', you will find
> a line looks like:
> 
> 12101 write(3, "\177ELF\2\1\1\0\0\0 ... ", 928) = 928
> 
> Send that line to me.
> 
> Thank you.
> 

Thank you very much for your help. I attach a tgz file which contains:
llvm/
llvm/llvmsubtest3.c   <-- Source code of failing subtest 35.3
llvm/llvmsubtest3     <-- Object code
llvm/bpftest1.c       <-- Souce code of BPF test (unneeded)
llvm/Makefile         <-- Makefile to build llvmsubtest2 and 3
llvm/llvmsubtest2.c   <-- Souce code of succeeding subtest 35.2
llvm/llvmsubtest2     <-- Object code
llvm/output/          <-- Output directory for command ./perf test -vv LLVM
llvm/output/llvm.out  <-- Verbose output of ./perf test -vv LLVM
llvm/output/perf-test-llvm-1.o <-- Object code for subtest 2
llvm/output/perf-test-llvm-2.o <-- Object code for subtest 3
llvm/output/perf-test-llvm-0.o <-- Object code for subtest 0

This provides all the information you requested.
The object files perf-test-llvm-[012].o have been captured with the
patch you provided.
The object code for llvmsubtest3.c compiled using my makefile
and the perf test LLVM code is identifcal:

[root@s8360047 llvm]# cmp llvmsubtest3 /tmp/perf-test-llvm-2.o
[root@s8360047 llvm]#

Thanks
-- 
Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

[-- Attachment #2: llvmtest-failure.tgz --]
[-- Type: application/x-compressed-tar, Size: 3199 bytes --]

  reply	other threads:[~2017-06-19  7:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13  8:40 perf test LLVM failure Thomas-Mich Richter
2017-06-16 16:09 ` Arnaldo Carvalho de Melo
2017-06-19  0:34   ` Wangnan (F)
2017-06-19  7:45     ` Thomas-Mich Richter [this message]
2017-06-19 10:29       ` Wangnan (F)
2017-06-19 11:59         ` Thomas-Mich Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3fddab50-c06d-452a-3447-970e3c368bcd@linux.vnet.ibm.com \
    --to=tmricht@linux.vnet.ibm.com \
    --cc=acme@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).