Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1197133 > unrolled thread

perf eBPF patch ordering. was: Re: perf test LLVM was: Re: [GIT PULL 00/39] perf tools: filtering events using eBPF programs

Started byArnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
First post2015-07-31 17:40 +0200
Last post2015-08-04 12:50 +0200
Articles 9 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2015-07-31 17:40 +0200
    Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs "Wangnan (F)" <wangnan0@huawei.com> - 2015-08-03 04:40 +0200
      Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2015-08-03 17:10 +0200
        Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-03 17:20 +0200
          Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT PULL 00/39] perf tools: filtering events using eBPF programs pi3orama <pi3orama@163.com> - 2015-08-03 18:00 +0200
            Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-03 18:20 +0200
              Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-03 21:50 +0200
                Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs "Wangnan (F)" <wangnan0@huawei.com> - 2015-08-04 07:30 +0200
                  Re: perf eBPF patch ordering.  was: Re: perf test LLVM was: Re: [GIT  PULL 00/39] perf tools: filtering events using eBPF programs "Wangnan (F)" <wangnan0@huawei.com> - 2015-08-04 12:50 +0200

#1197133 — perf eBPF patch ordering. was: Re: perf test LLVM was: Re: [GIT PULL 00/39] perf tools: filtering events using eBPF programs

FromArnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Date2015-07-31 17:40 +0200
Subjectperf eBPF patch ordering. was: Re: perf test LLVM was: Re: [GIT PULL 00/39] perf tools: filtering events using eBPF programs
Message-ID<pSkzF-1wQ-21@gated-at.bofh.it>
Em Wed, Jul 22, 2015 at 12:40:05PM +0800, Wangnan (F) escreveu:
> I noticed that you have rebase your perf/ebpf branch to 4.2-rc3. I have also
> done it in my tree. Please see:
> 
>  https://github.com/WangNan0/linux.git ebpf
> 
> Also, please recollect patch "perf tests: Add LLVM test for eBPF on-the-fly
> compiling", which adds verbose control. I'll also post it again.

I did it and some other rebases, expect more, but now I've got to:

  commit f0f99c45295e67787ad532492d9bebd6d9b56d3a
  Author: Wang Nan <wangnan0@huawei.com>
  Date:   Wed Jul 8 11:50:57 2015 +0000

    perf record: Enable passing bpf object file to --event

Which I split in 3 patches, no changes to the code, just avoiding doing
multiple things per patch, but point here is, when I see "enable passing
bpf object file to --event" I apply the patch and expect to be able to
go straight away and do:

    perf record -e foo.o sleep 1

And get some informative message as to hey, yes, I managed to do what
you asked or something is wrong, but I get:

  [root@felicio ~]# perf record --event foo.o sleep
  event syntax error: 'foo.o'
                       \___ parser error
  Run 'perf list' for a list of valid events

   usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list available events
  [root@felicio ~]#

So, is it enabled or is it not? Doesn't look like. I.e. I think the best
thing is to only expose this when it can be used. Till that time, we can
go on adding infrastructure to enable that and test that infrastructure
via 'perf test', like you did with 'perf test LLVM', thanks for doing
that:

  [root@felicio ~]# perf test LLVM
  38: Test LLVM searching and compiling                        : Ok

And in verbose mode we can see that it is finding everything it needs on this
RHEL7.1 test machine, after I got all the pieces from the llvm project git
repos and built it:

  [root@felicio ~]# perf test -v LLVM
  38: Test LLVM searching and compiling                        :
  --- start ---
  test child forked, pid 24457
  Kernel build dir is set to /lib/modules/4.2.0-rc3+/build
  set env: KBUILD_DIR=/lib/modules/4.2.0-rc3+/build
  unset env: KBUILD_OPTS
  include option is set to  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.3/include -I/home/acme/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/acme/git/linux/include -Iinclude -I/home/acme/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -Iinclude/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h 
  set env: CLANG_EXEC=/usr/local/bin/clang
  set env: CLANG_OPTIONS=-xc 
  set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.3/include -I/home/acme/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/acme/git/linux/include -Iinclude -I/home/acme/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -Iinclude/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h 
  set env: WORKING_DIR=/lib/modules/4.2.0-rc3+/build
  set env: CLANG_SOURCE=-
  llvm compiling command template: echo '__attribute__((section("do_fork"), used)) int fork(void *ctx) {return 0;} char _license[] __attribute__((section("license"), used)) = "GPL";int _version __attribute__((section("version"), used)) = 0x40100;' | $CLANG_EXEC -D__KERNEL__ $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o -
  test child finished with 0
  ---- end ----
  Test LLVM searching and compiling: Ok
  [root@felicio ~]#

