From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755675AbbHGCA7 (ORCPT ); Thu, 6 Aug 2015 22:00:59 -0400 Received: from mail.kernel.org ([198.145.29.136]:48971 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754536AbbHGCAz (ORCPT ); Thu, 6 Aug 2015 22:00:55 -0400 Date: Thu, 6 Aug 2015 11:46:52 -0300 From: Arnaldo Carvalho de Melo To: "Wangnan (F)" Cc: pi3orama , 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: <20150806144652.GA6989@kernel.org> References: <20150803150728.GA3864@kernel.org> <20150803151905.GE3864@kernel.org> <20150803161116.GB5498@kernel.org> <20150803194917.GE5498@kernel.org> <55C04D60.2050101@huawei.com> <55C0966B.5020801@huawei.com> <20150804155557.GB3126@kernel.org> <20150804161123.GC3126@kernel.org> <55C2BC01.3010000@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55C2BC01.3010000@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 Thu, Aug 06, 2015 at 09:44:33AM +0800, Wangnan (F) escreveu: > Hi Arnaldo, > > Have you tried 'perf test BPF'? Is that okay on your environment? Freshly checked out from your github repo, 'ebpf' branch, looks good, see output below, back to reading patches... 37: Test thread map : Ok 38: Test LLVM searching and compiling : Ok 39: Test BPF filter : Ok [root@felicio ~]# set -o vi [root@felicio ~]# perf test -v BPF 39: Test BPF filter : --- start --- test child forked, pid 9746 Kernel build dir is set to /lib/modules/4.2.0-rc3+/build set env: KBUILD_DIR=/lib/modules/4.2.0-rc3+/build unset env: KBUILD_OPTS include option is set to -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 set env: CLANG_EXEC=/usr/local/bin/clang set env: CLANG_OPTIONS=-xc set env: 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 set env: WORKING_DIR=/lib/modules/4.2.0-rc3+/build set env: CLANG_SOURCE=- llvm compiling command template: cat << '__EOF__' | $CLANG_EXEC -D__KERNEL__ $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o - #define LINUX_VERSION_CODE 0x00040200; #ifndef LINUX_VERSION_CODE # error Need LINUX_VERSION_CODE # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig' #endif #define BPF_ANY 0 #define BPF_MAP_TYPE_ARRAY 2 #define BPF_FUNC_map_lookup_elem 1 #define BPF_FUNC_map_update_elem 2 static void *(*bpf_map_lookup_elem)(void *map, void *key) = (void *) BPF_FUNC_map_lookup_elem; static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) = (void *) BPF_FUNC_map_update_elem; struct bpf_map_def { unsigned int type; unsigned int key_size; unsigned int value_size; unsigned int max_entries; }; #define SEC(NAME) __attribute__((section(NAME), used)) struct bpf_map_def SEC("maps") flip_table = { .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(int), .value_size = sizeof(int), .max_entries = 1, }; SEC("func=sys_epoll_pwait") int bpf_func__sys_epoll_pwait(void *ctx) { int ind =0; int *flag = bpf_map_lookup_elem(&flip_table, &ind); int new_flag; if (!flag) return 0; /* flip flag and store back */ new_flag = !*flag; bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY); return new_flag; } char _license[] SEC("license") = "GPL"; int _version SEC("version") = LINUX_VERSION_CODE; __EOF__ [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.018 MB /tmp/perf-bpf-test-7EbF3J/perf.data (56 samples) ] test child finished with 0 ---- end ---- Test BPF filter: Ok [root@felicio ~]#