Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713AbbFLQ6b (ORCPT ); Fri, 12 Jun 2015 12:58:31 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:33429 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751199AbbFLQ63 (ORCPT ); Fri, 12 Jun 2015 12:58:29 -0400 Message-ID: <557B0FB4.6000506@plumgrid.com> Date: Fri, 12 Jun 2015 09:58:28 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Wang Nan , acme@kernel.org, brendan.d.gregg@gmail.com, daniel@iogearbox.net, namhyung@kernel.org, masami.hiramatsu.pt@hitachi.com, paulus@samba.org, a.p.zijlstra@chello.nl, mingo@redhat.com, jolsa@kernel.org, dsahern@gmail.com CC: linux-kernel@vger.kernel.org, lizefan@huawei.com, hekuang@huawei.com, xiakaixu@huawei.com, pi3orama@163.com Subject: Re: [RFC PATCH v7 00/37] perf tools: filtering events using eBPF programs References: <1434087345-127225-1-git-send-email-wangnan0@huawei.com> In-Reply-To: <1434087345-127225-1-git-send-email-wangnan0@huawei.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3020 Lines: 76 On 6/11/15 10:35 PM, Wang Nan wrote: > This is the 7th version which tries to introduce eBPF programs to perf. > It enables 'perf record' to filter events using eBPF programs like: > > # perf record --event bpf-file.c sleep 1 > > and > > # perf record --event bpf-file.o sleep 1 > > This patch series is based on tip/perf/core (028c63b). > > Compare with v6 patch, this series totally refactor code for llvm > compiling '.c' into BPF object file using LLVM. Including: > > 1. A specific file tools/perf/util/llvm-utils.c is introduced for > holding all llvm/clang related work, instead of putting them into > bpf-loader.c. > > 2. Automatically detect kernel include options by embedded shell > script. > > 3. Use command line template to generate compiler commands instead of > assemble cmdline with printf, passing variables using environment. > Which enable users to define their own compiler commands. > > 4. Introduce '[llvm]' section to perf default config. > 5 options can be configured, but all of them can be omitted: > > [llvm] > # Path to clang. If omit, search it from $PATH. > clang-path = "/path/to/clang" > > # Cmdline template. Following line shows its default value. > # Environment variable is used to passing options. > clang-bpf-cmd-template = "$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c $CLANG_SOURCE -target bpf -O2 -o -" > > # Option passed to clang, will be passed to cmdline by $CLANG_OPTIONS. > clang-opt = "-Wno-unused-value -Wno-pointer-sign" > > # kbuild directory. If not set, use /lib/modules/`uname -r`/build. > # If set to "" deliberately, skip kernel header auto-detector. > kbuild-dir = "/path/to/kernel/build" > > # Options passed to 'make' when detecting kernel header options. > kbuild-opts = "ARCH=x86_64" > > Command line options '--clang-path' and '--clang-opt' is appended to > 'perf record'. > > 5. LLVM and BPF opening testcase is adding into 'perf test': > > # perf test 37 > 37: Test LLVM searching and compiling : Ok > > 6. Warning and error messages improvement. > > 7. Issue clang command suit for newest clang which support > '-target bpf', instead of calling > 'clang -emit-llvm | llc -march=bpf' pipe. All looks great to me. Piping clang into stdout to skip .o on a disk is a nice touch. 'usability hints' have improved as well. Thanks a lot for the hard work. btw, what compile times do you see? On my machine compiling basic hello_world.c with #include bpf_helpers.h and few kernel headers take: 0.02 sec So using .c is quite instant. Feels like interpreted language ;) -- 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/