Message ID | cover.1707080349.git.dxu@dxuuu.xyz (mailing list archive) |
---|---|
Headers | show |
Series | bpf, bpftool: Support dumping kfunc prototypes from BTF | expand |
On Sun, Feb 4, 2024 at 1:06 PM Daniel Xu <dxu@dxuuu.xyz> wrote: > > This patchset enables dumping kfunc prototypes from bpftool. This is > useful b/c with this patchset, end users will no longer have to manually > define kfunc prototypes. For the kernel tree, this also means we can > drop kfunc prototypes from: > > tools/testing/selftests/bpf/bpf_kfuncs.h > tools/testing/selftests/bpf/bpf_experimental.h > > Example usage: > > $ make PAHOLE=/home/dxu/dev/pahole/build/pahole -j30 vmlinux > > $ ./tools/bpf/bpftool/bpftool btf dump file ./vmlinux format c | rg "__ksym;" | head -3 > extern void cgroup_rstat_updated(struct cgroup *cgrp, int cpu) __weak __ksym; > extern void cgroup_rstat_flush(struct cgroup *cgrp) __weak __ksym; > extern struct bpf_key *bpf_lookup_user_key(u32 serial, u64 flags) __weak __ksym; > > Note that this patchset is only effective after the enabling pahole [0] > change is merged and the resulting feature enabled with > --btf_features=decl_tag_kfuncs. > > [0]: https://lore.kernel.org/bpf/cover.1707071969.git.dxu@dxuuu.xyz/ > > === Changelog === > > From v1: > * Add __weak annotation > * Use btf_dump for kfunc prototypes > * Update kernel bpf_rdonly_cast() signature > > Daniel Xu (2): > bpf: Have bpf_rdonly_cast() take a const pointer > bpftool: Support dumping kfunc prototypes from BTF I've applied patch #1 as it's a good change regardless. Please send v2 for patch #2. > > kernel/bpf/helpers.c | 4 ++-- > tools/bpf/bpftool/btf.c | 45 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 47 insertions(+), 2 deletions(-) > > -- > 2.42.1 >
On Tue, Feb 13, 2024 at 11:09:29AM -0800, Andrii Nakryiko wrote: > On Sun, Feb 4, 2024 at 1:06 PM Daniel Xu <dxu@dxuuu.xyz> wrote: > > > > This patchset enables dumping kfunc prototypes from bpftool. This is > > useful b/c with this patchset, end users will no longer have to manually > > define kfunc prototypes. For the kernel tree, this also means we can > > drop kfunc prototypes from: > > > > tools/testing/selftests/bpf/bpf_kfuncs.h > > tools/testing/selftests/bpf/bpf_experimental.h > > > > Example usage: > > > > $ make PAHOLE=/home/dxu/dev/pahole/build/pahole -j30 vmlinux > > > > $ ./tools/bpf/bpftool/bpftool btf dump file ./vmlinux format c | rg "__ksym;" | head -3 > > extern void cgroup_rstat_updated(struct cgroup *cgrp, int cpu) __weak __ksym; > > extern void cgroup_rstat_flush(struct cgroup *cgrp) __weak __ksym; > > extern struct bpf_key *bpf_lookup_user_key(u32 serial, u64 flags) __weak __ksym; > > > > Note that this patchset is only effective after the enabling pahole [0] > > change is merged and the resulting feature enabled with > > --btf_features=decl_tag_kfuncs. > > > > [0]: https://lore.kernel.org/bpf/cover.1707071969.git.dxu@dxuuu.xyz/ > > > > === Changelog === > > > > From v1: > > * Add __weak annotation > > * Use btf_dump for kfunc prototypes > > * Update kernel bpf_rdonly_cast() signature > > > > Daniel Xu (2): > > bpf: Have bpf_rdonly_cast() take a const pointer > > bpftool: Support dumping kfunc prototypes from BTF > > I've applied patch #1 as it's a good change regardless. Please send v2 > for patch #2. Ack. Been a bit busy recently - will probably have time to work on this again next weekend.