All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Wang Nan <wangnan0@huawei.com>
Cc: alexei.starovoitov@gmail.com, lizefan@huawei.com,
	linux-kernel@vger.kernel.org, pi3orama@163.com,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Alexei Starovoitov <ast@fb.com>, He Kuang <hekuang@huawei.com>,
	Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH v2 00/18] perf clang: Support compiling BPF script on the fly
Date: Wed, 5 Oct 2016 20:20:57 -0300	[thread overview]
Message-ID: <20161005232057.GL30363@kernel.org> (raw)
In-Reply-To: <1474874832-134786-1-git-send-email-wangnan0@huawei.com>

Em Mon, Sep 26, 2016 at 07:26:54AM +0000, Wang Nan escreveu:
> This patch add builtin clang, allow perf compile BPF scripts on the fly.
> This is the first step to implement what I announced at LinuxCon 2016 NA:

Ok, so I refreshed this series to apply against my latest perf/core and
put it in a tmp.perf/builtin-clang, will continue testing it tomorrow
after checking if fedora24 has those llvm-dev and libclang-dev that can
be used with this, do you know if it works on that distro?

Cool stuff! :-)

- Arnaldo
 
> http://events.linuxfoundation.org/sites/events/files/slides/Performance%20Monitoring%20and%20Analysis%20Using%20perf%20and%20BPF_1.pdf
> 
> Compare with v1:
>  1. Fix API usage so can be built at Ubuntu 16.04 (with llvm-dev and
>     libclang-dev installed)
>  2. Introduce default include files so BPF script writer doesn't need
>     define many BPF functions by their own.
> 
> Test:
> 
>  # cat ./test_bpf_output.c
>  /************************ BEGIN **************************/
>  #include <uapi/linux/bpf.h>
>  struct bpf_map_def SEC("maps") __bpf_stdout__ = {
>         .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
>         .key_size = sizeof(int),
>         .value_size = sizeof(u32),
>         .max_entries = __NR_CPUS__,
>  };
> 
>  static inline int __attribute__((always_inline))
>  func(void *ctx, int type)
>  {
> 	char output_str[] = "Raise a BPF event!";
> 
>         bpf_perf_event_output(ctx, &__bpf_stdout__, bpf_get_smp_processor_id(),
> 			  &output_str, sizeof(output_str));
>         return 0;
>  }
>  SEC("func_begin=sys_nanosleep")
>  int func_begin(void *ctx) {return func(ctx, 1);}
>  SEC("func_end=sys_nanosleep%return")
>  int func_end(void *ctx) { return func(ctx, 2);}
>  char _license[] SEC("license") = "GPL";
>  int _version SEC("version") = LINUX_VERSION_CODE;
>  /************************* END ***************************/
>  # perf trace --event ./test_bpf_output.c usleep 10
>  ...
>  0.449 ( 0.002 ms): usleep/827 getuid(                                                               ) = 0
>  0.482 ( 0.006 ms): usleep/827 nanosleep(rqtp: 0x7ffecc22fa50                                        ) ...
>  0.482 (         ): __bpf_stdout__:Raise a BPF event!..)
>  0.555 (         ): __bpf_stdout__:Raise a BPF event!..)
>  0.557 ( 0.081 ms): usleep/827  ... [continued]: nanosleep() = 0
>  0.562 ( 0.000 ms): usleep/827 exit_group(                                                           )
> 
> 
> v1 can be found at:
>   https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1238358.html
>   (should be http://lkml.kernel.org/g/1474635001-153850-1-git-send-email-wangnan0@huawei.com
>    but the link is broken)
> 
> Wang Nan (18):
>   tools build: Support compiling C++ source file
>   perf tools: Add feature detection for g++
>   perf tools: Add feature detection for LLVM
>   perf tools: Add feature detection for clang
>   perf build: Add clang and llvm compile and linking support
>   perf clang: Add builtin clang support ant test case
>   perf clang: Use real file system for #include
>   perf clang: Allow passing CFLAGS to builtin clang
>   perf clang: Update test case to use real BPF script
>   perf clang: Support compile IR to BPF object and add testcase
>   perf tools: Extract helpers in llvm-utils.c
>   perf bpf: Compile BPF script use builtin clang support
>   perf clang: Pass full path to builtin clang
>   perf clang: Pass CFLAGS to builtin clang
>   perf clang: Link BPF functions declaration into perf
>   perf clang: Declare BPF functions for BPF scripts automatically
>   perf clang: Include helpers to BPF scripts
>   perf clang: Define PERF_BUILTIN_CLANG for builtin clang compiling
> 
>  tools/build/Build.include                     |   1 +
>  tools/build/Makefile.build                    |   7 +
>  tools/build/Makefile.feature                  |   2 +-
>  tools/build/feature/Makefile                  |  28 ++-
>  tools/build/feature/test-clang.cpp            |  21 ++
>  tools/build/feature/test-cxx.cpp              |  15 ++
>  tools/build/feature/test-llvm.cpp             |   8 +
>  tools/perf/Makefile.config                    |  62 ++++-
>  tools/perf/Makefile.perf                      |  23 +-
>  tools/perf/tests/Build                        |   1 +
>  tools/perf/tests/bpf-script-example.c         |  20 +-
>  tools/perf/tests/bpf-script-test-kbuild.c     |   2 +
>  tools/perf/tests/bpf-script-test-prologue.c   |   4 +
>  tools/perf/tests/bpf-script-test-relocation.c |  20 +-
>  tools/perf/tests/builtin-test.c               |   9 +
>  tools/perf/tests/clang.c                      |  46 ++++
>  tools/perf/tests/llvm-cxx.h                   |  13 +
>  tools/perf/tests/make                         |   2 +
>  tools/perf/tests/tests.h                      |   3 +
>  tools/perf/util/Build                         |   2 +
>  tools/perf/util/bpf-loader.c                  |  15 +-
>  tools/perf/util/c++/Build                     |   4 +
>  tools/perf/util/c++/bpf-funcs-str.c           | 214 +++++++++++++++++
>  tools/perf/util/c++/bpf-helper-str.c          |  13 +
>  tools/perf/util/c++/clang-bpf-includes.h      |  13 +
>  tools/perf/util/c++/clang-c.h                 |  43 ++++
>  tools/perf/util/c++/clang-test.cpp            |  62 +++++
>  tools/perf/util/c++/clang.cpp                 | 329 ++++++++++++++++++++++++++
>  tools/perf/util/c++/clang.h                   |  26 ++
>  tools/perf/util/llvm-utils-cxx.h              |  14 ++
>  tools/perf/util/llvm-utils.c                  |  70 +++++-
>  tools/perf/util/llvm-utils.h                  |   7 +-
>  tools/perf/util/util-cxx.h                    |  26 ++
>  33 files changed, 1078 insertions(+), 47 deletions(-)
>  create mode 100644 tools/build/feature/test-clang.cpp
>  create mode 100644 tools/build/feature/test-cxx.cpp
>  create mode 100644 tools/build/feature/test-llvm.cpp
>  create mode 100644 tools/perf/tests/clang.c
>  create mode 100644 tools/perf/tests/llvm-cxx.h
>  create mode 100644 tools/perf/util/c++/Build
>  create mode 100644 tools/perf/util/c++/bpf-funcs-str.c
>  create mode 100644 tools/perf/util/c++/bpf-helper-str.c
>  create mode 100644 tools/perf/util/c++/clang-bpf-includes.h
>  create mode 100644 tools/perf/util/c++/clang-c.h
>  create mode 100644 tools/perf/util/c++/clang-test.cpp
>  create mode 100644 tools/perf/util/c++/clang.cpp
>  create mode 100644 tools/perf/util/c++/clang.h
>  create mode 100644 tools/perf/util/llvm-utils-cxx.h
>  create mode 100644 tools/perf/util/util-cxx.h
> 
> Cc: Wang Nan <wangnan0@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Alexei Starovoitov <ast@fb.com>
> Cc: He Kuang <hekuang@huawei.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> -- 
> 1.8.3.4

  parent reply	other threads:[~2016-10-05 23:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26  7:26 [PATCH v2 00/18] perf clang: Support compiling BPF script on the fly Wang Nan
2016-09-26  7:26 ` [PATCH v2 01/18] tools build: Support compiling C++ source file Wang Nan
2016-10-06 22:44   ` [tip:perf/urgent] " tip-bot for Wang Nan
2016-09-26  7:26 ` [PATCH v2 02/18] perf tools: Add feature detection for g++ Wang Nan
2016-10-06 22:45   ` [tip:perf/urgent] tools build: " tip-bot for Wang Nan
2016-09-26  7:26 ` [PATCH v2 03/18] perf tools: Add feature detection for LLVM Wang Nan
2016-09-26  7:26 ` [PATCH v2 04/18] perf tools: Add feature detection for clang Wang Nan
2016-09-26  7:26 ` [PATCH v2 05/18] perf build: Add clang and llvm compile and linking support Wang Nan
2016-09-26  7:27 ` [PATCH v2 06/18] perf clang: Add builtin clang support ant test case Wang Nan
2016-09-26  7:27 ` [PATCH v2 07/18] perf clang: Use real file system for #include Wang Nan
2016-09-26  7:27 ` [PATCH v2 08/18] perf clang: Allow passing CFLAGS to builtin clang Wang Nan
2016-09-26  7:27 ` [PATCH v2 09/18] perf clang: Update test case to use real BPF script Wang Nan
2016-09-26  7:27 ` [PATCH v2 10/18] perf clang: Support compile IR to BPF object and add testcase Wang Nan
2016-09-26  7:27 ` [PATCH v2 11/18] perf tools: Extract helpers in llvm-utils.c Wang Nan
2016-09-26  7:27 ` [PATCH v2 12/18] perf bpf: Compile BPF script use builtin clang support Wang Nan
2016-09-26  7:27 ` [PATCH v2 13/18] perf clang: Pass full path to builtin clang Wang Nan
2016-09-26  7:27 ` [PATCH v2 14/18] perf clang: Pass CFLAGS " Wang Nan
2016-09-26  7:27 ` [PATCH v2 15/18] perf clang: Link BPF functions declaration into perf Wang Nan
2016-09-26  7:27 ` [PATCH v2 16/18] perf clang: Declare BPF functions for BPF scripts automatically Wang Nan
2016-09-26  7:27 ` [PATCH v2 17/18] perf clang: Include helpers to BPF scripts Wang Nan
2016-09-26  7:27 ` [PATCH v2 18/18] perf clang: Define PERF_BUILTIN_CLANG for builtin clang compiling Wang Nan
2016-10-05 23:20 ` Arnaldo Carvalho de Melo [this message]
2016-10-08  2:03   ` [PATCH v2 00/18] perf clang: Support compiling BPF script on the fly Wangnan (F)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161005232057.GL30363@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ast@fb.com \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.