Re: [PATCH 05/31] perf record: Load eBPF object into kernel

From: pi3orama
Date: Fri Oct 23 2015 - 21:20:24 EST




发自我的 iPhone

> 在 2015年10月24日,上午12:58,Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> 写道:
>
> Em Wed, Oct 14, 2015 at 12:41:16PM +0000, Wang Nan escreveu:
>> This patch utilizes bpf_object__load() provided by libbpf to load all
>> objects into kernel.
>
> So, testing this, using that other proggie, I get;
>
> # perf record --event /tmp/foo.o sleep 1
> libbpf: load bpf program failed: Invalid argument
> libbpf: -- BEGIN DUMP LOG ---
> libbpf:
>
> libbpf: -- END LOG --

This means your kernel version and version section in your BPF object doesn't
match each other. Please try to pass a correct version code when compiling the
object. I think we should output something through error log so by -v we can see
the problem. I told Alexei about this problem once. Let me improve perf's
error message next week.

Thank you.


> libbpf: failed to load program 'fork=_do_fork'
> libbpf: failed to load object '/tmp/foo.o'
> event syntax error: '/tmp/foo.o'
> \___ Invalid argument: Are you root and runing a CONFIG_BPF_SYSCALL kernel?
>
> (add -v to see detail)
> 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
>
> But:
>
> [root@felicio ~]# grep -i bpf /proc/kallsyms | wc -l
> 117
> [root@felicio ~]# grep -i sys_bpf /proc/kallsyms
> ffffffff811829d0 T SyS_bpf
> ffffffff811829d0 T sys_bpf
> [root@felicio ~]# uname -a
> Linux felicio.ghostprotocols.net 4.2.0 #1 SMP Mon Aug 31 12:25:38 BRT
> 2015 x86_64 x86_64 x86_64 GNU/Linux
> [root@felicio ~]#
>
>
> I'll try updating it to torvalds/master...
>
> For reference, that foo.o eBPF proggie was built with:
>
> [acme@felicio linux]$ cat ~/bin/hello-ebpf
> # Taken from 'perf test LLVM'
> # Thu Oct 22 12:07:26 BRT 2015
>
> export 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"
> export WORKING_DIR=/lib/modules/4.2.0/build
> export CLANG_SOURCE=-
> export CLANG_OPTIONS=-xc
>
> OBJ=/tmp/foo.o
> rm -f $OBJ
> echo '__attribute__((section("fork=_do_fork"), used)) int fork(void
> *ctx) {return 0;} char _license[] __attribute__((section("license"),
> used)) = "GPL";int _version __attribute__((section("version"), used)) =
> 0x40100;' | clang -D__KERNEL__ $CLANG_OPTIONS $KERNEL_INC_OPTIONS
> -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c
> "$CLANG_SOURCE" -target bpf -O2 -o /tmp/foo.o && file $OBJ
>
> - Arnaldo

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/