Re: [PATCH v7] pgo: add clang's Profile Guided Optimization infrastructure
From: Nick Desaulniers <hidden>
Date: 2021-01-28 21:26:13
Also in:
linux-doc, lkml
On Thu, Jan 28, 2021 at 1:19 PM Sedat Dilek [off-list ref] wrote:
On Thu, Jan 28, 2021 at 10:12 PM Nick Desaulniers [off-list ref] wrote:quoted
On Thu, Jan 28, 2021 at 12:46 PM Sedat Dilek [off-list ref] wrote:quoted
[ LLVM ] Today, I switched over to LLVM version 12.0.0-rc1. [ Step #1: 5.11.0-rc5-5-amd64-clang12-pgo ] My first kernel was built with CONFIG_PGO_CLANG=y and LLVM=1 plus LLVM_IAS=1. [ start-build_5.11.0-rc5-5-amd64-clang12-pgo.txt ] dileks 193090 193065 0 06:54 pts/2 00:00:00 /usr/bin/perf_5.10 stat make V=1 -j4 HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld LLVM=1 LLVM_IAS=1 PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-5-amd64-clang12-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza KBUILD_BUILD_USER=sedat.dilek@gmail.com KBUILD_BUILD_TIMESTAMP=2021-01-28 bindeb-pkg KDEB_PKGVERSION=5.11.0~rc5-5~bullseye+dileks1 Config: config-5.11.0-rc5-5-amd64-clang12-pgo [ Step #2: x86-64 defconfig & vmlinux.profdata ] Booted into 5.11.0-rc5-5-amd64-clang12-pgo and built an x86-64 defconfig to generate/merge a vmlinux.profdata file. [ start-build_x86-64-defconfig.txt ] dileks 18430 15640 0 11:15 pts/2 00:00:00 make V=1 -j4 HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld LLVM=1 LLVM_IAS=1 Script: profile_clang-pgo.sh Config: dot-config.x86-64-defconfig [ Step #3.1: 5.11.0-rc5-6-amd64-clang12-pgo & GNU-AS ] The first rebuild with CONFIG_PGO_CLANG=n and "LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata". I was able to boot into this one. Used assembler: GNU-AS 2.35.1 [ start-build_5.11.0-rc5-6-amd64-clang12-pgo.txt ] dileks 65734 65709 0 11:54 pts/2 00:00:00 /usr/bin/perf_5.10 stat make V=1 -j4 HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-6-amd64-clang12-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza KBUILD_BUILD_USER=sedat.dilek@gmail.com KBUILD_BUILD_TIMESTAMP=2021-01-28 bindeb-pkg KDEB_PKGVERSION=5.11.0~rc5-6~bullseye+dileks1 LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata Config: config-5.11.0-rc5-6-amd64-clang12-pgo [ Step #3.2: 5.11.0-rc5-7-amd64-clang12-pgo & Clang-IAS ] The second rebuild with CONFIG_PGO_CLANG=n and "LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata" plus LLVM_IAS=1. Compilable but NOT bootable in QEMU and on bare metal. Used assembler: Clang-IAS v12.0.0-rc1 [ start-build_5.11.0-rc5-7-amd64-clang12-pgo.txt ] dileks 6545 6520 0 16:31 pts/2 00:00:00 /usr/bin/perf_5.10 stat make V=1 -j4 HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-7-amd64-clang12-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza KBUILD_BUILD_USER=sedat.dilek@gmail.com KBUILD_BUILD_TIMESTAMP=2021-01-28 bindeb-pkg KDEB_PKGVERSION=5.11.0~rc5-7~bullseye+dileks1 LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata LLVM_IAS=1 Config: config-5.11.0-rc5-7-amd64-clang12-pgo [ Conclusion ] The only statement I can tell you is a "PGO optimized" rebuild with LLVM_IAS=1 is compilable but NOT bootable.Thanks for the extensive testing and report. Can you compress, upload, and post a link to your kernel image? I would like to take it for a spin in QEMU and see if I can find what it's doing, then work backwards from there.Which files do you need? For QEMU: bzImage and initrd.img enough?
bzImage should be enough; I'll use my own initrd. If that boots for me, maybe then I'll take a look with the initrd added. -- Thanks, ~Nick Desaulniers