BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
	daniel@iogearbox.net, kernel-team@fb.com, yhs@fb.com
Subject: Re: [PATCH bpf-next v3 1/3] libbpf: __attribute__((btf_decl_tag("..."))) for btf dump in C format
Date: Fri, 11 Nov 2022 23:30:03 +0200	[thread overview]
Message-ID: <3d638bd465fb604ef01c1dc5a5a92617b90482d8.camel@gmail.com> (raw)
In-Reply-To: <CAEf4Bzbnd2UOT9Mko+0Yf9Kgsn-sGsV43MKExYjEaYbWg0WgZg@mail.gmail.com>

On Fri, 2022-11-11 at 10:58 -0800, Andrii Nakryiko wrote:
> On Thu, Nov 10, 2022 at 6:43 AM Eduard Zingerman <eddyz87@gmail.com> wrote:
> 
> 
> [...]
> 
> >  static int btf_dump_push_decl_stack_id(struct btf_dump *d, __u32 id)
> > @@ -1438,9 +1593,12 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,
> >                 }
> >                 case BTF_KIND_FUNC_PROTO: {
> >                         const struct btf_param *p = btf_params(t);
> > +                       struct decl_tag_array *decl_tags = NULL;
> >                         __u16 vlen = btf_vlen(t);
> >                         int i;
> > 
> > +                       hashmap__find(d->decl_tags, id, &decl_tags);
> > +
> >                         /*
> >                          * GCC emits extra volatile qualifier for
> >                          * __attribute__((noreturn)) function pointers. Clang
> 
> should there be btf_dump_emit_decl_tags(d, decl_tags, -1) somewhere
> here to emit tags of FUNC_PROTO itself?

Actually, I have not found a way to attach decl tag to a FUNC_PROTO itself:

  typedef void (*fn)(void) __decl_tag("..."); // here tag is attached to typedef
  struct foo {
    void (*fn)(void) __decl_tag("..."); // here tag is attached to a foo.fn field
  }
  void foo(void (*fn)(void) __decl_tag("...")); // here tag is attached to FUNC foo
                                                // parameter but should probably 
                                                // be attached to
                                                // FUNC_PROTO parameter instead.

Also, I think that Yonghong had reservations about decl tags attached to
FUNC_PROTO parameters.
Yonghong, could you please comment?

> 
> > @@ -1481,6 +1639,7 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,
> > 
> >                                 name = btf_name_of(d, p->name_off);
> >                                 btf_dump_emit_type_decl(d, p->type, name, lvl);
> > +                               btf_dump_emit_decl_tags(d, decl_tags, i);
> >                         }
> > 
> >                         btf_dump_printf(d, ")");
> > @@ -1896,6 +2055,7 @@ static int btf_dump_var_data(struct btf_dump *d,
> >                              const void *data)
> >  {
> >         enum btf_func_linkage linkage = btf_var(v)->linkage;
> > +       struct decl_tag_array *decl_tags = NULL;
> >         const struct btf_type *t;
> >         const char *l;
> >         __u32 type_id;
> > @@ -1920,7 +2080,10 @@ static int btf_dump_var_data(struct btf_dump *d,
> >         type_id = v->type;
> >         t = btf__type_by_id(d->btf, type_id);
> >         btf_dump_emit_type_cast(d, type_id, false);
> > -       btf_dump_printf(d, " %s = ", btf_name_of(d, v->name_off));
> > +       btf_dump_printf(d, " %s", btf_name_of(d, v->name_off));
> > +       hashmap__find(d->decl_tags, id, &decl_tags);
> > +       btf_dump_emit_decl_tags(d, decl_tags, -1);
> > +       btf_dump_printf(d, " = ");
> >         return btf_dump_dump_type_data(d, NULL, t, type_id, data, 0, 0);
> >  }
> > 
> > @@ -2421,6 +2584,8 @@ int btf_dump__dump_type_data(struct btf_dump *d, __u32 id,
> >         d->typed_dump->skip_names = OPTS_GET(opts, skip_names, false);
> >         d->typed_dump->emit_zeroes = OPTS_GET(opts, emit_zeroes, false);
> > 
> > +       btf_dump_assign_decl_tags(d);
> > +
> 
> I'm actually not sure we want those tags on binary data dump.
> Generally data dump is not type definition dump, so this seems
> unnecessary, it will just distract from data itself. Let's drop it for
> now? If there would be a need we can add it easily later.

Well, this is the only place where VARs are processed, removing this code
would make the second patch in a series useless.
But I like my second patch in a series :) should I just drop it?
I can extract it as a separate series and simplify some of the existing
data dump tests.

> 
> >         ret = btf_dump_dump_type_data(d, NULL, t, id, data, 0, 0);
> > 
> >         d->typed_dump = NULL;
> > --
> > 2.34.1
> > 


  reply	other threads:[~2022-11-11 21:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 14:43 [PATCH bpf-next v3 0/3] libbpf: btf_decl_tag attribute for btf dump in C format Eduard Zingerman
2022-11-10 14:43 ` [PATCH bpf-next v3 1/3] libbpf: __attribute__((btf_decl_tag("..."))) " Eduard Zingerman
2022-11-11 18:58   ` Andrii Nakryiko
2022-11-11 21:30     ` Eduard Zingerman [this message]
2022-11-14 19:56       ` Andrii Nakryiko
2022-11-16  1:51         ` Eduard Zingerman
2022-11-18  0:21           ` Andrii Nakryiko
2022-11-15 20:45       ` Yonghong Song
2022-11-15 20:48         ` Yonghong Song
2022-11-10 14:43 ` [PATCH bpf-next v3 2/3] selftests/bpf: Dump data sections as part of btf_dump_test_case tests Eduard Zingerman
2022-11-11 19:07   ` Andrii Nakryiko
2022-11-10 14:43 ` [PATCH bpf-next v3 3/3] selftests/bpf: Tests for BTF_KIND_DECL_TAG dump in C format Eduard Zingerman
2022-11-11 19:07   ` 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=3d638bd465fb604ef01c1dc5a5a92617b90482d8.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@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