Re: [PATCH v2 bpf-next 01/12] libbpf: s/btf__type_by_id/btf_type_by_id/.

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

 



On Thu, Nov 11, 2021 at 9:02 PM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> From: Alexei Starovoitov <ast@xxxxxxxxxx>
>
> To prepare relo_core.c to be compiled in the kernel and the user space
> replace btf__type_by_id with btf_type_by_id.
>
> In libbpf btf__type_by_id and btf_type_by_id have different behavior.
>
> bpf_core_apply_relo_insn() needs behavior of uapi btf__type_by_id
> vs internal btf_type_by_id, but type_id range check is already done
> in bpf_core_apply_relo(), so it's safe to replace it everywhere.
> The kernel btf_type_by_id() does the check anyway. It doesn't hurt.
>
> Suggested-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
> ---


A bit of obnoxiousness. When applied locally with pw-apply, the
subject of this patch looks like this:

eddb6c529562 libbpf: S/btf__type_by_id/btf_type_by_id/

Quite weird. More human-readable "Replace btf__type_by_id() with
btf_type_by_id()" reads so much better ;)

>  tools/lib/bpf/btf.c             |  2 +-
>  tools/lib/bpf/libbpf_internal.h |  2 +-
>  tools/lib/bpf/relo_core.c       | 16 ++++++++--------
>  3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index fadf089ae8fe..aa0e0bbde697 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -454,7 +454,7 @@ const struct btf *btf__base_btf(const struct btf *btf)
>  }
>

[...]

>         type_id = spec->root_type_id;
> -       t = btf__type_by_id(spec->btf, type_id);
> +       t = btf_type_by_id(spec->btf, type_id);
>         s = btf__name_by_offset(spec->btf, t->name_off);
>
>         libbpf_print(level, "[%u] %s %s", type_id, btf_kind_str(t), str_is_empty(s) ? "<anon>" : s);
> @@ -1158,7 +1158,7 @@ int bpf_core_apply_relo_insn(const char *prog_name, struct bpf_insn *insn,
>         int i, j, err;
>
>         local_id = relo->type_id;
> -       local_type = btf__type_by_id(local_btf, local_id);
> +       local_type = btf_type_by_id(local_btf, local_id);
>         if (!local_type)
>                 return -EINVAL;

Please remove this check, it's meaningless with the use of
btf_type_by_id() and you already justified why it's not necessary.

>
> --
> 2.30.2
>



[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