All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	dwarves@vger.kernel.org, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andriin@fb.com>, Yonghong Song <yhs@fb.com>,
	Hao Luo <haoluo@google.com>, "Frank Ch. Eigler" <fche@redhat.com>,
	Mark Wielaard <mjw@redhat.com>
Subject: Re: [PATCH 2/2] btf_encoder: Change functions check due to broken dwarf
Date: Tue, 3 Nov 2020 20:05:59 +0100	[thread overview]
Message-ID: <20201103190559.GI3597846@krava> (raw)
In-Reply-To: <CAEf4BzbdGwogFQiLE2eH9ER67hne7NgW4S8miYBM4CRb8NDPvg@mail.gmail.com>

On Tue, Nov 03, 2020 at 10:58:58AM -0800, Andrii Nakryiko wrote:
> On Mon, Nov 2, 2020 at 2:57 PM Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > On Mon, Nov 02, 2020 at 10:59:08PM +0100, Jiri Olsa wrote:
> > > On Sat, Oct 31, 2020 at 11:31:31PM +0100, Jiri Olsa wrote:
> > > > We need to generate just single BTF instance for the
> > > > function, while DWARF data contains multiple instances
> > > > of DW_TAG_subprogram tag.
> > > >
> > > > Unfortunately we can no longer rely on DW_AT_declaration
> > > > tag (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97060)
> > > >
> > > > Instead we apply following checks:
> > > >   - argument names are defined for the function
> > > >   - there's symbol and address defined for the function
> > > >   - function is generated only once
> > > >
> > > > Also because we want to follow kernel's ftrace traceable
> > > > functions, this patchset is adding extra check that the
> > > > function is one of the ftrace's functions.
> > > >
> > > > All ftrace functions addresses are stored in vmlinux
> > > > binary within symbols:
> > > >   __start_mcount_loc
> > > >   __stop_mcount_loc
> > >
> > > hum, for some reason this does not pass through bpf internal
> > > functions like bpf_iter_bpf_map.. I learned it hard way ;-)
> 
> what's the exact name of the function that was missing?
> bpf_iter_bpf_map doesn't exist. And if it's __init function, why does
> it matter, it's not going to be even available at runtime, right?
> 

bpf_map iter definition:

DEFINE_BPF_ITER_FUNC(bpf_map, struct bpf_iter_meta *meta, struct bpf_map *map)

goes to:

#define DEFINE_BPF_ITER_FUNC(target, args...)                   \
        extern int bpf_iter_ ## target(args);                   \
        int __init bpf_iter_ ## target(args) { return 0; }

that creates __init bpf_iter_bpf_map function that will make
it into BTF where it's expected when opening iterator, but the
code will be freed because it's __init function

there are few iteratos functions like that, and I was going to
check if there's more

> 
> > > will check
> >
> > so it gets filtered out because it's __init function
> > I'll check if the fix below catches all internal functions,
> > but I guess we should do something more robust
> >
> > jirka
> >
> >
> > ---
> > diff --git a/btf_encoder.c b/btf_encoder.c
> > index 0a378aa92142..3cd94280c35b 100644
> > --- a/btf_encoder.c
> > +++ b/btf_encoder.c
> > @@ -143,7 +143,8 @@ static int filter_functions(struct btf_elf *btfe, struct mcount_symbols *ms)
> >                 /* Do not enable .init section functions. */
> >                 if (init_filter &&
> >                     func->addr >= ms->init_begin &&
> > -                   func->addr <  ms->init_end)
> > +                   func->addr <  ms->init_end &&
> > +                   strncmp("bpf_", func->name, 4))
> 
> this looks like a very wrong way to do this? Can you please elaborate
> on what's missing and why it shouldn't be missing?

yes, it's just a hack, we should do something more
robust as I mentioned above

it just allowed me to use iterators finaly ;-)

jirka


  reply	other threads:[~2020-11-03 19:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31 22:31 [PATCHv2 0/2] pahole: Workaround dwarf bug for function encoding Jiri Olsa
2020-10-31 22:31 ` [PATCH 1/2] btf_encoder: Move find_all_percpu_vars in generic collect_symbols Jiri Olsa
2020-11-02 18:29   ` Hao Luo
2020-11-03 17:31     ` Arnaldo Carvalho de Melo
2020-10-31 22:31 ` [PATCH 2/2] btf_encoder: Change functions check due to broken dwarf Jiri Olsa
2020-11-02 21:59   ` Jiri Olsa
2020-11-02 22:56     ` Jiri Olsa
2020-11-03 18:58       ` Andrii Nakryiko
2020-11-03 19:05         ` Jiri Olsa [this message]
2020-11-03 19:23           ` Andrii Nakryiko
2020-11-03 19:34             ` Jiri Olsa
2020-11-03 20:27             ` Yonghong Song
2020-11-03 23:18               ` Jiri Olsa
2020-11-03 18:55   ` Andrii Nakryiko
2020-11-03 23:22     ` Jiri Olsa

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=20201103190559.GI3597846@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=fche@redhat.com \
    --cc=haoluo@google.com \
    --cc=jolsa@kernel.org \
    --cc=mjw@redhat.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.