Then, the next patch is even more exciting:

  perf record: Compile scriptlets if pass '.c' to --event

But its changelog doesn't come with a "hello_bpf.c" for me to use nor
the output of using it... bummer, I expected to use this new feature
right now :-)

Also, originally it had this name:

  [acme@felicio linux]$ git show --oneline f0f99c45295e67787ad532492d9bebd6d9b56d3a  | head -1
  f0f99c45295e perf record: Enable passing bpf object file to --event

But it doesn't even touch 'perf record':

  [acme@felicio linux]$ git show f0f99c45295e67787ad532492d9bebd6d9b56d3a | grep builtin-record
  [acme@felicio linux]$ 

So perhaps this was an artifact of refactoring previous patchkits?

I.e. I haven't looked at the other patches, but conceptually I can't think
_why_ would we expose a new feature that would only later be wired up and
then _really_ work.

Please reorder the patches to only expose --event foo.[oc] to when we can use
it.

Please continue from what I have in my perf/ebpf branch, it is all rebased to
latest tip/perf/core and passes most of the tests I put it thru (make -C
tools/perf build-test, 'perf test', fedora 21, RHEL 7.1).

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] | [next] | [standalone]


#1198497

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-08-03 04:40 +0200
Message-ID<pTdPr-6bY-3@gated-at.bofh.it>
In reply to#1197133

On 2015/8/1 4:31, Arnaldo Carvalho de Melo wrote:
> Em Fri, Jul 31, 2015 at 12:35:22PM -0300, Arnaldo Carvalho de Melo escreveu:
>> But point here is, when I see "enable passing
>> bpf object file to --event" I apply the patch and expect to be able to
>> go straight away and do:
>   
>>      perf record -e foo.o sleep 1
>   
>> And get some informative message as to hey, yes, I managed to do what
>> you asked or something is wrong, but I get:
>   
>>    [root@felicio ~]# perf record --event foo.o sleep
>>    event syntax error: 'foo.o'
>>                         \___ parser error
>>    Run 'perf list' for a list of valid events
>   
>>     usage: perf record [<options>] [<command>]
>>        or: perf record [<options>] -- <command> [<options>]
>   
>>        -e, --event <event>   event selector. use 'perf list' to list available events
>>    [root@felicio ~]#
>   
>> So, is it enabled or is it not? Doesn't look like. I.e. I think the best
>> thing is to only expose this when it can be used. Till that time, we can
> I just tried gdb'ing this with a breakpoint on parse_events_load_bpf(),
> but when I run:
>
>    (gdb) b parse_events_load_bpf
>    Breakpoint 1 at 0x48b11b: file util/parse-events.c, line 488.
>    (gdb) run record -e foo.o sleep 1
>    Starting program: /root/bin/perf record -e foo.o sleep 1
>    [Thread debugging using libthread_db enabled]
>    Using host libthread_db library "/lib64/libthread_db.so.1".
>    event syntax error: 'foo.o'
>                         \___ parser error
>    Run 'perf list' for a list of valid events
>
> Somehow it is not calling what the changeset says it would call when passing
> "-e foo.o", investigating...


Have you tried

/root/bin/perf record -e ./foo.o sleep 1

The key is './'.

I have reproduced the problem. Haven't noticed that because I always use './' name.

Will look into it.

Thank you, and glad to see you start looking at this cset.


> - 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]


#1198920

FromArnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Date2015-08-03 17:10 +0200
Message-ID<pTpxf-6Ex-5@gated-at.bofh.it>
In reply to#1198497
Em Mon, Aug 03, 2015 at 10:37:59AM +0800, Wangnan (F) escreveu:
> On 2015/8/1 4:31, Arnaldo Carvalho de Melo wrote:
> >Somehow it is not calling what the changeset says it would call when passing
> >"-e foo.o", investigating...
 
