On Thu, Dec 10, 2020 at 12:15:16AM +0000, Song Liu wrote:
> 
> 
> > On Dec 9, 2020, at 9:03 AM, Jiri Olsa <jo...@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 <songliubrav...@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

Reply via email to