Re: [PATCH v6 2/4] perf: support build BPF skeletons with perf

From: Arnaldo Carvalho de Melo
Date: Tue Dec 29 2020 - 13:17:10 EST


Em Tue, Dec 29, 2020 at 05:14:12PM +0000, Song Liu escreveu:
> > On Dec 29, 2020, at 3:48 AM, Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:

> > Em Tue, Dec 29, 2020 at 04:01:41PM +0900, Namhyung Kim escreveu:
> >> On Tue, Dec 29, 2020 at 2:41 AM Song Liu <songliubraving@xxxxxx> wrote:
> >>> BPF programs are useful in perf to profile BPF programs. BPF skeleton is

> >> I'm having difficulties understanding the first sentence - looks like a
> >> recursion. :) So do you want to use two (or more) BPF programs?

> > Yeah, we use perf to perf perf, so we need to use bpf with perf to perf
> > bpf :-)

> > Look at tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c, the BPF
> > skeleton used to create the in-kernel scaffold to profile BPF programs.

> > It uses two BPF programs (fentry/XXX and fexit/XXX) and some a
s/some//
> > PERF_EVENT_ARRAY map and an array to diff counters read at exit from
> > counters read at exit of the profiled BPF programs and then accumulate
s/exit/entry/
> > those diffs in another PERCPU_ARRAY.

> > This all ends up composing a "BPF PMU" that is what the userspace perf
> > tooling will read (from "accum_readings" BPF map) and 'perf stat' will
> > consume as if reading from an "old style perf counter" :-)

> > Song, did I get it right? :-)

> Thanks Arnaldo! I don't think anyone can explain it better. :-)

There, a patch :-)

- Arnaldo