> Have you tried
 
> /root/bin/perf record -e ./foo.o sleep 1

> The key is './'.

Nope, trying it now I get:

  [root@felicio ~]# perf record -e ./foo.o sleep 1
  libbpf: failed to open ./foo.o: No such file or directory
  bpf: failed to load ./foo.o
  invalid or unsupported event: './foo.o'
  Run 'perf list' for a list of valid events

   usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

    -e, --event <event>   event selector. use 'perf list' to list available events
  [root@felicio ~]#

Way too much verbosity, I think this should be just:

  [root@felicio ~]# perf record -e ./foo.o sleep 1
  perf: Failed to open ./foo.o: No such file or directory

I.e. Avoid messages coming directly from a library, as you don't know
what kind of UI tools using such library will use, it maybe GTK, for
instance, and then sending stuff to stderr or stdout is inappropriate.
 
> I have reproduced the problem. Haven't noticed that because I always use './' name.

Right, right now this is required, it should not be.
 
> Will look into it.

Thanks, I will try checkint the other patches, taking this current
limitation into account, so that I can comment on them.

- 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]


#1198939

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-03 17:20 +0200
Message-ID<pTpGW-6PV-19@gated-at.bofh.it>
In reply to#1198920
Em Mon, Aug 03, 2015 at 12:07:28PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Aug 03, 2015 at 10:37:59AM +0800, Wangnan (F) escreveu:
> > On 2015/8/1 4:31, Arnaldo Carvalho de Melo wrote:
> > >Somehow it is not calling what the changeset says it would call when passing
> > >"-e foo.o", investigating...
>  
> > Have you tried
>  
> > /root/bin/perf record -e ./foo.o sleep 1
> 
> > The key is './'.
> 
> Nope, trying it now I get:
> 
>   [root@felicio ~]# perf record -e ./foo.o sleep 1
>   libbpf: failed to open ./foo.o: No such file or directory
>   bpf: failed to load ./foo.o

And with a .c suffix:

  [root@felicio ~]# perf record -e ./foo.c sleep 1
  clang-3.8: error: no such file or directory: '/root/./foo.c'
  clang-3.8: error: no input files
  ERROR:	unable to compile ./foo.c
  Hint:	Check error message shown above.
     	LLVM 3.7 or newer is required. Which can be found from http://llvm.org
     	You may want to try git trunk:
     		git clone http://llvm.org/git/llvm.git
     		     and
     		git clone http://llvm.org/git/clang.git

     	Or fetch the latest clang/llvm 3.7 from pre-built llvm packages for
     	debian/ubuntu:
     		http://llvm.org/apt

     	If you are using old version of clang, change 'clang-bpf-cmd-template'
     	option in [llvm] section of ~/.perfconfig to:

     	  "$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS \
     	     -working-directory $WORKING_DIR -c $CLANG_SOURCE \
     	     -emit-llvm -o - | /path/to/llc -march=bpf -filetype=obj -o -"
     	(Replace /path/to/llc with path to your llc)

  Hint:	You can also pre-compile it into .o
  invalid or unsupported event: './foo.c'
  Run 'perf list' for a list of valid events

   usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list available events
  [root@felicio ~]#

Now to find a hello.c BPF scriptlet...

- 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]


#1198985 — Re: perf eBPF patch ordering. was: Re: perf test LLVM was: Re: [GIT PULL 00/39] perf tools: filtering events using eBPF programs

Frompi3orama <pi3orama@163.com>
Date2015-08-03 18:00 +0200
SubjectRe: perf eBPF patch ordering. was: Re: perf test LLVM was: Re: [GIT PULL 00/39] perf tools: filtering events using eBPF programs
Message-ID<pTqjE-7A6-15@gated-at.bofh.it>
In reply to#1198939

发自我的 iPhone

