From: Yonghong Song <yhs@fb.com>
To: Song Liu <songliubraving@fb.com>, <netdev@vger.kernel.org>,
<bpf@vger.kernel.org>
Cc: <quentin@isovalent.com>, <kernel-team@fb.com>, <ast@kernel.org>,
<daniel@iogearbox.net>, <arnaldo.melo@gmail.com>,
<jolsa@kernel.org>
Subject: Re: [PATCH v6 bpf-next 1/4] bpftool: introduce "prog profile" command
Date: Mon, 9 Mar 2020 15:53:41 -0700 [thread overview]
Message-ID: <9d3f763c-af59-472e-a57e-57fe61da2799@fb.com> (raw)
In-Reply-To: <20200309173218.2739965-2-songliubraving@fb.com>
On 3/9/20 10:32 AM, 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%)
>
> This command measures cycles and instructions for BPF program with id
> 337 for 3 seconds. The program has triggered 4228 times. The rest of the
> output is similar to perf-stat. In this example, the counters were only
> counting ~84% of the time because of time multiplexing of perf counters.
>
> Note that, this approach measures cycles and instructions in very small
> increments. So the fentry/fexit programs introduce noticeable errors to
> the measurement results.
>
> The fentry/fexit programs are generated with BPF skeletons. Therefore, we
> build bpftool twice. The first time _bpftool is built without skeletons.
> Then, _bpftool is used to generate the skeletons. The second time, bpftool
> is built with skeletons.
>
> Reviewed-by: Quentin Monnet <quentin@isovalent.com>
> Signed-off-by: Song Liu <songliubraving@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
next prev parent reply other threads:[~2020-03-09 22:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 17:32 [PATCH v6 bpf-next 0/4] bpftool: introduce prog profile Song Liu
2020-03-09 17:32 ` [PATCH v6 bpf-next 1/4] bpftool: introduce "prog profile" command Song Liu
2020-03-09 22:53 ` Yonghong Song [this message]
2020-03-09 17:32 ` [PATCH v6 bpf-next 2/4] bpftool: Documentation for bpftool prog profile Song Liu
2020-03-09 17:32 ` [PATCH v6 bpf-next 3/4] ybpftool: bash completion for "bpftool prog profile" Song Liu
2020-03-09 17:32 ` [PATCH v6 bpf-next 4/4] bpftool: fix typo in bash-completion Song Liu
2020-03-09 23:06 ` [PATCH v6 bpf-next 0/4] bpftool: introduce prog profile Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9d3f763c-af59-472e-a57e-57fe61da2799@fb.com \
--to=yhs@fb.com \
--cc=arnaldo.melo@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=quentin@isovalent.com \
--cc=songliubraving@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).