Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932310AbbHCTtY (ORCPT ); Mon, 3 Aug 2015 15:49:24 -0400 Received: from mail.kernel.org ([198.145.29.136]:42741 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932185AbbHCTtX (ORCPT ); Mon, 3 Aug 2015 15:49:23 -0400 Date: Mon, 3 Aug 2015 16:49:17 -0300 From: Arnaldo Carvalho de Melo To: pi3orama Cc: "Wangnan (F)" , He Kuang , Li Zefan , Alexei Starovoitov , Xia Kaixu , linux-kernel@vger.kernel.org, Ingo Molnar , Jiri Olsa , David Ahern , Namhyung Kim Subject: Re: perf eBPF patch ordering. was: Re: perf test LLVM was: Re: [GIT PULL 00/39] perf tools: filtering events using eBPF programs Message-ID: <20150803194917.GE5498@kernel.org> References: <55AE2858.6040409@huawei.com> <20150721114151.GF5368@kernel.org> <55AF1EA5.5020500@huawei.com> <20150731153522.GA16700@kernel.org> <20150731203125.GB16700@kernel.org> <55BED407.9090009@huawei.com> <20150803150728.GA3864@kernel.org> <20150803151905.GE3864@kernel.org> <20150803161116.GB5498@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150803161116.GB5498@kernel.org> 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 Content-Length: 4136 Lines: 98 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 > > > or: perf record [] -- [] > > > -e, --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 [] [] or: perf record [] -- [] -e, --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/