From: Yonghong Song <yhs@fb•com>
To: <peterz@infradead•org>, <rostedt@goodmis•org>, <ast@fb•com>,
<daniel@iogearbox•net>, <netdev@vger•kernel.org>
Cc: <kernel-team@fb•com>
Subject: [PATCH net-next 0/4] bpf: add two helpers to read perf event enabled/running time
Date: Fri, 1 Sep 2017 09:53:53 -0700 [thread overview]
Message-ID: <20170901165357.465121-1-yhs@fb.com> (raw)
Hardware pmu counters are limited resources. When there are more
pmu based perf events opened than available counters, kernel will
multiplex these events so each event gets certain percentage
(but not 100%) of the pmu time. In case that multiplexing happens,
the number of samples or counter value will not reflect the
case compared to no multiplexing. This makes comparison between
different runs difficult.
Typically, the number of samples or counter value should be
normalized before comparing to other experiments. The typical
normalization is done like:
normalized_num_samples = num_samples * time_enabled / time_running
normalized_counter_value = counter_value * time_enabled / time_running
where time_enabled is the time enabled for event and time_running is
the time running for event since last normalization.
This patch set implements two helper functions.
The helper bpf_perf_read_counter_time reads counter/time_enabled/time_running
for perf event array map. The helper bpf_perf_prog_read_time read
time_enabled/time_running for bpf prog with type BPF_PROG_TYPE_PERF_EVENT.
Yonghong Song (4):
bpf: add helper bpf_perf_read_counter_time for perf event array map
bpf: add a test case for helper bpf_perf_read_counter_time
bpf: add helper bpf_perf_prog_read_time
bpf: add a test case for helper bpf_perf_prog_read_time
include/linux/perf_event.h | 3 ++
include/uapi/linux/bpf.h | 29 +++++++++++-
kernel/bpf/verifier.c | 4 +-
kernel/events/core.c | 3 +-
kernel/trace/bpf_trace.c | 73 +++++++++++++++++++++++++++++--
samples/bpf/trace_event_kern.c | 5 +++
samples/bpf/tracex6_kern.c | 26 +++++++++++
samples/bpf/tracex6_user.c | 13 +++++-
tools/testing/selftests/bpf/bpf_helpers.h | 7 +++
9 files changed, 155 insertions(+), 8 deletions(-)
--
2.9.5
next reply other threads:[~2017-09-01 16:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-01 16:53 Yonghong Song [this message]
2017-09-01 16:53 ` [PATCH net-next 1/4] bpf: add helper bpf_perf_read_counter_time for perf event array map Yonghong Song
2017-09-01 20:29 ` Alexei Starovoitov
2017-09-01 20:50 ` Peter Zijlstra
2017-09-01 21:01 ` Yonghong Song
2017-09-01 20:41 ` Peter Zijlstra
2017-09-01 16:53 ` [PATCH net-next 2/4] bpf: add a test case for helper bpf_perf_read_counter_time Yonghong Song
2017-09-01 16:53 ` [PATCH net-next 3/4] bpf: add helper bpf_perf_prog_read_time Yonghong Song
2017-09-01 16:53 ` [PATCH net-next 4/4] bpf: add a test case for " Yonghong Song
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=20170901165357.465121-1-yhs@fb.com \
--to=yhs@fb$(echo .)com \
--cc=ast@fb$(echo .)com \
--cc=daniel@iogearbox$(echo .)net \
--cc=kernel-team@fb$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=peterz@infradead$(echo .)org \
--cc=rostedt@goodmis$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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