> 在 2015年8月3日,下午11:19,Arnaldo Carvalho de Melo <acme@kernel.org> 写道:
> 
> Em Mon, Aug 03, 2015 at 12:07:28PM -0300, Arnaldo Carvalho de Melo escreveu:
>> Em Mon, Aug 03, 2015 at 10:37:59AM +0800, Wangnan (F) escreveu:
>>> On 2015/8/1 4:31, Arnaldo Carvalho de Melo wrote:
>>>> Somehow it is not calling what the changeset says it would call when passing
>>>> "-e foo.o", investigating...
>> 
>>> Have you tried
>> 
>>> /root/bin/perf record -e ./foo.o sleep 1
>> 
>>> The key is './'.
>> 
>> Nope, trying it now I get:
>> 
>>  [root@felicio ~]# perf record -e ./foo.o sleep 1
>>  libbpf: failed to open ./foo.o: No such file or directory
>>  bpf: failed to load ./foo.o
> 
> And with a .c suffix:
> 
>  [root@felicio ~]# perf record -e ./foo.c sleep 1
>  clang-3.8: error: no such file or directory: '/root/./foo.c'
>  clang-3.8: error: no input files

What's the content of your foo.c? Could you please have a look?

I considered moving .o enabler down so when you see that patch the filter will be
 workable. However , like the llvm support, doing so will enable a bulk of code by
one patch, that's not good. Moving .c enabler down is easy.

Now I'm working on a BPF testcase. Tomorrow you will see a new test:

# perf test BPF

It enforces test__llvm, and forks a 'perf record' to do the filtering, then checks the
result using perf report -D. The patch of the new test is a mark which indicates the
basic function of BPF filter is done. What do you think about this idea?

Thank you.

>  ERROR:    unable to compile ./foo.c
>  Hint:    Check error message shown above.
>         LLVM 3.7 or newer is required. Which can be found from http://llvm.org
>         You may want to try git trunk:
>             git clone http://llvm.org/git/llvm.git
>                  and
>             git clone http://llvm.org/git/clang.git
> 
>         Or fetch the latest clang/llvm 3.7 from pre-built llvm packages for
>         debian/ubuntu:
>             http://llvm.org/apt
> 
>         If you are using old version of clang, change 'clang-bpf-cmd-template'
>         option in [llvm] section of ~/.perfconfig to:
> 
>           "$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS \
>              -working-directory $WORKING_DIR -c $CLANG_SOURCE \
>              -emit-llvm -o - | /path/to/llc -march=bpf -filetype=obj -o -"
>         (Replace /path/to/llc with path to your llc)
> 
>  Hint:    You can also pre-compile it into .o
>  invalid or unsupported event: './foo.c'
>  Run 'perf list' for a list of valid events
> 
>   usage: perf record [<options>] [<command>]
>      or: perf record [<options>] -- <command> [<options>]
> 
>      -e, --event <event>   event selector. use 'perf list' to list available events
>  [root@felicio ~]#
> 
> Now to find a hello.c BPF scriptlet...
> 
> - 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]


#1199009

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-03 18:20 +0200
Message-ID<pTqD0-8cj-17@gated-at.bofh.it>
In reply to#1198985
Em Mon, Aug 03, 2015 at 11:53:05PM +0800, pi3orama escreveu:
> 
> 
> 发自我的 iPhone
> 
> > 在 2015年8月3日,下午11:19,Arnaldo Carvalho de Melo <acme@kernel.org> 写道:
> > 
> > Em Mon, Aug 03, 2015 at 12:07:28PM -0300, Arnaldo Carvalho de Melo escreveu:
> >> Em Mon, Aug 03, 2015 at 10:37:59AM +0800, Wangnan (F) escreveu:
> >>> On 2015/8/1 4:31, Arnaldo Carvalho de Melo wrote:
> >>>> Somehow it is not calling what the changeset says it would call when passing
> >>>> "-e foo.o", investigating...
> >> 
> >>> Have you tried
> >> 
> >>> /root/bin/perf record -e ./foo.o sleep 1
> >> 
> >>> The key is './'.
> >> 
> >> Nope, trying it now I get:
> >> 
> >>  [root@felicio ~]# perf record -e ./foo.o sleep 1
> >>  libbpf: failed to open ./foo.o: No such file or directory
> >>  bpf: failed to load ./foo.o
> > 
> > And with a .c suffix:
> > 
> >  [root@felicio ~]# perf record -e ./foo.c sleep 1
> >  clang-3.8: error: no such file or directory: '/root/./foo.c'
> >  clang-3.8: error: no input files
> 
> What's the content of your foo.c? Could you please have a look?

