From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnaldo Carvalho de Melo Subject: Re: [PATCH bpf-next v5 00/10] BTF: BPF Type Format Date: Thu, 14 Jun 2018 12:03:34 -0300 Message-ID: <20180614150334.GF30043@kernel.org> References: <20180607190510.qtj7gq4wbfewcn4g@kafai-mbp> <20180607193029.GG17292@kernel.org> <20180607200701.bvsjzoq56rnggwfd@kafai-mbp> <20180612203124.GB22039@kernel.org> <20180612204126.GC22039@kernel.org> <20180613232638.yyhktiovl6oeawgt@kafai-mbp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , kernel-team@fb.com, Wang Nan , Jiri Olsa , Namhyung Kim , Ingo Molnar To: Martin KaFai Lau Return-path: Received: from mail.kernel.org ([198.145.29.99]:43296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754967AbeFNPDi (ORCPT ); Thu, 14 Jun 2018 11:03:38 -0400 Content-Disposition: inline In-Reply-To: <20180613232638.yyhktiovl6oeawgt@kafai-mbp> Sender: netdev-owner@vger.kernel.org List-ID: Em Wed, Jun 13, 2018 at 04:26:38PM -0700, Martin KaFai Lau escreveu: > On Tue, Jun 12, 2018 at 05:41:26PM -0300, Arnaldo Carvalho de Melo wrote: > > Em Tue, Jun 12, 2018 at 05:31:24PM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Thu, Jun 07, 2018 at 01:07:01PM -0700, Martin KaFai Lau escreveu: > > > > On Thu, Jun 07, 2018 at 04:30:29PM -0300, Arnaldo Carvalho de Melo wrote: > > > > > So this must be available in a newer llvm version? Which one? > > > > I should have put in the details in my last email or > > > > in the commit message, my bad. > > > > 1. The tools/testing/selftests/bpf/Makefile has the CLANG_FLAGS and > > > > LLC_FLAGS needed to compile the bpf prog. It requires a new > > > > "-mattr=dwarf" llc option which was added to the future > > > > llvm 7.0. > > > [root@jouet bpf]# pahole hello.o > > > struct clang version 5.0.1 (tags/RELEASE_501/final) { > > > clang version 5.0.1 (tags/RELEASE_501/final) clang version 5.0.1 (tags/RELEASE_501/final); /* 0 4 */ > > > clang version 5.0.1 (tags/RELEASE_501/final) clang version 5.0.1 (tags/RELEASE_501/final); /* 4 4 */ > > > clang version 5.0.1 (tags/RELEASE_501/final) clang version 5.0.1 (tags/RELEASE_501/final); /* 8 4 */ > > > clang version 5.0.1 (tags/RELEASE_501/final) clang version 5.0.1 (tags/RELEASE_501/final); /* 12 4 */ > > > /* size: 16, cachelines: 1, members: 4 */ > > > /* last cacheline: 16 bytes */ > > > }; > > > [root@jouet bpf]# > > > > > > Ok, I guess I saw this case in the llvm/clang git logs, so this one was > > > generated with the older clang, will regenerate and add that "-mattr=dwarf" > > > part. > > [root@jouet bpf]# pahole hello.o > > struct clang version 7.0.0 > > /* size: 16, cachelines: 1, members: 4 */ > > /* last cacheline: 16 bytes */ > > }; > That means the "-mattr=dwarf" is not effective. > Can you share your clang and llc command to create hello.o? I tried it, but it didn't work, see: [root@jouet bpf]# cat hello.c #include "stdio.h" int syscall_enter(openat)(void *ctx) { puts("Hello, world\n"); return 0; } [root@jouet bpf]# trace -e openat,hello.c touch /tmp/kafai clang-6.0: error: unknown argument: '-mattr=dwarf' ERROR: unable to compile hello.c Hint: Check error message shown above. Hint: You can also pre-compile it into .o using: clang -target bpf -O2 -c hello.c with proper -I and -D options. event syntax error: 'hello.c' \___ Failed to load hello.c from source: Error when compiling BPF scriptlet (add -v to see detail) Run 'perf list' for a list of valid events Usage: perf trace [] [] or: perf trace [] -- [] or: perf trace record [] [] or: perf trace record [] -- [] -e, --event event/syscall selector. use 'perf list' to list available events [root@jouet bpf]# The full command line with that is: [root@jouet bpf]# trace -v -e openat,hello.c touch /tmp/kafai |& grep mattr set env: CLANG_OPTIONS=-g -mattr=dwarf llvm compiling command : /usr/local/bin/clang -D__KERNEL__ -D__NR_CPUS__=4 -DLINUX_VERSION_CODE=0x41100 -g -mattr=dwarf -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 -I/home/acme/lib/include/perf/bpf -Wno-unused-value -Wno-pointer-sign -working-directory /lib/modules/4.17.0-rc5/build -c /home/acme/bpf/hello.c -target bpf -O2 -o - clang-6.0: error: unknown argument: '-mattr=dwarf' [root@jouet bpf]# This is with these llvm and clang trees: [root@jouet llvm]# git log --oneline -5 98c78e82f54 (HEAD -> master, origin/master, origin/HEAD) [asan] Instrument comdat globals on COFF targets 6ad988b5998 [DAGCombiner] clean up comments; NFC a735ba5b795 [X86][SSE] Support v8i16/v16i16 rotations 1503b9f6fe8 [x86] add tests for node-level FMF; NFC 4a49826736f [x86] regenerate test checks; NFC [root@jouet llvm]# [root@jouet llvm]# cd tools/clang/ [root@jouet clang]# git log --oneline -5 8c873daccc (HEAD -> master, origin/master, origin/HEAD) [X86] Add builtins for vpermq/vpermpd instructions to enable target feature checking. a344be6ba4 [X86] Change immediate type for some builtins from char to int. dcdd53793e [CUDA] Fix emission of constant strings in sections a90c85acaf [X86] Add builtins for shufps and shufpd to enable target feature and immediate range checking. ff71c0eccc [X86] Add builtins for pshufd, pshuflw, and pshufhw to enable target feature and immediate range checking. [root@jouet clang]# [root@jouet clang]# git log | grep mattr=dwarf [root@jouet clang]# cd - /home/acme/git.tmp/git/llvm [root@jouet llvm]# git log | grep mattr=dwarf bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections This patch introduces a new flag -mattr=dwarfris [root@jouet llvm]# Humm, so its -mattr=dwarfris and not -attr=dwarf? Didn't help :-\ commit 0e0047f8c9ada2f0fe0c5f01579a80e2455b8df5 Author: Yonghong Song Date: Thu Mar 1 23:04:59 2018 +0000 bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections Commit e4507fb8c94b ("bpf: disable DwarfUsesRelocationsAcrossSections") disables MCAsmInfo DwarfUsesRelocationsAcrossSections unconditionally so that dwarf will not use cross section (between dwarf and symbol table) relocations. This new debug format enables pahole to dump structures correctly as libdwarves.so does not have BPF backend support yet. This new debug format, however, breaks bcc (https://github.com/iovisor/bcc) source debug output as llvm in-memory Dwarf support has some issues to handle it. More specifically, with DwarfUsesRelocationsAcrossSections disabled, JIT compiler does not generate .debug_abbrev and Dwarf DIE (debug info entry) processing is not happy about this. This patch introduces a new flag -mattr=dwarfris (dwarf relocation in section) to disable DwarfUsesRelocationsAcrossSections. DwarfUsesRelocationsAcrossSections is true by default. Signed-off-by: Yonghong Song git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326505 91177308-0d34-0410-b5e6-96231b3b80d8