Re: [PATCH 2/4] perf record: Enable off-cpu analysis with BPF

From: Namhyung Kim
Date: Fri Apr 29 2022 - 13:28:53 EST


Hi Hao,

On Wed, Apr 27, 2022 at 4:07 PM Hao Luo <haoluo@xxxxxxxxxx> wrote:
>
> Hi Namhyung,
>
> On Fri, Apr 22, 2022 at 8:05 AM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> >
>
> [...]
>
> >
> > Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> > ---
> > tools/perf/Makefile.perf | 1 +
> > tools/perf/builtin-record.c | 21 +++
> > tools/perf/util/Build | 1 +
> > tools/perf/util/bpf_off_cpu.c | 208 +++++++++++++++++++++++++
> > tools/perf/util/bpf_skel/off_cpu.bpf.c | 137 ++++++++++++++++
> > tools/perf/util/off_cpu.h | 22 +++
> > 6 files changed, 390 insertions(+)
> > create mode 100644 tools/perf/util/bpf_off_cpu.c
> > create mode 100644 tools/perf/util/bpf_skel/off_cpu.bpf.c
> > create mode 100644 tools/perf/util/off_cpu.h
> >
>
> [...]
>
> > diff --git a/tools/perf/util/bpf_skel/off_cpu.bpf.c b/tools/perf/util/bpf_skel/off_cpu.bpf.c
> > new file mode 100644
> > index 000000000000..2bc6f7cc59ea
> > --- /dev/null
> > +++ b/tools/perf/util/bpf_skel/off_cpu.bpf.c
> >
> > +struct {
> > + __uint(type, BPF_MAP_TYPE_HASH);
> > + __uint(key_size, sizeof(__u32));
> > + __uint(value_size, sizeof(struct tstamp_data));
> > + __uint(max_entries, MAX_ENTRIES);
> > +} tstamp SEC(".maps");
>
> I think using task local storage for this tstamp would be more
> efficient. There is an example in
> tools/bpf/runqslower/runqslower.bpf.c

Right, will change in v2.

Thanks,
Namhyung