public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Ihor Solodrai <ihor.solodrai@linux.dev>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH bpf-next] scripts/gen-btf.sh: Disable LTO when generating initial .o file
Date: Tue, 6 Jan 2026 14:53:27 -0700	[thread overview]
Message-ID: <20260106215327.GA1957425@ax162> (raw)
In-Reply-To: <6908562f-4a99-44ea-bffb-19f33fcffe83@linux.dev>

On Mon, Jan 05, 2026 at 05:06:49PM -0800, Ihor Solodrai wrote:
> I got curious and did a little experiment. Basically, I ran perf stat
> on this part of gen-btf.sh:
> 
> 	echo "" | ${CC} ${CLANG_FLAGS} ${KBUILD_CFLAGS} -c -x c -o ${btf_data} -
> 	${OBJCOPY} --add-section .BTF=${ELF_FILE}.BTF \
> 		--set-section-flags .BTF=alloc,readonly ${btf_data}
> 	${OBJCOPY} --only-section=.BTF --strip-all ${btf_data}
> 
> Replacing ${CC} command with:
> 
> 	${OBJCOPY} --strip-all "${ELF_FILE}" ${btf_data} 2>/dev/null
> 
> for comparison.
> 
> TL;DR is that using ${CC} is:
>   * about 1.5x faster than GNU objcopy --strip-all .tmp_vmlinux1
>   * about 16x (!) faster than llvm-objcopy --strip-all .tmp_vmlinux1
> 
> With obvious caveats that this is a particular machine (Threadripper
> PRO 3975WX), toolchain etc:
>   * clang version 21.1.7
>   * gcc (GCC) 15.2.1 20251211
> 
> This is bpf-next (a069190b590e) with BPF CI-like kconfig.

Oof, that difference between GNU and LLVM's objcopy implementations...
At the same time, it was only a little over a second for llvm-objcopy.
Maybe that gets worse if more is built into the kernel to the point
where it is untenable but maybe it is worth the reduced complexity? That
said, my patch is pretty simple (and a follow up for KBUILD_CPPFLAGS if
needed would be equally simple), your testing demonstrates that there
is some performance improvement, and I cannot imagine there being any
other bugs of this nature in this area going forward. I have no real
strong opinion, I just need my builds to finish :)

Cheers,
Nathan

  reply	other threads:[~2026-01-06 21:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 21:12 [PATCH bpf-next] scripts/gen-btf.sh: Disable LTO when generating initial .o file Nathan Chancellor
2026-01-05 22:01 ` Ihor Solodrai
2026-01-05 23:46   ` Nathan Chancellor
2026-01-06  1:06     ` Ihor Solodrai
2026-01-06 21:53       ` Nathan Chancellor [this message]
2026-01-06 22:01         ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260106215327.GA1957425@ax162 \
    --to=nathan@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=martin.lau@linux.dev \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox