All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel Müller" <deso@posteo.net>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 1/2] libbpf: Move core "types_are_compat" logic into relo_core.c
Date: Thu, 23 Jun 2022 18:13:43 +0000	[thread overview]
Message-ID: <20220623181343.hgopdj2v3ejfmojq@muellerd-fedora-MJ0AC3F3> (raw)
In-Reply-To: <CAEf4Bzbe-r+G00Zy-wTFE+Y765BtmaTNHYdjoXc91XNwzuJWWQ@mail.gmail.com>

On Wed, Jun 22, 2022 at 09:15:01PM -0700, Andrii Nakryiko wrote:
> On Wed, Jun 22, 2022 at 10:35 AM Daniel Müller <deso@posteo.net> wrote:
> >
> > This change merges the two existing implementations of the
> > bpf_core_types_are_compat() function into relo_core.c, inheriting the
> > recursion tracking from the kernel and the usage of
> > btf_kind_core_compat() from libbpf. The kernel is left untouched and
> > will be adjusted subsequently.
> >
> > Signed-off-by: Daniel Müller <deso@posteo.net>
> > ---
> 
> I don't feel very strongly about this, but given we are consolidating
> kernel and libbpf code, I think it makes sense to do it in one patch.

Sure.


> >  tools/lib/bpf/libbpf.c    | 72 +-----------------------------------
> >  tools/lib/bpf/relo_core.c | 78 +++++++++++++++++++++++++++++++++++++++
> >  tools/lib/bpf/relo_core.h |  2 +
> >  3 files changed, 81 insertions(+), 71 deletions(-)
> >
> 
> [...]
> 
> > -       default:
> > -               pr_warn("unexpected kind %s relocated, local [%d], target [%d]\n",
> > -                       btf_kind_str(local_type), local_id, targ_id);
> > -               return 0;
> > -       }
> > +       return bpf_core_types_are_compat_recur(local_btf, local_id, targ_btf, targ_id, INT_MAX);
> 
> INT_MAX seems like an overkill, let's just hard-code 32 just like we
> have for a local recursion limit here?

Okay.

> >  }
> >
> 
> [...]
> 
> >  /*
> >   * Turn bpf_core_relo into a low- and high-level spec representation,
> >   * validating correctness along the way, as well as calculating resulting
> > diff --git a/tools/lib/bpf/relo_core.h b/tools/lib/bpf/relo_core.h
> > index 7df0da0..b8998f 100644
> > --- a/tools/lib/bpf/relo_core.h
> > +++ b/tools/lib/bpf/relo_core.h
> > @@ -68,6 +68,8 @@ struct bpf_core_relo_res {
> >         __u32 new_type_id;
> >  };
> >
> > +int bpf_core_types_are_compat_recur(const struct btf *local_btf, __u32 local_id,
> > +                                   const struct btf *targ_btf, __u32 targ_id, int level);
> 
> Just leave it called __bpf_core_types_are_compat like in kernel, it is
> clearly an "internal" version of bpf_core_types_are_compat(), so it's
> more proper naming convention.

Sounds good.

[...]

Thanks,
Daniel

  reply	other threads:[~2022-06-23 19:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22 17:35 [PATCH bpf-next 0/2] Deduplicate type compat check Daniel Müller
2022-06-22 17:35 ` [PATCH bpf-next 1/2] libbpf: Move core "types_are_compat" logic into relo_core.c Daniel Müller
2022-06-22 22:19   ` Daniel Müller
2022-06-23  4:15     ` Andrii Nakryiko
2022-06-23  4:15   ` Andrii Nakryiko
2022-06-23 18:13     ` Daniel Müller [this message]
2022-06-22 17:35 ` [PATCH bpf-next 2/2] bpf: Use bpf_core_types_are_compat functionality from relo_core.c Daniel Müller

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=20220623181343.hgopdj2v3ejfmojq@muellerd-fedora-MJ0AC3F3 \
    --to=deso@posteo.net \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.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.