I said:

> > Now to find a hello.c BPF scriptlet...

Because, as clang says: "error: no such file or directory: '/root/./foo.c'"

It doesn't exists :-)
 
> I considered moving .o enabler down so when you see that patch the filter will be
>  workable. However , like the llvm support, doing so will enable a bulk of code by
> one patch, that's not good. Moving .c enabler down is easy.

Right, probably leaving the .c enabler to be the last one, together with
a "hello_bpf.c" that we can use in testing it is best.
 
> Now I'm working on a BPF testcase. Tomorrow you will see a new test:
 
> # perf test BPF
 
> It enforces test__llvm, and forks a 'perf record' to do the filtering, then checks the
> result using perf report -D. The patch of the new test is a mark which indicates the
> basic function of BPF filter is done. What do you think about this idea?

Excellent idea, you could even save the intermediary .o file and use it
in another test :-)

Sometimes we can't straight away test some infrastructure because the
patch at hand is just glue, that will later be used by a tool, 'perf
record', say, in those cases we can test this glue by using it in a
'perf test' entry.

Thanks!

- Arnaldo
 
> Thank you.
> 
> >  ERROR:    unable to compile ./foo.c
> >  Hint:    Check error message shown above.
> >         LLVM 3.7 or newer is required. Which can be found from http://llvm.org
> >         You may want to try git trunk:
> >             git clone http://llvm.org/git/llvm.git
> >                  and
> >             git clone http://llvm.org/git/clang.git
> > 
> >         Or fetch the latest clang/llvm 3.7 from pre-built llvm packages for
> >         debian/ubuntu:
> >             http://llvm.org/apt
> > 
> >         If you are using old version of clang, change 'clang-bpf-cmd-template'
> >         option in [llvm] section of ~/.perfconfig to:
> > 
> >           "$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS \
> >              -working-directory $WORKING_DIR -c $CLANG_SOURCE \
> >              -emit-llvm -o - | /path/to/llc -march=bpf -filetype=obj -o -"
> >         (Replace /path/to/llc with path to your llc)
> > 
> >  Hint:    You can also pre-compile it into .o
> >  invalid or unsupported event: './foo.c'
> >  Run 'perf list' for a list of valid events
> > 
> >   usage: perf record [<options>] [<command>]
> >      or: perf record [<options>] -- <command> [<options>]
> > 
> >      -e, --event <event>   event selector. use 'perf list' to list available events
> >  [root@felicio ~]#
> > 
> > Now to find a hello.c BPF scriptlet...
> > 
> > - 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]


#1199227

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-08-03 21:50 +0200
Message-ID<pTtUe-4n6-25@gated-at.bofh.it>
In reply to#1199009
Em Mon, Aug 03, 2015 at 01:11:16PM -0300, Arnaldo Carvalho de Melo escreveu:
> > >  ERROR:    unable to compile ./foo.c
> > >  Hint:    Check error message shown above.
> > >         LLVM 3.7 or newer is required. Which can be found from http://llvm.org
> > >         You may want to try git trunk:
> > >             git clone http://llvm.org/git/llvm.git
> > >                  and
<SNIP>
> > >      or: perf record [<options>] -- <command> [<options>]

> > >      -e, --event <event>   event selector. use 'perf list' to list available events
> > >  [root@felicio ~]#

> > > Now to find a hello.c BPF scriptlet...

So, we do not need to provide all this LLVM environment installation
hints when we get to any error, i.e. the one above was just becasuse
"./foo.c" doesn't exist, clang ran successfully, so no need for telling
the user how to install it.

