* [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs
@ 2026-11-11 22:24 Yonghong Song
2026-11-12 10:53 ` Breno Leitao
2026-11-12 12:36 ` Alan Maguire
0 siblings, 2 replies; 5+ messages in thread
From: Yonghong Song @ 2026-11-11 22:24 UTC (permalink / raw)
To: Alan Maguire, Arnaldo Carvalho de Melo, dwarves
Cc: Alexei Starovoitov, Andrii Nakryiko, bpf, kernel-team,
Breno Leitao
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>
---
btf_encoder.c | 49 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 35 insertions(+), 14 deletions(-)
diff --git a/btf_encoder.c b/btf_encoder.c
index 05ffe82..4269467 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -1421,16 +1421,30 @@ static int32_t btf_encoder__save_func(struct btf_encoder *encoder, struct functi
}
}
}
+
+ /*
+ * A kfunc keeps the ABI of its C prototype, so reset the DWARF
+ * location based flags: otherwise the kfunc may be treated as
+ * optimized and skipped, or lose parameters in BTF.
+ */
+ if (!loc && is_kfunc_state(state)) {
+ state->unexpected_reg = 0;
+ state->optimized_parms = 0;
+ state->uncertain_parm_loc = 0;
+ state->reordered_parm = 0;
+ state->signature_changed = 0;
+ }
+
ftype__for_each_parameter(ftype, param) {
const char *name;
char *final_name = NULL;
/* No location info/optimized + reordered means optimized out. */
- if (!loc && ftype->reordered_parm && (!param->has_loc || param->optimized)) {
+ if (!loc && state->reordered_parm && (!param->has_loc || param->optimized)) {
state->nr_parms--;
continue;
}
- if (!loc && encoder->true_signature && ftype->signature_changed &&
+ if (!loc && encoder->true_signature && state->signature_changed &&
param->optimized) {
state->nr_parms--;
continue;
@@ -1797,17 +1811,20 @@ static int btf_encoder__add_saved_funcs(struct btf_encoder *encoder, bool skip_e
* signature; true_signature can rewrite those signatures.
* Also exclude functions with unexpected register use, multiple
* inconsistent prototypes or uncertain parameter locations.
+ * The location based checks do not apply to kfuncs.
*/
- if (state->unexpected_reg)
- skip_reason = "unexpected register usage for parameter\n";
+ if (!is_kfunc_state(state)) {
+ if (state->unexpected_reg)
+ skip_reason = "unexpected register usage for parameter\n";
+ if (state->uncertain_parm_loc)
+ skip_reason = "uncertain parameter location\n";
+ if (state->reordered_parm)
+ skip_reason = "reordered parameters\n";
+ if (btf_encoder_func_state__skip_optimized_parms(encoder, canonical_state))
+ skip_reason = "optimized parameters\n";
+ }
if (skip_encoding_inconsistent_proto && state->inconsistent_proto)
skip_reason = "inconsistet prototype\n";
- if (state->uncertain_parm_loc)
- skip_reason = "uncertain parameter location\n";
- if (state->reordered_parm)
- skip_reason = "reordered parameters\n";
- if (btf_encoder_func_state__skip_optimized_parms(encoder, canonical_state))
- skip_reason = "optimized parameters\n";
if (state->elf->ambiguous_addr)
skip_reason = "ambiguous address\n";
@@ -3056,10 +3073,14 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
if (!found_percpu && encoder->verbose)
printf("%s: '%s' doesn't have '%s' section\n", __func__, cu->filename, PERCPU_SECTION);
- if (encoder->tag_kfuncs) {
- if (btf_encoder__collect_kfuncs(encoder))
- goto out_delete;
- }
+ /*
+ * Mark kfuncs before any function state is saved, so
+ * btf_encoder__save_func() keeps their source prototypes.
+ * Needed even without decl_tag_kfuncs, which only controls
+ * the decl tags.
+ */
+ if (btf_encoder__collect_kfuncs(encoder))
+ goto out_delete;
if (encoder->verbose)
printf("File %s:\n", cu->filename);
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs
2026-11-11 22:24 [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs Yonghong Song
@ 2026-11-12 10:53 ` Breno Leitao
2026-11-12 12:36 ` Alan Maguire
1 sibling, 0 replies; 5+ messages in thread
From: Breno Leitao @ 2026-11-12 10:53 UTC (permalink / raw)
To: Yonghong Song
Cc: Alan Maguire, Arnaldo Carvalho de Melo, dwarves,
Alexei Starovoitov, Andrii Nakryiko, bpf, kernel-team
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs
2026-11-11 22:24 [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs Yonghong Song
2026-11-12 10:53 ` Breno Leitao
@ 2026-11-12 12:36 ` Alan Maguire
2026-11-12 13:54 ` Breno Leitao
2026-11-12 15:26 ` Yonghong Song
1 sibling, 2 replies; 5+ messages in thread
From: Alan Maguire @ 2026-11-12 12:36 UTC (permalink / raw)
To: Yonghong Song, Alan Maguire, Arnaldo Carvalho de Melo, dwarves
Cc: Alexei Starovoitov, Andrii Nakryiko, bpf, kernel-team,
Breno Leitao
On 11/11/26 10:24 PM, 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>
I'm having trouble reproducing the original failure; would you mind sharing
the config that reproduces it? I tried with clang 22, but no luck so far.
> Closes: https://lore.kernel.org/all/au27Y9m78_3EH2v1@gmail.com/
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
> ---
> btf_encoder.c | 49 +++++++++++++++++++++++++++++++++++--------------
> 1 file changed, 35 insertions(+), 14 deletions(-)
>
> diff --git a/btf_encoder.c b/btf_encoder.c
> index 05ffe82..4269467 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c
> @@ -1421,16 +1421,30 @@ static int32_t btf_encoder__save_func(struct btf_encoder *encoder, struct functi
> }
> }
> }
> +
> + /*
> + * A kfunc keeps the ABI of its C prototype, so reset the DWARF
> + * location based flags: otherwise the kfunc may be treated as
> + * optimized and skipped, or lose parameters in BTF.
> + */
> + if (!loc && is_kfunc_state(state)) {
> + state->unexpected_reg = 0;
> + state->optimized_parms = 0;
> + state->uncertain_parm_loc = 0;
> + state->reordered_parm = 0;
> + state->signature_changed = 0;
> + }
> +
a nit I know, but to me this would read better if we did it above, i.e where we
set these values to non-zero, and avoided doing so for the kfunc case, something like:
/*
* A kfunc keeps the ABI of its C prototype, so avoid setting
* state flags, otherwise the kfunc may be treated as
* optimized and skipped, or lose parameters in BTF. For other
* cases, ensure the optimizations/uncertainties are reflected
* in state flags.
*/
if (loc || !is_kfunc_state(state)) {
state->inconsistent_proto = ftype->inconsistent_proto;
state->unexpected_reg = ftype->unexpected_reg;
state->optimized_parms = ftype->optimized_parms;
state->uncertain_parm_loc = ftype->uncertain_parm_loc;
state->reordered_parm = ftype->reordered_parm;
state->signature_changed = ftype->signature_changed;
if (state->addr && func) {
for (int i = 0; i < func->sym_cnt; i++) {
if (state->addr != func->syms[i].addr)
continue;
if (str_contains_optimized_fn_suffix(func->syms[i].name)) {
state->optimized_symbol = 1;
break;
}
}
}
}
Better to not set these values in the first place for kfuncs since we start
with a zeroed out state.
> ftype__for_each_parameter(ftype, param) {
> const char *name;
> char *final_name = NULL;
>
> /* No location info/optimized + reordered means optimized out. */
> - if (!loc && ftype->reordered_parm && (!param->has_loc || param->optimized)) {
> + if (!loc && state->reordered_parm && (!param->has_loc || param->optimized)) {
> state->nr_parms--;
> continue;
> }
> - if (!loc && encoder->true_signature && ftype->signature_changed &&
> + if (!loc && encoder->true_signature && state->signature_changed &&
> param->optimized) {
> state->nr_parms--;
> continue;
> @@ -1797,17 +1811,20 @@ static int btf_encoder__add_saved_funcs(struct btf_encoder *encoder, bool skip_e
> * signature; true_signature can rewrite those signatures.
> * Also exclude functions with unexpected register use, multiple
> * inconsistent prototypes or uncertain parameter locations.
> + * The location based checks do not apply to kfuncs.
> */
> - if (state->unexpected_reg)
> - skip_reason = "unexpected register usage for parameter\n";
> + if (!is_kfunc_state(state)) {
> + if (state->unexpected_reg)
> + skip_reason = "unexpected register usage for parameter\n";
> + if (state->uncertain_parm_loc)
> + skip_reason = "uncertain parameter location\n";
> + if (state->reordered_parm)
> + skip_reason = "reordered parameters\n";
> + if (btf_encoder_func_state__skip_optimized_parms(encoder, canonical_state))
> + skip_reason = "optimized parameters\n";
> + }
> if (skip_encoding_inconsistent_proto && state->inconsistent_proto)
> skip_reason = "inconsistet prototype\n";
> - if (state->uncertain_parm_loc)
> - skip_reason = "uncertain parameter location\n";
> - if (state->reordered_parm)
> - skip_reason = "reordered parameters\n";
> - if (btf_encoder_func_state__skip_optimized_parms(encoder, canonical_state))
> - skip_reason = "optimized parameters\n";
> if (state->elf->ambiguous_addr)
> skip_reason = "ambiguous address\n";
>
> @@ -3056,10 +3073,14 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
> if (!found_percpu && encoder->verbose)
> printf("%s: '%s' doesn't have '%s' section\n", __func__, cu->filename, PERCPU_SECTION);
>
> - if (encoder->tag_kfuncs) {
> - if (btf_encoder__collect_kfuncs(encoder))
> - goto out_delete;
> - }
> + /*
> + * Mark kfuncs before any function state is saved, so
> + * btf_encoder__save_func() keeps their source prototypes.
> + * Needed even without decl_tag_kfuncs, which only controls
> + * the decl tags.
> + */
> + if (btf_encoder__collect_kfuncs(encoder))
> + goto out_delete;
>
> if (encoder->verbose)
> printf("File %s:\n", cu->filename);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs
2026-11-12 12:36 ` Alan Maguire
@ 2026-11-12 13:54 ` Breno Leitao
2026-11-12 15:26 ` Yonghong Song
1 sibling, 0 replies; 5+ messages in thread
From: Breno Leitao @ 2026-11-12 13:54 UTC (permalink / raw)
To: Alan Maguire
Cc: Yonghong Song, Alan Maguire, Arnaldo Carvalho de Melo, dwarves,
Alexei Starovoitov, Andrii Nakryiko, bpf, kernel-team
Hello Alan,
On Thu, Nov 12, 2026 at 12:36:29PM +0000, Alan Maguire wrote:
> > Reported-by: Breno Leitao <leitao@debian.org>
>
> I'm having trouble reproducing the original failure; would you mind sharing
> the config that reproduces it? I tried with clang 22, but no luck so far.
This reproduces it on x86_64, with next-20261111, clang 22.1.3 and
pahole master (9eb594d):
# make LLVM=1 x86_64_defconfig
# ./scripts/config -e BPF_SYSCALL -e BPF_JIT -e CGROUP_BPF \
-d DEBUG_INFO_NONE -e DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT \
-e DEBUG_INFO_BTF -e KCSAN -e UBSAN -e WERROR
# make LLVM=1 olddefconfig
# make LLVM=1 -j$(nproc) vmlinux
[...]
BTF .tmp_vmlinux1
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
Failed to generate BTF for vmlinux
let me know if you are not able to, and I will send you my full .config
Thanks,
--breno
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs
2026-11-12 12:36 ` Alan Maguire
2026-11-12 13:54 ` Breno Leitao
@ 2026-11-12 15:26 ` Yonghong Song
1 sibling, 0 replies; 5+ messages in thread
From: Yonghong Song @ 2026-11-12 15:26 UTC (permalink / raw)
To: Alan Maguire, Alan Maguire, Arnaldo Carvalho de Melo, dwarves
Cc: Alexei Starovoitov, Andrii Nakryiko, bpf, kernel-team,
Breno Leitao
On 11/12/26 4:36 AM, Alan Maguire wrote:
> On 11/11/26 10:24 PM, 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>
> I'm having trouble reproducing the original failure; would you mind sharing
> the config that reproduces it? I tried with clang 22, but no luck so far.
>
>> Closes: https://lore.kernel.org/all/au27Y9m78_3EH2v1@gmail.com/
>> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
>> ---
>> btf_encoder.c | 49 +++++++++++++++++++++++++++++++++++--------------
>> 1 file changed, 35 insertions(+), 14 deletions(-)
>>
>> diff --git a/btf_encoder.c b/btf_encoder.c
>> index 05ffe82..4269467 100644
>> --- a/btf_encoder.c
>> +++ b/btf_encoder.c
>> @@ -1421,16 +1421,30 @@ static int32_t btf_encoder__save_func(struct btf_encoder *encoder, struct functi
>> }
>> }
>> }
>> +
>> + /*
>> + * A kfunc keeps the ABI of its C prototype, so reset the DWARF
>> + * location based flags: otherwise the kfunc may be treated as
>> + * optimized and skipped, or lose parameters in BTF.
>> + */
>> + if (!loc && is_kfunc_state(state)) {
>> + state->unexpected_reg = 0;
>> + state->optimized_parms = 0;
>> + state->uncertain_parm_loc = 0;
>> + state->reordered_parm = 0;
>> + state->signature_changed = 0;
>> + }
>> +
> a nit I know, but to me this would read better if we did it above, i.e where we
> set these values to non-zero, and avoided doing so for the kfunc case, something like:
>
> /*
> * A kfunc keeps the ABI of its C prototype, so avoid setting
> * state flags, otherwise the kfunc may be treated as
> * optimized and skipped, or lose parameters in BTF. For other
> * cases, ensure the optimizations/uncertainties are reflected
> * in state flags.
> */
> if (loc || !is_kfunc_state(state)) {
> state->inconsistent_proto = ftype->inconsistent_proto;
> state->unexpected_reg = ftype->unexpected_reg;
> state->optimized_parms = ftype->optimized_parms;
> state->uncertain_parm_loc = ftype->uncertain_parm_loc;
> state->reordered_parm = ftype->reordered_parm;
> state->signature_changed = ftype->signature_changed;
> if (state->addr && func) {
> for (int i = 0; i < func->sym_cnt; i++) {
> if (state->addr != func->syms[i].addr)
> continue;
> if (str_contains_optimized_fn_suffix(func->syms[i].name)) {
> state->optimized_symbol = 1;
> break;
> }
> }
> }
> }
>
> Better to not set these values in the first place for kfuncs since we start
> with a zeroed out state.
Okay, Will send v2 with the above suggestion!
>
>
>> ftype__for_each_parameter(ftype, param) {
>> const char *name;
>> char *final_name = NULL;
>>
>> /* No location info/optimized + reordered means optimized out. */
>> - if (!loc && ftype->reordered_parm && (!param->has_loc || param->optimized)) {
>> + if (!loc && state->reordered_parm && (!param->has_loc || param->optimized)) {
>> state->nr_parms--;
>> continue;
>> }
>> - if (!loc && encoder->true_signature && ftype->signature_changed &&
>> + if (!loc && encoder->true_signature && state->signature_changed &&
>> param->optimized) {
>> state->nr_parms--;
>> continue;
>> @@ -1797,17 +1811,20 @@ static int btf_encoder__add_saved_funcs(struct btf_encoder *encoder, bool skip_e
>> * signature; true_signature can rewrite those signatures.
>> * Also exclude functions with unexpected register use, multiple
>> * inconsistent prototypes or uncertain parameter locations.
>> + * The location based checks do not apply to kfuncs.
>> */
>> - if (state->unexpected_reg)
>> - skip_reason = "unexpected register usage for parameter\n";
>> + if (!is_kfunc_state(state)) {
>> + if (state->unexpected_reg)
>> + skip_reason = "unexpected register usage for parameter\n";
>> + if (state->uncertain_parm_loc)
>> + skip_reason = "uncertain parameter location\n";
>> + if (state->reordered_parm)
>> + skip_reason = "reordered parameters\n";
>> + if (btf_encoder_func_state__skip_optimized_parms(encoder, canonical_state))
>> + skip_reason = "optimized parameters\n";
>> + }
>> if (skip_encoding_inconsistent_proto && state->inconsistent_proto)
>> skip_reason = "inconsistet prototype\n";
>> - if (state->uncertain_parm_loc)
>> - skip_reason = "uncertain parameter location\n";
>> - if (state->reordered_parm)
>> - skip_reason = "reordered parameters\n";
>> - if (btf_encoder_func_state__skip_optimized_parms(encoder, canonical_state))
>> - skip_reason = "optimized parameters\n";
>> if (state->elf->ambiguous_addr)
>> skip_reason = "ambiguous address\n";
>>
>> @@ -3056,10 +3073,14 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
>> if (!found_percpu && encoder->verbose)
>> printf("%s: '%s' doesn't have '%s' section\n", __func__, cu->filename, PERCPU_SECTION);
>>
>> - if (encoder->tag_kfuncs) {
>> - if (btf_encoder__collect_kfuncs(encoder))
>> - goto out_delete;
>> - }
>> + /*
>> + * Mark kfuncs before any function state is saved, so
>> + * btf_encoder__save_func() keeps their source prototypes.
>> + * Needed even without decl_tag_kfuncs, which only controls
>> + * the decl tags.
>> + */
>> + if (btf_encoder__collect_kfuncs(encoder))
>> + goto out_delete;
>>
>> if (encoder->verbose)
>> printf("File %s:\n", cu->filename);
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-12 15:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 22:24 [PATCH dwarves] btf_encoder: Keep the source prototype of kfuncs Yonghong Song
2026-11-12 10:53 ` Breno Leitao
2026-11-12 12:36 ` Alan Maguire
2026-11-12 13:54 ` Breno Leitao
2026-11-12 15:26 ` Yonghong Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox