[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D919D5EE-2447-4B2F-B343-9F24B69FAB26@fb.com>
Date: Mon, 2 Mar 2020 16:52:15 +0000
From: Song Liu <songliubraving@...com>
To: Quentin Monnet <quentin@...valent.com>, Yonghong Song <yhs@...com>
CC: Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
"Kernel Team" <Kernel-team@...com>,
"ast@...nel.org" <ast@...nel.org>,
"daniel@...earbox.net" <daniel@...earbox.net>,
"arnaldo.melo@...il.com" <arnaldo.melo@...il.com>,
"jolsa@...nel.org" <jolsa@...nel.org>
Subject: Re: [PATCH v2 bpf-next 1/2] bpftool: introduce "prog profile" command
> On Mar 2, 2020, at 5:36 AM, Quentin Monnet <quentin@...valent.com> wrote:
>
> Hi Song,
>
> Thanks for this work! Some remarks (mostly nitpicks) inline.
>
> 2020-02-28 15:40 UTC-0800 ~ Song Liu <songliubraving@...com>
>> 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 3 id 337 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.
>>
>> Signed-off-by: Song Liu <songliubraving@...com>
>> ---
Thanks Yonghong and Quentin! I will fix these and send v3.
Song
Powered by blists - more mailing lists