All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Kui-Feng Lee <kuifeng@fb.com>
Cc: 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: Fri, 25 Mar 2022 16:02:13 -0700	[thread overview]
Message-ID: <CAEf4BzYTBV2qi10s5ewz9QPR2MU0v+dtGCkfqJomps8N8-HF0g@mail.gmail.com> (raw)
In-Reply-To: <20220321230837.855572-1-kuifeng@fb.com>

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>

>  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
>

  reply	other threads:[~2022-03-25 23:02 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 [this message]
2022-03-26 14:51   ` 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=CAEf4BzYTBV2qi10s5ewz9QPR2MU0v+dtGCkfqJomps8N8-HF0g@mail.gmail.com \
    --to=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 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.