The following error also shouldn't emit those hints:

  [root@felicio ~]# perf record -e ./lock_page.bpf.c sleep 1
  /root/./lock_page.bpf.c:1:5: error: expected parameter declarator
  SEC("lock_page=__lock_page page->flags")
      ^
  /root/./lock_page.bpf.c:1:5: error: expected ')'
  /root/./lock_page.bpf.c:1:4: note: to match this '('
  SEC("lock_page=__lock_page page->flags")
     ^
  /root/./lock_page.bpf.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  SEC("lock_page=__lock_page page->flags")
  ^
  /root/./lock_page.bpf.c:1:41: error: expected ';' after top level declarator
  SEC("lock_page=__lock_page page->flags")
                                          ^
                                          ;
  /root/./lock_page.bpf.c:2:22: warning: declaration of 'struct pt_regs' will not be visible outside of this function [-Wvisibility]
  int lock_page(struct pt_regs *ctx, int err, unsigned long flags)
                     ^
  2 warnings and 3 errors generated.
  ERROR:	unable to compile ./lock_page.bpf.c
  Hint:	Check error message shown above.
     	LLVM 3.7 or newer is required. Which can be found from http://llvm.org
     	You may want to try git trunk:
     		git clone http://llvm.org/git/llvm.git
     		     and
     		git clone http://llvm.org/git/clang.git

     	Or fetch the latest clang/llvm 3.7 from pre-built llvm packages for
     	debian/ubuntu:
     		http://llvm.org/apt

     	If you are using old version of clang, change 'clang-bpf-cmd-template'
     	option in [llvm] section of ~/.perfconfig to:

     	  "$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS \
     	     -working-directory $WORKING_DIR -c $CLANG_SOURCE \
     	     -emit-llvm -o - | /path/to/llc -march=bpf -filetype=obj -o -"
     	(Replace /path/to/llc with path to your llc)

  Hint:	You can also pre-compile it into .o
  invalid or unsupported event: './lock_page.bpf.c'
  Run 'perf list' for a list of valid events

   usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list available events
  [root@felicio ~]# 

And I am interested in that "Hint: You can also pre-compile it into .o", seems
like a useful one, if it  was on the screen, i.e. how can I pre-compile this
into a .o, its some random piece of eBPF "scriptlet" I found in one of your
csets, after this cset in your patchkit:

  [root@felicio ~]# cat lock_page.bpf.c 
  SEC("lock_page=__lock_page page->flags")
  int lock_page(struct pt_regs *ctx, int err, unsigned long flags)
  {
  	return 1;
  }
  [root@felicio ~]#

Also it would be nice to tell the user, when compilation fails, where to look
for a eBPF scriptlet primer, i.e. where can I find some documentation on how
to write such scriptlets?

At this point I expect it to build the .c into a .o, then, as the wiring up is
not there, tell the user that all went well, but more infrastructure is needed,
apply the following patches from Wang Nan! 8-)

- 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]


#1199415

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-08-04 07:30 +0200
Message-ID<pTCXw-Vx-7@gated-at.bofh.it>
In reply to#1199227
Hi Arnaldo,

The following changes since commit 922cc21746202956acb41c89a6190bb50805fa31:

   perf tools: Introduce llvm config options (2015-07-31 12:17:50 -0300)

are available in the git repository at:

   https://github.com/WangNan0/linux.git ebpf

for you to fetch changes up to d85bf4b6470b8d860bbae25418e5ae3ccd9711e8:

   perf tools: Support attach BPF program on uprobe events (2015-08-04 
04:59:20 +0000)

----------------------------------------------------------------

The new cset has following improvements:

1. Improve error message: now don't dump LLVM environment setting messages
    if clang is found. Also, describe how to pre-compile .c file into .o.

    See: perf tools: Call clang to compile C source to object code
https://github.com/WangNan0/linux/commit/264676a5b922aaf1e9be3800fe06d5b67b06cd12

2. Reorder patches, so when 'perf record' is able to accept '--event 
file.c', the BPF filter
    should work. Also, an example BPF script file is provided, and the 
compilation
    method is described in commit message.

    See:
         perf tools: Infrastructure for compiling scriptlets when 
passing '.c' to --event
https://github.com/WangNan0/linux/commit/eca622f4a88e1a791fc2405c398256ad572eba54

3. Introduce 'perf test BPF', which uses previous introduced scriptlet, 
fork a
    'perf record' to utilise it and uses 'perf report' to check the result.

    See: perf tests: Enforce LLVM test for BPF test
