From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932400AbdK0REm (ORCPT ); Mon, 27 Nov 2017 12:04:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:33794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932256AbdK0REj (ORCPT ); Mon, 27 Nov 2017 12:04:39 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 426A421943 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org Date: Mon, 27 Nov 2017 14:04:35 -0300 From: Arnaldo Carvalho de Melo To: Daniel Borkmann Cc: Josh Poimboeuf , Wang Nan , Alexei Starovoitov , Adrian Hunter , David Ahern , Jiri Olsa , Ingo Molnar , Namhyung Kim , Linux Kernel Mailing List , yhs@fb.com Subject: Re: perf test LLVM & clang 6 failing Message-ID: <20171127170435.GA3298@kernel.org> References: <20171124144717.GO8789@kernel.org> <7cd16670-37c9-21f5-21c8-d50385ebc951@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7cd16670-37c9-21f5-21c8-d50385ebc951@iogearbox.net> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Nov 24, 2017 at 04:16:52PM +0100, Daniel Borkmann escreveu: > [ +Yonghong ] + Josh > On 11/24/2017 03:47 PM, Arnaldo Carvalho de Melo wrote: > > FYI, just noticed, recently updated clang to version 6, from its > > upstream git repo. > > Do you recall what was your LLVM version prior to this where it was > working fine? (Wild guess from below would be the BPF inline asm > support that was added recently to LLVM (2865ab6996) vs asm() used > in headers included in the stdin header causing trouble due to arch > mixup?) So, if I go to the cset just before: commit f5caf621ee357279e759c0911daf6d55c7d36f03 Author: Josh Poimboeuf Date: Wed Sep 20 16:24:33 2017 -0500 x86/asm: Fix inline asm call constraints for Clang --- 'perf test LLVM' works again: [root@jouet ~]# perf test LLVM 37: LLVM search and compile : 37.1: Basic BPF llvm compile : Ok 37.2: kbuild searching : Ok 37.3: Compile source for BPF prologue generation : Ok 37.4: Compile source for BPF relocation : Ok [root@jouet ~]# I.e. 'perf test LLVM' built from what is in my acme/perf/urgent branch, targetted to v4.15, uses kernel headers and if I go to just before f5caf621ee, it works again, both with clang from fedora26 (4.0.1) and with 6.0, built from sources. 'perf test BPF' breaks for another reason, needs another investigation, maybe you guys can spot something changed recently in that area: libbpf: failed to create map (name: 'flip_table'): Invalid argument libbpf: failed to load object '[basic_bpf_test]' Complete logs up to this error are below, I'll go read Yonghong message to see if I can get the 'perf test LLVM' case fixed. - Arnaldo [root@jouet ~]# perf test BPF 39: BPF filter : 39.1: Basic BPF filtering : FAILED! 39.2: BPF pinning : Skip 39.3: BPF prologue generation : Skip 39.4: BPF relocation checker : Skip [root@jouet ~]# perf test -v BPF 39: BPF filter : 39.1: Basic BPF filtering : --- start --- test child forked, pid 3541 Kernel build dir is set to /lib/modules/4.14.0+/build set env: KBUILD_DIR=/lib/modules/4.14.0+/build unset env: KBUILD_OPTS include option is set to -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/7/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./include -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h set env: NR_CPUS=4 set env: LINUX_VERSION_CODE=0x40e00 set env: CLANG_EXEC=/usr/lib64/ccache/clang set env: CLANG_OPTIONS=-xc set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/7/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./include -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h set env: WORKING_DIR=/lib/modules/4.14.0+/build set env: CLANG_SOURCE=- llvm compiling command template: echo '/* * bpf-script-example.c * Test basic LLVM building */ #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_wait") int bpf_func__SyS_epoll_wait(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; ' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o - libbpf: loading object '[basic_bpf_test]' from buffer libbpf: section .strtab, size 120, link 0, flags 0, type=3 libbpf: section .text, size 0, link 0, flags 6, type=1 libbpf: section func=SyS_epoll_wait, size 200, link 0, flags 6, type=1 libbpf: found program func=SyS_epoll_wait libbpf: section .relfunc=SyS_epoll_wait, size 32, link 8, flags 0, type=9 libbpf: section maps, size 16, link 0, flags 3, type=1 libbpf: section license, size 4, link 0, flags 3, type=1 libbpf: license of [basic_bpf_test] is GPL libbpf: section version, size 4, link 0, flags 3, type=1 libbpf: kernel version of [basic_bpf_test] is 40e00 libbpf: section .symtab, size 168, link 1, flags 0, type=2 libbpf: maps in [basic_bpf_test]: 1 maps in 16 bytes libbpf: map 0 is "flip_table" libbpf: collecting relocating info for: 'func=SyS_epoll_wait' libbpf: relocation: insn_idx=4 libbpf: relocation: find map 0 (flip_table) for insn 4 libbpf: relocation: insn_idx=18 libbpf: relocation: find map 0 (flip_table) for insn 18 bpf: config program 'func=SyS_epoll_wait' symbol:SyS_epoll_wait file:(null) line:0 offset:0 return:0 lazy:(null) bpf: config 'func=SyS_epoll_wait' is ok Looking at the vmlinux_path (8 entries long) Using /lib/modules/4.14.0+/build/vmlinux for symbols Open Debuginfo file: /lib/modules/4.14.0+/build/vmlinux Try to find probe point from debuginfo. Matched function: SyS_epoll_wait [2e5a9be] found inline addr: 0xffffffff812af256 Probe point found: compat_SyS_epoll_pwait+150 found inline addr: 0xffffffff812af037 Probe point found: SyS_epoll_pwait+135 found inline addr: 0xffffffff812aeed0 Probe point found: SyS_epoll_wait+0 Found 3 probe_trace_events. Opening /sys/kernel/debug/tracing//kprobe_events write=1 Writing event: p:perf_bpf_probe/func _text+2814550 Writing event: p:perf_bpf_probe/func_1 _text+2814007 Writing event: p:perf_bpf_probe/func_2 _text+2813648 libbpf: failed to create map (name: 'flip_table'): Invalid argument libbpf: failed to load object '[basic_bpf_test]' bpf: load objects failed Failed to add events selected by BPF