From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752973AbbJWQ6p (ORCPT ); Fri, 23 Oct 2015 12:58:45 -0400 Received: from mail.kernel.org ([198.145.29.136]:43806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752014AbbJWQ6o (ORCPT ); Fri, 23 Oct 2015 12:58:44 -0400 Date: Fri, 23 Oct 2015 13:58:40 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: ast@plumgrid.com, brendan.d.gregg@gmail.com, a.p.zijlstra@chello.nl, daniel@iogearbox.net, dsahern@gmail.com, hekuang@huawei.com, jolsa@kernel.org, lizefan@huawei.com, masami.hiramatsu.pt@hitachi.com, namhyung@kernel.org, paulus@samba.org, linux-kernel@vger.kernel.org, pi3orama@163.com, xiakaixu@huawei.com Subject: Re: [PATCH 05/31] perf record: Load eBPF object into kernel Message-ID: <20151023165840.GI27006@kernel.org> References: <1444826502-49291-1-git-send-email-wangnan0@huawei.com> <1444826502-49291-6-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1444826502-49291-6-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 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 [] [] or: perf record [] -- [] -e, --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