From: Alan Maguire <alan.maguire@oracle.com>
To: sedat.dilek@gmail.com
Cc: Ihor Solodrai <ihor.solodrai@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Mykola Lysenko <mykolal@fb.com>,
bpf@vger.kernel.org, sudipm.mukherjee@gmail.com,
cavok@debian.org,
"dwarves@vger.kernel.org" <dwarves@vger.kernel.org>
Subject: Re: pahole v1.30 and libbpf: Introduce kflag for type_tags and decl_tags in BTF
Date: Thu, 24 Apr 2025 08:48:39 +0100 [thread overview]
Message-ID: <9a577a7a-d55b-4017-b1ab-e6f2980f58b0@oracle.com> (raw)
In-Reply-To: <CAEf4BzadoMS7RPL26J2U_NyQUXnwVEmP+TxHU6D8R4AKvWSGsA@mail.gmail.com>
On 23/04/2025 18:50, Andrii Nakryiko wrote:
> On Fri, Apr 18, 2025 at 11:58 AM Sedat Dilek <sedat.dilek@gmail.com> 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.
From a libbpf perspective, looks like bpf selftests have test coverage
for btf__add_type_attr() already as part of prog_tests/btf_dump.c.
Alan
>> dileks@iniza:~/src/linux/git$ git log --oneline -1
>> 51d1b1d42841c557dabde5b140ae20774591e6dc
>> 51d1b1d42841 libbpf: Introduce kflag for type_tags and decl_tags in BTF
>>
>> Add the following functions to libbpf API:
>> * btf__add_type_attr()
>> * btf__add_decl_attr()
>>
>> dileks@iniza:~/src/linux/git$ git describe --contains
>> 51d1b1d42841c557dabde5b140ae20774591e6dc
>> v6.15-rc1~98^2~87^2~5
>>
>> Currently, I use Debian-kernel v6.12.22 and want to build a selfmade
>> v6.12.24 (when it is released).
>>
>> If you need further information, please let me know.
>>
>> Best Thanks,
>> -Sedat-
>>
>> P.S.: My investigations
>>
>> [ DEBIAN PAHOLE ]
>>
>> Debian/unstable AMD64 ships on my request pahole version 1.30-1.
>> This version was built against libbpf-dev version (1:1.5.0-2)
>>
>> Link: https://packages.debian.org/sid/pahole
>> Link: https://packages.debian.org/sid/libbpf-dev
>> Link: https://bugs.debian.org/1103000
>>
>>
>> [ SELFMADE PAHOLE ]
>>
>> Prereq: libbpf API version >= 1.6.0
>>
>> dileks@iniza:~/src/pahole/git$ git describe
>> v1.29-16-gb45268b74da1
>>
>> dileks@iniza:~/src/pahole/git$ git log --oneline -1
>> b45268b74da1 (HEAD -> pahole-v1.30, tag: v1.30, origin/next,
>> origin/master, origin/HEAD, master) Prep 1.30
>>
>> root# /opt/pahole/bin/pahole --version
>> v1.30
>>
>> INFO: git describe should report v1.30
>>
>>
>> [ BUILD INSTRUCTIONS ]
>>
>> VER="1.30"
>> PREFIX="/opt/pahole-$VER"
>> PREFIX_CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=$PREFIX"
>>
>> echo $PREFIX_CMAKE_OPTS
>>
>> cd ..
>> mkdir build
>> cd build
>>
>> # NOTE: See upstream commit "CMakeList.txt: Respect CMAKE_INSTALL_LIBDIR"
>> ##cmake $PREFIX_CMAKE_OPTS -D__LIB=lib ../git
>> LC_ALL=C.UTF-8 cmake $PREFIX_CMAKE_OPTS ../git
>> make
>> sudo make install
>>
>> NOTE: Do NOT forget to run `ldconfig` as root (see below).
>>
>>
>> [ LDCONFIG ]
>>
>> File: /etc/ld.so.conf.d/a-local-pahole.conf
>>
>> # pahole lib configuration
>> /opt/pahole/lib
>>
>> root# cd /opt
>> root# ln -sf pahole-$VER pahole
>> root# ldconfig
>> root# ldconfig --print-cache | grep pahole
>>
>>
>> [ PAHOLE - CMAKE LOG (LIBBPF) ]
>>
>> [...]
>> -- Submodule update
>> Submodule 'lib/bpf' (https://github.com/libbpf/libbpf) registered for
>> path 'lib/bpf'
>> Cloning into '/home/dileks/src/pahole/git/lib/bpf'...
>> Submodule path 'lib/bpf': checked out '42a6ef63161a8dc4288172b27f3870e50b3606f7'
>> -- Submodule update - done
>>
>> Link: https://web.git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=v1.30&id=fe2dcd28ba9d348744ee93fed43cbed5dc0d6a43
>>
>>
>> [ BTF FEATURES ]
>>
>> root# /opt/pahole/bin/pahole --usage | grep feature
>> [--btf_encode_force] [--btf_features=FEATURE_LIST]
>> [--btf_features_strict=FEATURE_LIST_STRICT] [--btf_gen_all]
>> [--skip_missing] [--sort] [--structs] [--supported_btf_features]
>>
>> NOTE: --btf_feature*s* (all options plural) VS. commit 40e82f5be9a7
>> ("pahole: Introduce --btf_feature=attributes")
>>
>> root# /opt/pahole/bin/pahole --supported_btf_features
>> encode_force,var,float,decl_tag,type_tag,enum64,optimized_func,consistent_func,decl_tag_kfuncs,reproducible_build,distilled_base,global_var,attributes
>>
>> NOTE: Supported = attributes
>>
>>
>> [ LIBBPF API VERSION >= 1.6.0 ]
>>
>> Link: https://web.git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=v1.30&id=fe2dcd28ba9d348744ee93fed43cbed5dc0d6a43
>>
>> commit fe2dcd28ba9d348744ee93fed43cbed5dc0d6a43 ("pahole: Sync with
>> libbpf mainline")
>>
>> Pull recently added libbpf API functions:
>> * btf__add_decl_attr()
>> * btf__add_type_attr()
>>
>> root# llvm-dwarfdump-19 /opt/pahole/bin/pahole | grep btf | grep add
>> DW_AT_name ("btf__add_type_attr")
>> DW_AT_name ("btf__add_enum64")
>>
>>
>> [ pahole.git - lib/bpf/src/libbpf.map ]
>>
>> LIBBPF_1.6.0 {
>> global:
>> bpf_linker__add_buf;
>> bpf_linker__add_fd;
>> bpf_linker__new_fd;
>> btf__add_decl_attr;
>> btf__add_type_attr;
>> } LIBBPF_1.5.0;
>>
>> -EOT-
parent reply other threads:[~2025-04-24 7:49 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CAEf4BzadoMS7RPL26J2U_NyQUXnwVEmP+TxHU6D8R4AKvWSGsA@mail.gmail.com>]
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=9a577a7a-d55b-4017-b1ab-e6f2980f58b0@oracle.com \
--to=alan.maguire@oracle.com \
--cc=acme@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cavok@debian.org \
--cc=dwarves@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=mykolal@fb.com \
--cc=sedat.dilek@gmail.com \
--cc=sudipm.mukherjee@gmail.com \
/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