From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757748AbbJ2Q0D (ORCPT ); Thu, 29 Oct 2015 12:26:03 -0400 Received: from mail.kernel.org ([198.145.29.136]:44964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751801AbbJ2Q0B (ORCPT ); Thu, 29 Oct 2015 12:26:01 -0400 Date: Thu, 29 Oct 2015 13:25:53 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan , Ingo Molnar 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 09/31] perf tools: Compile scriptlets to BPF objects when passing '.c' to --event Message-ID: <20151029162553.GE2923@kernel.org> References: <1444826502-49291-1-git-send-email-wangnan0@huawei.com> <1444826502-49291-10-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-10-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: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