All of lore.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:15:38 -0300	[thread overview]
Message-ID: <20190215171538.GB31177@kernel.org> (raw)
In-Reply-To: <CAEf4BzYpCieVmjuwW-yuiOLuAfhZ9oTPGCZM-O88Jii2rrnP0w@mail.gmail.com>

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:
> >
> > Em Thu, Feb 14, 2019 at 10:20:29AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Thu, Feb 14, 2019 at 10:11:56AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > > Em Thu, Feb 14, 2019 at 09:47:57AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > > > Em Wed, Feb 13, 2019 at 09:43:43PM -0800, Andrii Nakryiko escreveu:
> > > > > > happy with it. So consider this email a solicitation for naming
> > > > > > suggestion. Keep in mind, that all the pahole's functions of the form
> > > > > > btf__xxx will be renamed as well for consistency. If you like
> > > > > > btf_info, let me know as well, I'll just stick with it.
> > > >
> > > > > Can you try thinking if splitting this further into 'struct btf_loader',
> > > > > 'struct btf_encoder' that would live in the pahole sources and that
> > > > > refer to a 'struct btf' that lives in libbpf (or in libbtf, at some
> > > > > point) is a move that eases your current needs?
> 
> I think pahole would be simpler by using struct btf for btf_loader and
> separate struct btf_enc (or whatever name we come up with) to encode
> BTF during DWARF->BTF conversion. See below about mutable vs immutable
> BTF representations. For immutable parts libbpf's struct btf should be
> enough, though pahole is dealing also with endianness issues, so we'll
> need to resolve that somehow.
> 
> > > >
> > > > So, the btf__new() in tools/lib/bpf/btf.c is basically a variant of
> > > > btf__new() in the pahole sources, probably we should go ahead and make
> > > > pahole use that btf__new() and do changes in tools/lib/bpf/btf.c to
> > > > allow for it to access internal state that it needs to do its job?
> > >
> > > No, we can't, because tools/lib/btf/btf.c btf__new() is centered on
> > > getting some BTF buffer no matter where it comes from and passing it to
> > > the kernel.
> 
> 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.

> and strings sections. Then, once application is done constructing BTF,
> that modifyable struct can be "sealed" into read-only struct btf.
> Whichever way we'll go about that, there should be minimal changes to
> pahole to be able to reuse that functionality.
 
> > > So probably we should backtrack to my previous suggestion of having
> > > pahole use 'struct btf_loader', or even more explicitely, 'struct
> > > btf_elf' to make extra clear that this has nothing to do with the
> > > kernel, its purely about loading/encoding the BTF info from/to a ELF
> > > file.

> > So, I have this in my private branch, please see if this helps get
> > things moving forward:
 
> Yes, this is exactly what I needed, thanks for doing this massive
> renaming! See just one nit below about probably unintentional file
> name change.

yeah
 
> > @@ -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.

Thanks,

- Arnaldo

  reply	other threads:[~2019-02-15 17:15 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 [this message]
2019-02-15 17:25             ` Andrii Nakryiko
2019-02-15 17:43               ` Arnaldo Carvalho de Melo
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=20190215171538.GB31177@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 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.