public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Alexei Starovoitov <ast@fb.com>, Yonghong Song <yhs@fb.com>,
	Martin Lau <kafai@fb.com>,
	bpf@vger.kernel.org, dwarves@vger.kernel.org
Subject: Re: pahole: soliciting naming suggestion for struct btf rename
Date: Fri, 15 Feb 2019 14:43:17 -0300	[thread overview]
Message-ID: <20190215174317.GG31177@kernel.org> (raw)
In-Reply-To: <CAEf4BzY_uZfb0WrmFjVZiOgttJzc4C81NX3_K0K7uAugHKUWaA@mail.gmail.com>

Em Fri, Feb 15, 2019 at 09:25:48AM -0800, Andrii Nakryiko escreveu:
> On Fri, Feb 15, 2019 at 9:15 AM Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> wrote:
> > Em Thu, Feb 14, 2019 at 08:37:51PM -0800, Andrii Nakryiko escreveu:
> > > On Thu, Feb 14, 2019 at 6:01 AM Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> wrote:
> > > Yes, libbpf's struct btf is immutable read-only view of .BTF section
> > > that can come from either file or kernel. When I'll be adding BTF
> > > writing (encoding) API, it probably will be done using something
> > > similar to pahole's struct btf, that supports dynamic growth of types

> > Ok, I noticed that libbpf's btf__new() does load things into the kernel,
> > perhaps we should have it not do that and instead have some other method
> > for asking it to send the data to kernel, i.e.:

> >         struct btf *btf = btf__new();
> >         int err = btf__load_to_kernel(btf, data, size);

> > Or have multiple constructors, each specifying what it actually does,
> > i.e.:

> > To get a btf data + size and insert it into the kernel, getting its fd,
> > etc:

> >         struct btf *btf = btf__new_to_kernel(data, size);

> > For asking for BTF info that is already in the kernel to be obtained for
> > tooling to parse maps in running bpf programs:

> >         struct btf *btf = btf__new_from_kernel(fd);

> > And for the pahole case it would be:

> >         struct btf *btf = btf__new_from_elf(file-with-BTF-ELF-section)

> > that would then be used to do the encoding, etc.

> We already did that a couple of days ago, that code wasn't yet
> mirrored into github.com/libbpf/libbpf until yesterday (it was merged
> this morning). We now have btf__new(data, size) that just constructs
> in-memory BTF struct with index for types. And we have
> btf__load(struct btf* btf) that can load that into kernel.

cool
 
> We already have equivalent of btf__new_from_kernel(fd) -- btf__get_from_id(fd).

cool, if it allocates space for sizeof(*btf) and returns this newly
allocated object, then please consider renaming it to btf__new_from_id(fd).

> Adding something akin to btf__new_from_elf() might be a good idea as
> well, for completeness.

Its nice to be on the same page :-)

<SNIP>
 
> > > > @@ -645,7 +636,7 @@ static int btf__write_elf(struct btf *btf)
> > > >                         llvm_objcopy = "llvm-objcopy";
> > > >
> > > >                 /* Use objcopy to add a .BTF section */
> > > > -               snprintf(tmp_fn, sizeof(tmp_fn), "%s.btf", btf->filename);
> > > > +               snprintf(tmp_fn, sizeof(tmp_fn), "%s.btfe", btfe->filename);
> > >
> > > This is probably unintentional change, though not a problem per se.
> >
> > Eagle eyes, I'll fix that.
 
> :)

- Arnaldo

  reply	other threads:[~2019-02-15 17:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14  5:43 pahole: soliciting naming suggestion for struct btf rename Andrii Nakryiko
2019-02-14 12:47 ` Arnaldo Carvalho de Melo
2019-02-14 13:11   ` Arnaldo Carvalho de Melo
2019-02-14 13:20     ` Arnaldo Carvalho de Melo
2019-02-14 14:01       ` Arnaldo Carvalho de Melo
2019-02-15  4:37         ` Andrii Nakryiko
2019-02-15 17:15           ` Arnaldo Carvalho de Melo
2019-02-15 17:25             ` Andrii Nakryiko
2019-02-15 17:43               ` Arnaldo Carvalho de Melo [this message]
2019-02-15 17:17   ` Alexei Starovoitov
2019-02-15 17:25     ` Arnaldo Carvalho de Melo
2019-02-15 18:47       ` Alexei Starovoitov
2019-02-15 20:21         ` Daniel Borkmann
2019-02-18 12:44           ` Arnaldo Carvalho de Melo

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=20190215174317.GG31177@kernel.org \
    --to=acme@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=kafai@fb.com \
    --cc=yhs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox