Re: pahole v1.30 and libbpf: Introduce kflag for type_tags and decl_tags in BTF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/04/2025 18:50, Andrii Nakryiko wrote:
> On Fri, Apr 18, 2025 at 11:58 AM Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:
>>
>> [ QUESTION ]
>>
>> How to check if libbpf API functions
>>  * btf__add_decl_attr()
>>  * btf__add_type_attr()
>> work as expected with pahole v1.30?
> 
> What does it mean "work as expected"?
> 
> Can you be a bit more explicit about what is the problem and what
> doesn't work? I didn't get that from the below investigation notes,
> sorry.
> 
>>
>> Looks like I need Linux version >= v6.15-rc1?
>>

hi Sedat, I'm presuming you just want a way to test these new APIs using
pahole-generated BTF (if that's not what you're asking, as Andrii says
please do let us know what you're trying to do in more detail).

There are two aspects to this; can I generate those attributes, and can
the kernel handle them?

For the first case, type attributes are currently generated if the
"attributes" BTF feature is specified. Whether you have this
functionality in pahole v1.30 depends how you build pahole; if you use
the git submodule, you will have the required function. If not, the new
functionality Ihor added should dynamically detect the presence of
btf__add_type_attr() in the shared library libbpf.so for cases where the
"attributes" flag is specified. If your libbpf.so does not have that
function, the feature request is ignored. btf__add_decl_attr() isn't
used in pahole yet. You can run

pahole --supported_btf_features

...to see if the feature is supported; looks like it is in your case
from what you sent.

Now the next issue is whether a kernel can parse type tags with kind
flag set; only kernels that specify the "attributes" BTF feature in
scripts/Makefile.btf should generate such type tags, as these are the
kernels that can validate BTF containing them.

You can see type attributes in action for vmlinux BTF by running
"bpftool btf dump file vmlinux format c"; a few of the arena-related
kfunc parameters should have address_space(1) attributes associated with
them; example

extern void __attribute__((address_space(1)))
*bpf_arena_alloc_pages(void *p__map, void
__attribute__((address_space(1))) *addr__ign, u32 page_cnt, int node_id,
u64 flags) __weak __ksym;

Note that you need a matching bpftool that also understands that the
kind flag set means an __attribute__((address_space(1))) ; otherwise
these will incorrectly show as
__attribute__(btf_type_tag("address_space(1)")). So make sure you use
the bpftool from a kernel supporting the "attributes" BTF feature.

It would be good to have a standalone pahole selftest covering type
attribute generation; if that's something you would like to contribute
that would be great. We can't really test the decl attribute from the
pahole side until pahole starts using it.


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux