From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin KaFai Lau Subject: Re: [PATCH bpf-next v5 00/10] BTF: BPF Type Format Date: Wed, 13 Jun 2018 16:26:38 -0700 Message-ID: <20180613232638.yyhktiovl6oeawgt@kafai-mbp> References: <20180607190510.qtj7gq4wbfewcn4g@kafai-mbp> <20180607193029.GG17292@kernel.org> <20180607200701.bvsjzoq56rnggwfd@kafai-mbp> <20180612203124.GB22039@kernel.org> <20180612204126.GC22039@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: , Alexei Starovoitov , Daniel Borkmann , , Wang Nan , Jiri Olsa , Namhyung Kim , Ingo Molnar To: Arnaldo Carvalho de Melo Return-path: Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:39774 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935710AbeFMX13 (ORCPT ); Wed, 13 Jun 2018 19:27:29 -0400 Content-Disposition: inline In-Reply-To: <20180612204126.GC22039@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: 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 escrev= eu: > > 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 wr= ote: > > > > So this must be available in a newer llvm version? Which one? > >=20 > > > I should have put in the details in my last email or > > > in the commit message, my bad. > > =20 > > > 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=3Ddwarf" llc option which was added to the future > > > llvm 7.0. >=20 > > [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 */ > >=20 > > /* size: 16, cachelines: 1, members: 4 */ > > /* last cacheline: 16 bytes */ > > }; > > [root@jouet bpf]#=20 > >=20 > > 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=3D= dwarf" > > part. >=20 > [root@jouet bpf]# pahole hello.o > struct clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3D= http-3A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di= 6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su= 4Qq2wiLOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873d= accce7ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/u= rl?u=3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw= &r=3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75g= M-V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D = 98c78e82f54be8fb0bb5f02e3ca674fbde10ef34) { > clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-3= A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobKx= beG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2wi= LOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce7= ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78 clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-= 3A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobK= xbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2w= iLOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce= 7ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78e82f54be8fb0bb5f02e3ca674fbde10ef34); /* 0 4 */ > clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-3= A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobKx= beG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2wi= LOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce7= ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78 clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-= 3A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobK= xbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2w= iLOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce= 7ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78e82f54be8fb0bb5f02e3ca674fbde10ef34); /* 4 4 */ > clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-3= A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobKx= beG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2wi= LOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce7= ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78 clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-= 3A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobK= xbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2w= iLOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce= 7ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78e82f54be8fb0bb5f02e3ca674fbde10ef34); /* 8 4 */ > clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-3= A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobKx= beG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2wi= LOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce7= ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78 clang version 7.0.0 (https://urldefense.proofpoint.com/v2/url?u=3Dhttp-= 3A__llvm.org_git_clang.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r=3Di6WobK= xbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-V2su4Qq2w= iLOGkU-adI&s=3D_Qzsu689xEjjl9JvYCvJsIZLZZKDLB6rM-Uc0gqQvyg&e=3D 8c873daccce= 7ee5339b9fd82c81fe02b73543b65) (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__llvm.org_git_llvm.git&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3MUw&r= =3Di6WobKxbeG3slzHSIOxTVtYIJw7qjCE6S0spDTKL-J4&m=3D4d495SlcvobgBOFahId75gM-= V2su4Qq2wiLOGkU-adI&s=3DcFz6VP_YIYy_hubsx05WDqpTDyXl0Wnx_RAmAl1dbpg&e=3D 98= c78e82f54be8fb0bb5f02e3ca674fbde10ef34); /* 12 4 */ >=20 > /* size: 16, cachelines: 1, members: 4 */ > /* last cacheline: 16 bytes */ > }; That means the "-mattr=3Ddwarf" is not effective. Can you share your clang and llc command to create hello.o? > [root@jouet bpf]# >=20 > Ideas? >=20 > [root@jouet bpf]# trace -e open*,hello.c > clang-6.0: error: unknown argument: '-mattr=3Ddwarf' > 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 >=20 > (add -v to see detail) > Run 'perf list' for a list of valid events >=20 > Usage: perf trace [] [] > or: perf trace [] -- [] > or: perf trace record [] [] > or: perf trace record [] -- [] >=20 > -e, --event event/syscall selector. use 'perf list' to list= available events > [root@jouet bpf]# >=20 > [root@jouet bpf]# trace -v -e open*,hello.c > bpf: builtin compilation failed: -95, try external compiler > Kernel build dir is set to /lib/modules/4.17.0-rc5/build > set env: KBUILD_DIR=3D/lib/modules/4.17.0-rc5/build > unset env: KBUILD_OPTS > include option is set to -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-l= inux/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/lin= ux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/g= it/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/li= nux/include/linux/kconfig.h=20 > set env: NR_CPUS=3D4 > set env: LINUX_VERSION_CODE=3D0x41100 > set env: CLANG_EXEC=3D/usr/local/bin/clang > set env: CLANG_OPTIONS=3D-g -mattr=3Ddwarf > set env: KERNEL_INC_OPTIONS=3D -nostdinc -isystem /usr/lib/gcc/x86_64-red= hat-linux/7/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/in= clude/generated -I/home/acme/git/linux/include -I./include -I/home/acme/gi= t/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/a= cme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/g= it/linux/include/linux/kconfig.h=20 > set env: PERF_BPF_INC_OPTIONS=3D-I/home/acme/lib/include/perf/bpf > set env: WORKING_DIR=3D/lib/modules/4.17.0-rc5/build > set env: CLANG_SOURCE=3D/home/acme/bpf/hello.c > llvm compiling command template: $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__= =3D$NR_CPUS -DLINUX_VERSION_CODE=3D$LINUX_VERSION_CODE $CLANG_OPTIONS $KERN= EL_INC_OPTIONS $PERF_BPF_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -w= orking-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o - > llvm compiling command : /usr/local/bin/clang -D__KERNEL__ -D__NR_CPUS__= =3D4 -DLINUX_VERSION_CODE=3D0x41100 -g -mattr=3Ddwarf -nostdinc -isystem /= usr/lib/gcc/x86_64-redhat-linux/7/include -I/home/acme/git/linux/arch/x86/i= nclude -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./i= nclude -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/ge= nerated/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/in= clude/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=3Ddwarf' > 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 >=20