From: Eduard Zingerman <eddyz87@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>, acme@kernel.org
Cc: andrii.nakryiko@gmail.com, ast@kernel.org, daniel@iogearbox.net,
jolsa@kernel.org, martin.lau@linux.dev, song@kernel.org,
yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org,
sdf@google.com, haoluo@google.com, mykolal@fb.com,
bpf@vger.kernel.org
Subject: Re: [PATCH dwarves 3/3] btf_encoder: learn BTF_KIND_MAX value from base BTF when generating split BTF
Date: Wed, 13 Sep 2023 19:58:50 +0300 [thread overview]
Message-ID: <8f91f140d779625e47f425958e186bf255f26b19.camel@gmail.com> (raw)
In-Reply-To: <20230913142646.190047-4-alan.maguire@oracle.com>
On Wed, 2023-09-13 at 15:26 +0100, Alan Maguire wrote:
> > When creating module BTF, the module likely will not have a DWARF
> > specificiation of BTF_KIND_MAX, so look for it in the base BTF. For
> > vmlinux base BTF, the enumeration value is present, so the base BTF
> > can be checked to limit BTF kind representation.
> >
> > Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> > ---
> > btf_encoder.c | 24 ++++++++++++++++++++++++
> > btf_encoder.h | 2 ++
> > pahole.c | 2 ++
> > 3 files changed, 28 insertions(+)
> >
> > diff --git a/btf_encoder.c b/btf_encoder.c
> > index ad0158f..6cb3df6 100644
> > --- a/btf_encoder.c
> > +++ b/btf_encoder.c
> > @@ -1902,3 +1902,27 @@ void dwarves__set_btf_kind_max(struct conf_load *conf_load, int btf_kind_max)
> > if (btf_kind_max < BTF_KIND_ENUM64)
> > conf_load->skip_encoding_btf_enum64 = true;
> > }
> > +
> > +void btf__set_btf_kind_max(struct conf_load *conf_load, struct btf *btf)
> > +{
Nitpick: same function for DWARF has name dwarf__find_btf_kind_max,
which seems to be a bit inconsistent.
> > + __u32 id, type_cnt = btf__type_cnt(btf);
> > +
> > + for (id = 1; id < type_cnt; id++) {
> > + const struct btf_type *t = btf__type_by_id(btf, id);
> > + const struct btf_enum *e;
> > + __u16 vlen, i;
> > +
> > + if (!t || !btf_is_enum(t))
> > + continue;
> > + vlen = btf_vlen(t);
> > + e = btf_enum(t);
> > + for (i = 0; i < vlen; e++, i++) {
> > + const char *name = btf__name_by_offset(btf, e->name_off);
> > +
> > + if (!name || strcmp(name, "BTF_KIND_MAX"))
> > + continue;
> > + dwarves__set_btf_kind_max(conf_load, e->val);
> > + return;
> > + }
> > + }
> > +}
> > diff --git a/btf_encoder.h b/btf_encoder.h
> > index 34516bb..e5e12ef 100644
> > --- a/btf_encoder.h
> > +++ b/btf_encoder.h
> > @@ -27,4 +27,6 @@ struct btf *btf_encoder__btf(struct btf_encoder *encoder);
> >
> > int btf_encoder__add_encoder(struct btf_encoder *encoder, struct btf_encoder *other);
> >
> > +void btf__set_btf_kind_max(struct conf_load *conf_load, struct btf *btf);
> > +
> > #endif /* _BTF_ENCODER_H_ */
> > diff --git a/pahole.c b/pahole.c
> > index aca2704..4d6d059 100644
> > --- a/pahole.c
> > +++ b/pahole.c
> > @@ -3470,6 +3470,7 @@ int main(int argc, char *argv[])
> > base_btf_file, libbpf_get_error(conf_load.base_btf));
> > goto out;
> > }
> > + btf__set_btf_kind_max(&conf_load, conf_load.base_btf);
> > if (!btf_encode && !ctf_encode) {
> > // Force "btf" since a btf_base is being informed
> > conf_load.format_path = "btf";
> > @@ -3513,6 +3514,7 @@ try_sole_arg_as_class_names:
> > base_btf_file, libbpf_get_error(conf_load.base_btf));
> > goto out;
> > }
> > + btf__set_btf_kind_max(&conf_load, conf_load.base_btf);
> > }
> > }
> >
next prev parent reply other threads:[~2023-09-13 16:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 14:26 [PATCH dwarves 0/3] dwarves: detect BTF kinds supported by kernel Alan Maguire
2023-09-13 14:26 ` [PATCH dwarves 1/3] dwarves: auto-detect maximum kind supported by vmlinux Alan Maguire
2023-09-13 16:58 ` Eduard Zingerman
2023-09-13 17:44 ` Alan Maguire
2023-09-13 14:26 ` [PATCH dwarves 2/3] pahole: add --skip_autodetect_btf_kind_max to disable kind autodetect Alan Maguire
2023-09-13 14:26 ` [PATCH dwarves 3/3] btf_encoder: learn BTF_KIND_MAX value from base BTF when generating split BTF Alan Maguire
2023-09-13 16:58 ` Eduard Zingerman [this message]
2023-09-13 16:58 ` [PATCH dwarves 0/3] dwarves: detect BTF kinds supported by kernel Eduard Zingerman
2023-09-14 17:58 ` Andrii Nakryiko
2023-09-19 16:30 ` Alan Maguire
2023-09-19 18:58 ` Andrii Nakryiko
2023-10-11 9:27 ` Alan Maguire
2023-10-13 0:22 ` Andrii Nakryiko
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=8f91f140d779625e47f425958e186bf255f26b19.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--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