Em Wed, Oct 14, 2015 at 12:41:20PM +0000, Wang Nan escreveu:
> This patch provides infrastructure for passing source files to --event
> directly using:
> 
>  # perf record --event bpf-file.c command
> 
> This patch does following works:
> 
>  1) Allow passing '.c' file to '--event'. parse_events_load_bpf() is
>     expanded to allow caller tell it whether the passed file is source
>     file or object.
> 
>  2) llvm__compile_bpf() is called to compile the '.c' file, the result
>     is saved into memory. Use bpf_object__open_buffer() to load the
>     in-memory object.
> 
> Introduces a bpf-script-example.c so we can manually test it:
> 
>  # perf record --clang-opt "-DLINUX_VERSION_CODE=0x40200" --event 
> ./bpf-script-example.c sleep 1
> 
> Note that '--clang-opt' must put before '--event'.
> 
> Futher patches will merge it into a testcase so can be tested automatically.

Not working here... humm, perhaps the version again...

[root@felicio linux]# perf record --clang-opt "-DLINUX_VERSION_CODE=0x40200" 
--event tools/perf/tests/bpf-script-example.c sleep 1
libbpf: load bpf program failed: Invalid argument
libbpf: -- BEGIN DUMP LOG ---
libbpf: 

libbpf: -- END LOG --
libbpf: failed to load program 'func=sys_epoll_pwait'

Yeah, as soon as I used:

# perf record --clang-opt "-DLINUX_VERSION_CODE=0x40300" --event 
tools/perf/tests/bpf-script-example.c sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data ]
[root@felicio linux]# 

I think we should provide some stuff like this LINUX_VERSION_CODE
automagically, right?

And also check the version in a .o file, to make sure we don't ask the
kernel to load something with a mismatch in that version.

And you could've provided something that would actually do something
meaningful, i.e.  a filter that would capture some samples for a given event
while discarding something not that important...

I.e. show the value provided at the time we build that patch.

I'll try to come up with something like that after I have lunch, but so far
so good, I think I'll be able to send this to Ingo today, and that is a major
milestone!

Great work, thanks a lot for doing this!

- Arnaldo

P.S.: If we pass a .c ending string to 'trace', 'record', 'top', etc, I think
we could do away with that pesky --event/-e, i.e.:

        trace cool_stuff.c

Would do the right thing, i.e. be equivalent to:

        trace --event cool_stuff.c
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to