https://github.com/WangNan0/linux/commit/a7cdab453863c580446dc2c3a3f3a86f21b770ce

         perf test: Enable 'perf test' run as test targets
https://github.com/WangNan0/linux/commit/b14f2627e95d348be5ec19bd24a5117e8c2ffe46
     and
         perf test: Add 'perf test BPF'
https://github.com/WangNan0/linux/commit/8414217dbfa57df4dbb55642dc26205e1c7cbdf1

4. Fix a bug that if the filename doesn't contain '/' it is recongnised 
as event name then
    failed to be applied by order adjusting in parse-events.l: bring 
{bpf_object} and
    {bpf_source} ahead.

You need to pop 9 patches from your perf/ebpf tree and rebase my tree. 
However, until
patch "perf tools: Enable passing bpf object file to --event" the 
changes is tiny. Please
check.

Thank you.

On 2015/8/4 3:49, Arnaldo Carvalho de Melo wrote:
> Em Mon, Aug 03, 2015 at 01:11:16PM -0300, Arnaldo Carvalho de Melo escreveu:
>>>>   ERROR:    unable to compile ./foo.c
>>>>   Hint:    Check error message shown above.
>>>>          LLVM 3.7 or newer is required. Which can be found from http://llvm.org
>>>>          You may want to try git trunk:
>>>>              git clone http://llvm.org/git/llvm.git
>>>>                   and
> <SNIP>
>>>>       or: perf record [<options>] -- <command> [<options>]
>>>>       -e, --event <event>   event selector. use 'perf list' to list available events
>>>>   [root@felicio ~]#
>>>> Now to find a hello.c BPF scriptlet...
> So, we do not need to provide all this LLVM environment installation
> hints when we get to any error, i.e. the one above was just becasuse
> "./foo.c" doesn't exist, clang ran successfully, so no need for telling
> the user how to install it.
>
> The following error also shouldn't emit those hints:
>
>    [root@felicio ~]# perf record -e ./lock_page.bpf.c sleep 1
>    /root/./lock_page.bpf.c:1:5: error: expected parameter declarator
>    SEC("lock_page=__lock_page page->flags")
>        ^
>    /root/./lock_page.bpf.c:1:5: error: expected ')'
>    /root/./lock_page.bpf.c:1:4: note: to match this '('
>    SEC("lock_page=__lock_page page->flags")
>       ^
>    /root/./lock_page.bpf.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
>    SEC("lock_page=__lock_page page->flags")
>    ^
>    /root/./lock_page.bpf.c:1:41: error: expected ';' after top level declarator
>    SEC("lock_page=__lock_page page->flags")
>                                            ^
>                                            ;
>    /root/./lock_page.bpf.c:2:22: warning: declaration of 'struct pt_regs' will not be visible outside of this function [-Wvisibility]
>    int lock_page(struct pt_regs *ctx, int err, unsigned long flags)
>                       ^
>    2 warnings and 3 errors generated.
>    ERROR:	unable to compile ./lock_page.bpf.c
>    Hint:	Check error message shown above.
>       	LLVM 3.7 or newer is required. Which can be found from http://llvm.org
>       	You may want to try git trunk:
>       		git clone http://llvm.org/git/llvm.git
>       		     and
>       		git clone http://llvm.org/git/clang.git
>
>       	Or fetch the latest clang/llvm 3.7 from pre-built llvm packages for
>       	debian/ubuntu:
>       		http://llvm.org/apt
>
>       	If you are using old version of clang, change 'clang-bpf-cmd-template'
>       	option in [llvm] section of ~/.perfconfig to:
>
>       	  "$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS \
>       	     -working-directory $WORKING_DIR -c $CLANG_SOURCE \
>       	     -emit-llvm -o - | /path/to/llc -march=bpf -filetype=obj -o -"
>       	(Replace /path/to/llc with path to your llc)
>
>    Hint:	You can also pre-compile it into .o
>    invalid or unsupported event: './lock_page.bpf.c'
>    Run 'perf list' for a list of valid events
>
>     usage: perf record [<options>] [<command>]
>        or: perf record [<options>] -- <command> [<options>]
>
>        -e, --event <event>   event selector. use 'perf list' to list available events
>    [root@felicio ~]#
>
> And I am interested in that "Hint: You can also pre-compile it into .o", seems
> like a useful one, if it  was on the screen, i.e. how can I pre-compile this
> into a .o, its some random piece of eBPF "scriptlet" I found in one of your
> csets, after this cset in your patchkit:
>
>    [root@felicio ~]# cat lock_page.bpf.c
>    SEC("lock_page=__lock_page page->flags")
>    int lock_page(struct pt_regs *ctx, int err, unsigned long flags)
>    {
>    	return 1;
>    }
>    [root@felicio ~]#
>
> Also it would be nice to tell the user, when compilation fails, where to look
> for a eBPF scriptlet primer, i.e. where can I find some documentation on how
> to write such scriptlets?
>
> At this point I expect it to build the .c into a .o, then, as the wiring up is
> not there, tell the user that all went well, but more infrastructure is needed,
> apply the following patches from Wang Nan! 8-)
>
> - 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]


