Re: [PATCH dwarves v1 0/3] btf_encoder: support for BPF magic kernel functions

Ihor Solodrai
2025-11-04T22:38:09Z

On 11/4/25 2:33 PM, Eduard Zingerman wrote:
> On Tue, 2025-11-04 at 14:25 -0800, Ihor Solodrai wrote:
>> On 11/4/25 12:59 PM, Alan Maguire wrote:
>>> On 29/10/2025 19:02, Ihor Solodrai wrote:
>>>> This series implements BTF encoding of BPF kernel functions marked
>>>> with KF_MAGIC_ARGS flag in pahole.
>>>>
>>>> The kfunc flag indicates that the arguments of a kfunc with __magic
>>>> suffix are implicitly set by the verifier, and so pahole must emit two
>>>> functions to BTF:
>>>> * kfunc_impl() with the arguments matching kernel declaration
>>>> * kfunc() with __magic arguments omitted
>>>>
>>>> For more details see relevant patch series for BPF:
>>>> "bpf: magic kernel functions"
>>>>
>>>> This series is built upon KF_IMPLICIT_PROG_AUX_ARG support [1],
>>>> although the approach changed signifcantly to call it a v2.
>>>>
>>>> [1] https://lore.kernel.org/dwarves/20250924211512.1287298-1-ihor.solodrai@linux.dev/
>>>>
>>>> Ihor Solodrai (3):
>>>> btf_encoder: refactor btf_encoder__add_func_proto
>>>> btf_encoder: factor out btf_encoder__add_bpf_kfunc()
>>>> btf_encoder: support kfuncs with KF_MAGIC_ARGS flag
>>>>
>>>> btf_encoder.c | 292 ++++++++++++++++++++++++++++++++++++++------------
>>>> 1 file changed, 222 insertions(+), 70 deletions(-)
>>>>
>>>
>>> seems like we could potentially pull in patches 1 and 2 as cleanups
>>> prior to handling the KF_MAGIC/IMPLICIT change; would that be worthwhile?
>>>
>>
>> Hi Alan.
>>
>> Feel free to merge in the refactoring patches if you think they are
>> useful. No objections.
>
> Hi Alan, Ihor,
>
> If you thinking about merging patch #1, please consider my comment:
>
> > > +static int32_t btf_encoder__add_func_proto_for_state(struct btf_encoder *encoder, struct btf_encoder_func_state *state)
>
> > You can get rid of the `encoder` parameter here.
> > See https://github.com/acmel/dwarves/commit/080d1f27ae71e30c269a1e26e85bb86c3683f195 .
>
> I sound a bit like a broken record, sorry.

Oh, thanks for the ping, I missed this comment.

Alan, let me re-spin the refactoring patches separately.

>
> …