BPF List
 help / color / mirror / Atom feed
* [PATCH dwarves v4 0/2] pahole: Inject kfunc decl tags into BTF
@ 2024-02-04 18:40 Daniel Xu
  2024-02-04 18:40 ` [PATCH dwarves v4 1/2] pahole: Add --btf_feature=decl_tag_kfuncs feature Daniel Xu
  2024-02-04 18:40 ` [PATCH dwarves v4 2/2] pahole: Inject kfunc decl tags into BTF Daniel Xu
  0 siblings, 2 replies; 14+ messages in thread
From: Daniel Xu @ 2024-02-04 18:40 UTC (permalink / raw)
  To: acme, jolsa, quentin, alan.maguire; +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.

=== Changelog ===

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 (2):
  pahole: Add --btf_feature=decl_tag_kfuncs feature
  pahole: Inject kfunc decl tags into BTF

 btf_encoder.c | 361 ++++++++++++++++++++++++++++++++++++++++++++++++++
 dwarves.h     |   1 +
 pahole.c      |   1 +
 3 files changed, 363 insertions(+)

-- 
2.42.1


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

end of thread, other threads:[~2024-03-15 19:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-04 18:40 [PATCH dwarves v4 0/2] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-02-04 18:40 ` [PATCH dwarves v4 1/2] pahole: Add --btf_feature=decl_tag_kfuncs feature Daniel Xu
2024-02-06 12:47   ` Jiri Olsa
2024-02-06 14:14     ` Alan Maguire
2024-02-04 18:40 ` [PATCH dwarves v4 2/2] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-02-05 16:54   ` Eduard Zingerman
2024-02-05 23:31   ` Eduard Zingerman
2024-02-28 16:07     ` Daniel Xu
2024-02-28 21:33       ` Eduard Zingerman
2024-03-15 19:43         ` Daniel Xu
2024-02-08 10:00   ` Alan Maguire
2024-02-29  0:57     ` Daniel Xu
2024-03-13  3:17       ` Daniel Xu
2024-03-13  9:36         ` Alan Maguire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox