Re: [RFC bpf 2/2] btf: adapt relo_core for kernel compilation

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

 



On Thu, Sep 16, 2021 at 6:22 PM Matteo Croce <mcroce@xxxxxxxxxxxxxxxxxxx> wrote:
>
> How can we share the helpers source too instead of duplicating it?

Ideally. Yes.
Andrii pointed out that libbpf's btf.h is installed,
so it's part of libbpf api.
Therefore it's safer to rename kernel helpers with equivalent meaning
instead of risking libbpf renames.

>
> Indeed, I found a small difference between the userspace and kernel code.
>
> In tools/lib/bpf/btf.h we have btf_is_mod() which returns true for
> { BTF_KIND_VOLATILE, BTF_KIND_CONST, BTF_KIND_RESTRICT },
> while in kernel/bpf/btf.c we have btf_type_is_modifier() which returns
> true also for BTF_KIND_TYPEDEF.
>
> Which is the right one?

btf_is_mod() is part of libbpf btf.h, so we cannot change it.
btf_type_is_modifier() is kernel internal helper.
It doesn't need to change and doesn't need to match.
The equivalent helpers are
skip_mods_and_typedefs() in the libbpf
and
btf_type_skip_modifiers() in the kernel.
In this case it's probably better to search-and-replace in libbpf.
In most other cases kernel search-and-replace will be necessary.
For example:
btf_type_vlen->btf_vlen
btf_type_member->btf_members



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux