[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200304192111.GB168640@krava>
Date: Wed, 4 Mar 2020 20:21:11 +0100
From: Jiri Olsa <jolsa@...hat.com>
To: Song Liu <songliubraving@...com>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org, quentin@...valent.com,
kernel-team@...com, ast@...nel.org, daniel@...earbox.net,
arnaldo.melo@...il.com, jolsa@...nel.org
Subject: Re: [PATCH v4 bpf-next 1/4] bpftool: introduce "prog profile" command
On Wed, Mar 04, 2020 at 10:07:07AM -0800, Song Liu wrote:
> With fentry/fexit programs, it is possible to profile BPF program with
> hardware counters. Introduce bpftool "prog profile", which measures key
> metrics of a BPF program.
>
> bpftool prog profile command creates per-cpu perf events. Then it attaches
> fentry/fexit programs to the target BPF program. The fentry program saves
> perf event value to a map. The fexit program reads the perf event again,
> and calculates the difference, which is the instructions/cycles used by
> the target program.
>
> Example input and output:
>
> ./bpftool prog profile id 337 duration 3 cycles instructions llc_misses
>
> 4228 run_cnt
> 3403698 cycles (84.08%)
> 3525294 instructions # 1.04 insn per cycle (84.05%)
> 13 llc_misses # 3.69 LLC misses per million isns (83.50%)
FYI I'm in the middle of moving perf's 'events parsing' interface to libperf,
which takes event name/s on input and returns list of perf_event_attr objects
parse_events("cycles") -> ready to use 'struct perf_event_attr'
You can use any event that's listed in 'perf list' command, which includes
also all vendor (Intel/Arm/ppc..) events. It might be useful extension for
this command.
jirka
Powered by blists - more mailing lists