From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Kui-Feng Lee <kuifeng@fb.com>,
Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
dwarves@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH dwarves] pahole, btf_encoder: Collect info of per-cpu varaibles from threads.
Date: Sat, 26 Mar 2022 11:51:21 -0300 [thread overview]
Message-ID: <Yj8oaVdV2+Pmacv9@kernel.org> (raw)
In-Reply-To: <CAEf4BzYTBV2qi10s5ewz9QPR2MU0v+dtGCkfqJomps8N8-HF0g@mail.gmail.com>
Em Fri, Mar 25, 2022 at 04:02:13PM -0700, Andrii Nakryiko escreveu:
> On Mon, Mar 21, 2022 at 4:08 PM Kui-Feng Lee <kuifeng@fb.com> wrote:
> >
> > Collect the information of per-cpu variables from encoders of worker
> > threads to the primary encoder.
> >
> > btf_encoder store per-cpu info separately, not in btf. Previously, it
> > merged only btf types generated by worker threads. So, some of the
> > per-cpu info was missing.
> >
> > Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
> > ---
>
> I've applied this locally and tested, it all looks good, thanks! I'm
> keeping this applied locally until Arnaldo pushes this to master :)
>
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> Tested-by: Andrii Nakryiko <andrii@kernel.org>
And from a quick look the code is really elegant, well done!
Applied and will push to the next branch, later today/tomorrow I'll push
it out to master after it passes the libbpf CI tests.
Thanks!
- Arnaldo
> > btf_encoder.c | 21 +++++++++++++++++++++
> > btf_encoder.h | 2 ++
> > pahole.c | 2 +-
> > 3 files changed, 24 insertions(+), 1 deletion(-)
> >
> > diff --git a/btf_encoder.c b/btf_encoder.c
> > index fa29824..1a42094 100644
> > --- a/btf_encoder.c
> > +++ b/btf_encoder.c
> > @@ -606,6 +606,27 @@ static int32_t btf_encoder__add_var_secinfo(struct btf_encoder *encoder, uint32_
> > return gobuffer__add(&encoder->percpu_secinfo, &si, sizeof(si));
> > }
> >
> > +int32_t btf_encoder__add_encoder(struct btf_encoder *encoder, struct btf_encoder *other)
> > +{
> > + struct gobuffer *var_secinfo_buf = &other->percpu_secinfo;
> > + size_t sz = gobuffer__size(var_secinfo_buf);
> > + uint16_t nr_var_secinfo = sz / sizeof(struct btf_var_secinfo);
> > + uint32_t type_id;
> > + uint32_t next_type_id = btf__type_cnt(encoder->btf);
> > + int32_t i, id;
> > + struct btf_var_secinfo *vsi;
> > +
> > + for (i = 0; i < nr_var_secinfo; i++) {
> > + vsi = (struct btf_var_secinfo *)var_secinfo_buf->entries + i;
> > + type_id = next_type_id + vsi->type - 1; /* Type ID starts from 1 */
> > + id = btf_encoder__add_var_secinfo(encoder, type_id, vsi->offset, vsi->size);
> > + if (id < 0)
> > + return id;
> > + }
> > +
> > + return btf__add_btf(encoder->btf, other->btf);
> > +}
> > +
> > static int32_t btf_encoder__add_datasec(struct btf_encoder *encoder, const char *section_name)
> > {
> > struct gobuffer *var_secinfo_buf = &encoder->percpu_secinfo;
> > diff --git a/btf_encoder.h b/btf_encoder.h
> > index 0f0eee8..339fae2 100644
> > --- a/btf_encoder.h
> > +++ b/btf_encoder.h
> > @@ -31,4 +31,6 @@ struct btf_encoder *btf_encoders__next(struct btf_encoder *encoder);
> >
> > struct btf *btf_encoder__btf(struct btf_encoder *encoder);
> >
> > +int btf_encoder__add_encoder(struct btf_encoder *encoder, struct btf_encoder *other);
> > +
> > #endif /* _BTF_ENCODER_H_ */
> > diff --git a/pahole.c b/pahole.c
> > index f7c7966..a909b22 100644
> > --- a/pahole.c
> > +++ b/pahole.c
> > @@ -2867,7 +2867,7 @@ static int pahole_threads_collect(struct conf_load *conf, int nr_threads, void *
> > */
> > if (!threads[i]->btf || threads[i]->encoder == btf_encoder)
> > continue; /* The primary btf_encoder */
> > - err = btf__add_btf(btf_encoder__btf(btf_encoder), threads[i]->btf);
> > + err = btf_encoder__add_encoder(btf_encoder, threads[i]->encoder);
> > if (err < 0)
> > goto out;
> > btf_encoder__delete(threads[i]->encoder);
> > --
> > 2.30.2
> >
--
- Arnaldo
prev parent reply other threads:[~2022-03-26 14:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 23:08 [PATCH dwarves] pahole, btf_encoder: Collect info of per-cpu varaibles from threads Kui-Feng Lee
2022-03-25 23:02 ` Andrii Nakryiko
2022-03-26 14:51 ` Arnaldo Carvalho de Melo [this message]
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=Yj8oaVdV2+Pmacv9@kernel.org \
--to=acme@kernel.org \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=arnaldo.melo@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=dwarves@vger.kernel.org \
--cc=kuifeng@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;
as well as URLs for NNTP newsgroup(s).