Re: [PATCH 24/24] perf record: Add --buildid-mmap option to enable mmap's build id

From: Namhyung Kim
Date: Fri Nov 13 2020 - 19:32:30 EST


On Fri, Nov 13, 2020 at 8:09 PM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Fri, Nov 13, 2020 at 01:40:00PM +0900, Namhyung Kim wrote:
> > On Mon, Nov 09, 2020 at 10:54:15PM +0100, Jiri Olsa wrote:
> > > Adding --buildid-mmap option to enable build id in mmap2 events.
> > > It will only work if there's kernel support for that and it disables
> > > build id cache (implies --no-buildid).
> > >
> > > It's also possible to enable it permanently via config option
> > > in ~.perfconfig file:
> > >
> > > [record]
> > > build-id=mmap
> >
> > You also need to update the documentation.
>
> right, forgot doc for the config option
>
> SNIP
>
> > > "append timestamp to output filename"),
> > > OPT_BOOLEAN(0, "timestamp-boundary", &record.timestamp_boundary,
> > > @@ -2657,6 +2662,21 @@ int cmd_record(int argc, const char **argv)
> > >
> > > }
> > >
> > > + if (rec->buildid_mmap) {
> > > + if (!perf_can_record_build_id()) {
> > > + pr_err("Failed: no support to record build id in mmap events, update your kernel.\n");
> > > + err = -EINVAL;
> > > + goto out_opts;
> > > + }
> > > + pr_debug("Enabling build id in mmap2 events.\n");
> > > + /* Enable mmap build id synthesizing. */
> > > + symbol_conf.buildid_mmap2 = true;
> > > + /* Enable perf_event_attr::build_id bit. */
> > > + rec->opts.build_id = true;
> > > + /* Disable build id cache. */
> > > + rec->no_buildid = true;
> >
> > I'm afraid this can make it miss some build-id in the end because of
> > the possibility of the failure.
>
> with following fix (already merged):
> b33164f2bd1c bpf: Iterate through all PT_NOTE sections when looking for build id
>
> I could see high rate of build id being retrieved
>
> I'll make new numbers for next version, but I think we can neglect
> the failure, considering that we pick only 'hit' objects out of all
> of them
>
> also enabling the build id cache for this would go against the
> purpose why I'd like to have this.. so hopefuly the numbers
> will be convincing ;-)

Yeah, I think it'd be ok for most cases but we cannot guarantee..
What about checking the dso list at the end of a record session
and check all of them having build-id? Then we can safely skip
the build-id collecting stage. Hmm.. but it won't work for the pipe.

Thanks,
Namhyung