#1199652

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-08-04 12:50 +0200
Message-ID<pTHXc-86v-17@gated-at.bofh.it>
In reply to#1199415

On 2015/8/4 13:28, Wangnan (F) wrote:
> Hi Arnaldo,
>
> The following changes since commit 
> 922cc21746202956acb41c89a6190bb50805fa31:
>
>   perf tools: Introduce llvm config options (2015-07-31 12:17:50 -0300)
>
> are available in the git repository at:
>
>   https://github.com/WangNan0/linux.git ebpf
>
> for you to fetch changes up to d85bf4b6470b8d860bbae25418e5ae3ccd9711e8:
>
>   perf tools: Support attach BPF program on uprobe events (2015-08-04 
> 04:59:20 +0000)
>
> ----------------------------------------------------------------
>
> The new cset has following improvements:
>
> 1. Improve error message: now don't dump LLVM environment setting 
> messages
>    if clang is found. Also, describe how to pre-compile .c file into .o.
>
>    See: perf tools: Call clang to compile C source to object code
> https://github.com/WangNan0/linux/commit/264676a5b922aaf1e9be3800fe06d5b67b06cd12 
>
>
> 2. Reorder patches, so when 'perf record' is able to accept '--event 
> file.c', the BPF filter
>    should work. Also, an example BPF script file is provided, and the 
> compilation
>    method is described in commit message.
>
>    See:
>         perf tools: Infrastructure for compiling scriptlets when 
> passing '.c' to --event
> https://github.com/WangNan0/linux/commit/eca622f4a88e1a791fc2405c398256ad572eba54 
>
>
> 3. Introduce 'perf test BPF', which uses previous introduced 
> scriptlet, fork a
>    'perf record' to utilise it and uses 'perf report' to check the 
> result.
>
>    See: perf tests: Enforce LLVM test for BPF test
> https://github.com/WangNan0/linux/commit/a7cdab453863c580446dc2c3a3f3a86f21b770ce 
>
>
>         perf test: Enable 'perf test' run as test targets
> https://github.com/WangNan0/linux/commit/b14f2627e95d348be5ec19bd24a5117e8c2ffe46 
>
>     and
>         perf test: Add 'perf test BPF'
> https://github.com/WangNan0/linux/commit/8414217dbfa57df4dbb55642dc26205e1c7cbdf1 
>

Just realized that 'tempnam' is not safe. Switch to mkdtemp. Please see 
the new version:

https://github.com/WangNan0/linux/commit/bd02aed760c4a35fec4483d24c158799f05f6f9e

and pull request update:

The following changes since commit 922cc21746202956acb41c89a6190bb50805fa31:

   perf tools: Introduce llvm config options (2015-07-31 12:17:50 -0300)

are available in the git repository at:

   https://github.com/WangNan0/linux.git ebpf

for you to fetch changes up to 47ef1d2a64bd0e7931835e1c40caed21f793c8b8:

   perf tools: Support attach BPF program on uprobe events (2015-08-04 
10:30:50 +0000)

Thank you.



--
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] | [standalone]


Back to top | Article view | linux.kernel


csiph-web