Re: [BUG] perf: intel_pt won't display kernel function

From: Arnaldo Carvalho de Melo
Date: Wed Apr 03 2019 - 14:51:00 EST


Em Wed, Apr 03, 2019 at 04:27:56PM +0000, Song Liu escreveu:
>
>
> > On Apr 3, 2019, at 8:15 AM, Arnaldo Carvalho de Melo <arnaldo.melo@xxxxxxxxx> wrote:
> >
> > Em Wed, Apr 03, 2019 at 11:53:53AM -0300, Arnaldo Carvalho de Melo escreveu:
> >> Em Wed, Apr 03, 2019 at 04:37:38PM +0200, Jiri Olsa escreveu:
> >>> hi,
> >>> perf script --call-trace stop working for me recently,
> >>> and displays only user space functions
> >>>
> >>> I bisected that to:
> >>> 7b612e291a5a perf tools: Synthesize PERF_RECORD_* for loaded BPF programs
> >>>
> >>> data from following comands will display user space functions only:
> >>> # perf-with-kcore record pt -e intel_pt// -- ls
> >>> # perf-with-kcore script pt --call-trace
> >>>
> >>> when I disable the bpf synthesizing (patch below), kernel functions are back
> >>>
> >>> I guess the new events mess up with intel_pt decoder somehow
> >>
> >> I.e. I'm adding the patch below to my perf/urgent branch.
> >
> > Song, that is what I have, can I have your Acked-by and please consider
> > taking a look at the bug Jiri reported,
> >
> > Thanks,
> >
> > - Arnaldo
>
> Current logic with --no-bpf-event is to generate PERF_RECORD_KSYMBOL, but not
> PERF_RECORD_BPF_EVENT:

I see... The opts is done later, after querying the kernel for existing
BPF programs so that at least the KSYMBOL ones can be generated. So I'll
keep it as is, no need for this patch.

> https://elixir.bootlin.com/linux/v5.1-rc3/source/tools/perf/util/bpf-event.c#L254
>
> I will look into the intel_pt problem.

Ok.

> In the meanwhile, let's fix it for now.

I'll wait a bit.

> Acked-by: Song Liu <songliubraving@xxxxxx>
>
> Thanks,
> Song
>
>
> > commit 011318ccc2024ba03e96c32a06f74ca5d6ab5503
> > Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> > Date: Wed Apr 3 12:05:15 2019 -0300
> >
> > perf record: Do not synthesize BPF records when --no-bpf-event is used
> >
> > By default we synthesize and ask the kernel for BPF events, having a
> > --no-bpf-event option to disable that, which can be useful, for
> > instance, if there are still bugs in that code, which seems to be the
> > case as reported by Jiri Olsa in:
> >
> > "[BUG] perf: intel_pt won't display kernel function"
> > 20190403143738.GB32001@krava">https://lore.kernel.org/lkml/20190403143738.GB32001@krava
> >
> > So add the check for record_opts.no_bpf_event when considering
> > synthesizing BPF events for pre-existing BPF programs in 'perf record'.
> >
> > The reported bug needs further analysis and is a separate matter.
> >
> > Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> > Cc: Alexei Starovoitov <ast@xxxxxxxxxx>
> > Cc: Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx>
> > Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
> > Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> > Cc: Martin KaFai Lau <kafai@xxxxxx>
> > Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: Song Liu <songliubraving@xxxxxx>
> > Cc: Yonghong Song <yhs@xxxxxx>
> > Fixes: 7b612e291a5a ("perf tools: Synthesize PERF_RECORD_* for loaded BPF programs")
> > Link: https://lore.kernel.org/lkml/20190403145353.GE32553@xxxxxxxxxx
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> >
> > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> > index 4e2d953d4bc5..17d772f192ad 100644
> > --- a/tools/perf/builtin-record.c
> > +++ b/tools/perf/builtin-record.c
> > @@ -1114,10 +1114,11 @@ static int record__synthesize(struct record *rec, bool tail)
> > return err;
> > }
> >
> > - err = perf_event__synthesize_bpf_events(session, process_synthesized_event,
> > - machine, opts);
> > - if (err < 0)
> > - pr_warning("Couldn't synthesize bpf events.\n");
> > + if (!opts->no_bpf_event) {
> > + err = perf_event__synthesize_bpf_events(session, process_synthesized_event, machine, opts);
> > + if (err < 0)
> > + pr_warning("Couldn't synthesize bpf events.\n");
> > + }
> >
> > err = __machine__synthesize_threads(machine, tool, &opts->target, rec->evlist->threads,
> > process_synthesized_event, opts->sample_address,

--

- Arnaldo