From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753050AbbJXBUU (ORCPT ); Fri, 23 Oct 2015 21:20:20 -0400 Received: from m12-14.163.com ([220.181.12.14]:56097 "EHLO m12-14.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925AbbJXBUR convert rfc822-to-8bit (ORCPT ); Fri, 23 Oct 2015 21:20:17 -0400 Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 05/31] perf record: Load eBPF object into kernel From: pi3orama X-Mailer: iPhone Mail (13A452) In-Reply-To: <20151023165840.GI27006@kernel.org> Date: Sat, 24 Oct 2015 09:18:56 +0800 Cc: Wang Nan , 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, xiakaixu@huawei.com Content-Transfer-Encoding: 8BIT Message-Id: References: <1444826502-49291-1-git-send-email-wangnan0@huawei.com> <1444826502-49291-6-git-send-email-wangnan0@huawei.com> <20151023165840.GI27006@kernel.org> To: Arnaldo Carvalho de Melo X-CM-TRANSID: DsCowEA50E9_3CpWHl_XEg--.56139S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZF4xJFy7ZrWfGry5Wr17Jrb_yoW5AF4xpF sYk34FgF40g34rX34DAa1a9ay3A34DCr45JFy7Wr4UAa4YqFn7Wws29F129rn8Wrs09a4I vayfJrn5G34DZ3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07USLvNUUUUU= X-Originating-IP: [210.73.4.168] X-CM-SenderInfo: lslt02xdpdqiywtou0bp/xtbBdRydQFEAO649YAAAst Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 发自我的 iPhone > 在 2015年10月24日,上午12:58,Arnaldo Carvalho de Melo 写道: > > 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 [] [] > 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