lkml.org 
[lkml]   [2020]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/2] perf-stat: enable counting events for BPF programs
On Thu, Dec 10, 2020 at 12:15:16AM +0000, Song Liu wrote:
>
>
> > On Dec 9, 2020, at 9:03 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > On Tue, Dec 08, 2020 at 10:16:46AM -0800, Song Liu wrote:
> >> Introduce perf-stat -b option, which counts events for BPF programs, like:
> >>
> >> [root@localhost ~]# ~/perf stat -e ref-cycles,cycles -b 254 -I 1000
> >> 1.487903822 115,200 ref-cycles
> >> 1.487903822 86,012 cycles
> >> 2.489147029 80,560 ref-cycles
> >> 2.489147029 73,784 cycles
> >> 3.490341825 60,720 ref-cycles
> >> 3.490341825 37,797 cycles
> >> 4.491540887 37,120 ref-cycles
> >> 4.491540887 31,963 cycles
> >>
> >> The example above counts cycles and ref-cycles of BPF program of id 254.
> >> This is similar to bpftool-prog-profile command, but more flexible.
> >>
> >> perf-stat -b creates per-cpu perf_event and loads fentry/fexit BPF
> >> programs (monitor-progs) to the target BPF program (target-prog). The
> >> monitor-progs read perf_event before and after the target-prog, and
> >> aggregate the difference in a BPF map. Then the user space reads data
> >> from these maps.
> >>
> >> A new struct bpf_counter is introduced to provide common interface that
> >> uses BPF programs/maps to count perf events.
> >>
> >> Signed-off-by: Song Liu <songliubraving@fb.com>
> >
> > I'm getting this at the end of the compilation:
> >
> > LINK perf
> > rm /home/jolsa/linux-perf/tools/perf/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o
> >
> > I guess we can keep it or make it silent somehow
>
> I also noticed this, but haven't figured out how to silent it. I guess
> we can fix it out later.

I think this might do it:

.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o

SNIP

> >> tools/perf/util/evsel.c | 11 +
> >> tools/perf/util/evsel.h | 6 +
> >> tools/perf/util/stat-display.c | 4 +-
> >> tools/perf/util/target.c | 34 +-
> >> tools/perf/util/target.h | 10 +
> >> 11 files changed, 591 insertions(+), 17 deletions(-)
> >> create mode 100644 tools/perf/util/bpf_counter.c
> >> create mode 100644 tools/perf/util/bpf_counter.h
> >> create mode 100644 tools/perf/util/bpf_skel/bpf_prog_profiler.bpf.c
> >
> > we need man page update, would be great with some example
>
> How about we do this in a follow up patch?

sry, we need to add man changes with new option

thanks,
jirka

\
 
 \ /
  Last update: 2020-12-13 23:37    [W:0.052 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site