BPF List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Yonghong Song <yonghong.song@linux.dev>
Cc: Alan Maguire <alan.maguire@oracle.com>,
	 Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	dwarves@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	 Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs
Date: Thu, 12 Nov 2026 02:53:08 -0800	[thread overview]
Message-ID: <avWaZSCBSZ7wcm5y@gmail.com> (raw)
In-Reply-To: <20261111222447.322978-1-yonghong.song@linux.dev>

On Wed, Nov 11, 2026 at 02:24:47PM -0800, Yonghong Song wrote:
> The location based checks can drop kfuncs from BTF even though their ABI
> did not change. With the arm64 KCSAN setup in the report, resolve_btfids
> fails with:
> 
>   WARN: resolve_btfids: no BTF func for kfunc bpf_tcp_ops_set_rcvlowat in bpf_tcp_ops_set_rcvlowat_kfunc_set
>   WARN: resolve_btfids: unresolved symbol bpf_tcp_ops_set_rcvlowat
> 
> The location list of 'rcvlowat' starts after the function entry, in a
> callee-saved register, so the function is marked unexpected_reg and
> skipped. scx_bpf_tid_to_task() hits the same skip through a
> different DWARF pattern.
> 
> Kfuncs are defined with __bpf_kfunc ("__used __retain __noclone
> noinline"), so the compiler keeps the calling convention of the C
> prototype. Odd parameter locations of a kfunc are debug info artifacts,
> not ABI changes.
> 
> For kfuncs, clear the location derived flags when saving the state,
> keep all source parameters, and skip the location based checks, also in
> btf_encoder__add_saved_funcs() where saved_functions_combine() can merge
> the flags back in. The inconsistent prototype and ambiguous address
> checks still apply.
> 
> Kfuncs were only collected with decl_tag_kfuncs, which the kernel no
> longer passes since commit 692393104909 ("resolve_btfids: Emit bpf_kfunc
> and bpf_fastcall decl tags"). Collect them whenever BTF is encoded; the
> decl tags are still only emitted with decl_tag_kfuncs.
> 
> With this change, bpf_tcp_ops_set_rcvlowat() and scx_bpf_tid_to_task()
> are encoded again, and no other function in vmlinux BTF changes.
> 
> Reported-by: Breno Leitao <leitao@debian.org>
> Closes: https://lore.kernel.org/all/au27Y9m78_3EH2v1@gmail.com/
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>

Thanks, this fixes my build. I tested it on top of pahole master
(9eb594d) with next-20261111 and clang 22.1.3:

 - arm64 KCSAN, CONFIG_WERROR=y: vmlinux links again,
   bpf_tcp_ops_set_rcvlowat() and scx_bpf_tid_to_task() are back in BTF,
   __bpf_tcp_ops_init() and scx_init() return 0 instead of -22, and the
   prog_tests/tcp_autolowat.c cases pass (run standalone).

 - x86_64 KCSAN drops bpf_tcp_ops_set_rcvlowat() in the same way, and
   this fixes it there too.

 - Running pahole with and without this patch on the same vmlinux, the
   only BTF difference on both architectures is the kfuncs coming back.

Tested-by: Breno Leitao <leitao@debian.org>

--breno

  reply	other threads:[~2026-11-12 10:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 22:24 [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs Yonghong Song
2026-11-12 10:53 ` Breno Leitao [this message]
2026-11-12 12:36 ` Alan Maguire
2026-11-12 13:54   ` Breno Leitao
2026-11-12 15:26   ` Yonghong Song

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=avWaZSCBSZ7wcm5y@gmail.com \
    --to=leitao@debian.org \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --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