All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Matteo Croce <mcroce@linux.microsoft.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [RFC bpf 2/2] btf: adapt relo_core for kernel compilation
Date: Thu, 16 Sep 2021 21:12:41 -0700	[thread overview]
Message-ID: <CAADnVQ+j2zZecHSuc46HZ=wYmwqFEqDuO=xgfirguKKUWAJCBg@mail.gmail.com> (raw)
In-Reply-To: <CAFnufp3Gx11kknVZhZ+MxdpYJKg6awiCpssFoyUcyFrvQ8=eqw@mail.gmail.com>

On Thu, Sep 16, 2021 at 6:22 PM Matteo Croce <mcroce@linux.microsoft.com> 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

  reply	other threads:[~2021-09-17  4:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 13:31 [RFC bpf 0/2] bpf: kernel CO-RE relocation Matteo Croce
2021-09-09 13:31 ` [RFC bpf 1/2] btf: copy relo_core from tools to kernel Matteo Croce
2021-09-09 13:31 ` [RFC bpf 2/2] btf: adapt relo_core for kernel compilation Matteo Croce
2021-09-09 15:38   ` kernel test robot
2021-09-09 18:23   ` Alexei Starovoitov
2021-09-17  1:21     ` Matteo Croce
2021-09-17  4:12       ` Alexei Starovoitov [this message]
2021-09-17 17:45         ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAADnVQ+j2zZecHSuc46HZ=wYmwqFEqDuO=xgfirguKKUWAJCBg@mail.gmail.com' \
    --to=alexei.starovoitov@gmail.com \
    --cc=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=mcroce@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.