All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH dwarves v9 0/3] pahole: Inject kfunc decl tags into BTF
@ 2024-04-29 22:45 Daniel Xu
  2024-04-29 22:45 ` [PATCH dwarves v9 1/3] pahole: Save input filename separate from output Daniel Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Daniel Xu @ 2024-04-29 22:45 UTC (permalink / raw
  To: acme, jolsa, quentin, alan.maguire, eddyz87
  Cc: andrii.nakryiko, ast, daniel, bpf

This patchset teaches pahole to parse symbols in .BTF_ids section in
vmlinux and discover exported kfuncs. Pahole then takes the list of
kfuncs and injects a BTF_KIND_DECL_TAG for each kfunc.

Example of encoding:

        $ bpftool btf dump file .tmp_vmlinux.btf | rg "DECL_TAG 'bpf_kfunc'" | wc -l
        121

        $ bpftool btf dump file .tmp_vmlinux.btf | rg 56337
        [56337] FUNC 'bpf_ct_change_timeout' type_id=56336 linkage=static
        [127861] DECL_TAG 'bpf_kfunc' type_id=56337 component_idx=-1

This enables downstream users and tools to dynamically discover which
kfuncs are available on a system by parsing vmlinux or module BTF, both
available in /sys/kernel/btf.

This feature is enabled with --btf_features=decl_tag,decl_tag_kfuncs.

Tested-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>

=== Changelog ===

Changes from v8:
* Fix another get_func_name() edge case

Changes from v7:
* Fix/support detached BTF encoding

Changes from v6:
* Rebase and add decl_tag_kfuncs as default feature

Changes from v5:
* Add gobuffer__sort() helper
* Use strstarts() instead of strncmp()
* Use uint64_t instead of size_t
* Add clarifying comments for get_func_name()

Changes from v4:
* Update man page with decl_tag_kfuncs feature
* Fix release mode build warnings
* Add elf_getshrstrndx() error checking
* Disable tagging if decl_tag feature is off
* Fix malformed func name handling

Changes from v3:
* Guard kfunc tagging behind feature flag
* Use struct btf_id_set8 definition
* Remove unnecessary member from btf_encoder
* Fix code styling

Changes from v2:
* More reliably detect kfunc membership in set8 by tracking set addr ranges
* Rename some variables/functions to be more clear about kfunc vs func

Changes from v1:
* Fix resource leaks
* Fix callee -> caller typo
* Rename btf_decl_tag from kfunc -> bpf_kfunc
* Only grab btf_id_set funcs tagged kfunc
* Presort btf func list

Daniel Xu (3):
  pahole: Save input filename separate from output
  pahole: Add --btf_feature=decl_tag_kfuncs feature
  pahole: Inject kfunc decl tags into BTF

 btf_encoder.c      | 377 +++++++++++++++++++++++++++++++++++++++++++++
 dwarves.h          |   1 +
 man-pages/pahole.1 |   1 +
 pahole.c           |   1 +
 4 files changed, 380 insertions(+)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-05-07  2:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29 22:45 [PATCH dwarves v9 0/3] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-04-29 22:45 ` [PATCH dwarves v9 1/3] pahole: Save input filename separate from output Daniel Xu
2024-04-30 18:41   ` Arnaldo Carvalho de Melo
2024-04-29 22:45 ` [PATCH dwarves v9 2/3] pahole: Add --btf_feature=decl_tag_kfuncs feature Daniel Xu
2024-04-30 18:48   ` Arnaldo Carvalho de Melo
2024-04-30 23:00     ` Daniel Xu
2024-05-02 11:49       ` Alan Maguire
2024-05-02 13:35         ` Arnaldo Carvalho de Melo
2024-05-02 13:43           ` Alan Maguire
2024-04-29 22:46 ` [PATCH dwarves v9 3/3] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-04-30 19:57   ` Arnaldo Carvalho de Melo
2024-04-30 23:29     ` Daniel Xu
2024-04-30 20:42   ` Arnaldo Carvalho de Melo
2024-04-30 23:27     ` Daniel Xu
2024-05-06 20:07       ` Arnaldo Carvalho de Melo
2024-05-07  2:18         ` Daniel Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.