netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v6 0/4] bpf: add two helpers to read perf event enabled/running time
@ 2017-10-02 22:42 Yonghong Song
  2017-10-02 22:42 ` [PATCH net-next v6 1/4] bpf: add helper bpf_perf_event_read_value for perf event array map Yonghong Song
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Yonghong Song @ 2017-10-02 22:42 UTC (permalink / raw)
  To: peterz, rostedt, ast, daniel, netdev; +Cc: kernel-team

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_event_read_value reads counter/time_enabled/time_running
for perf event array map. The helper bpf_perf_prog_read_value read
counter/time_enabled/time_running for bpf prog with type BPF_PROG_TYPE_PERF_EVENT.

[Dave, Peter,

 Previous communcation shows that this patch may potentially have
 merge conflict with upcoming tip changes in the next merge window.

 Could you advise how this patch should proceed?

 Thanks!
]

Changelogs:
v5->v6:
  . rebase on top of net-next
v4->v5:
  . fix some coding style issues
  . memset the input buffer in case of error for ARG_PTR_TO_UNINIT_MEM
    type of argument.
v3->v4:
  . fix a build failure
v2->v3:
  . counters should be read in order to read enabled/running time. This is to
    prevent that counters and enabled/running time may be read separately.
v1->v2:
  . reading enabled/running time should be together with reading counters
    which contains the logic to ensure the result is valid.

Yonghong Song (4):
  bpf: add helper bpf_perf_event_read_value for perf event array map
  bpf: add a test case for helper bpf_perf_event_read_value
  bpf: add helper bpf_perf_prog_read_value
  bpf: add a test case for helper bpf_perf_prog_read_value

 include/linux/perf_event.h                |  7 ++-
 include/uapi/linux/bpf.h                  | 28 +++++++++++-
 kernel/bpf/arraymap.c                     |  2 +-
 kernel/bpf/verifier.c                     |  4 +-
 kernel/events/core.c                      | 16 +++++--
 kernel/trace/bpf_trace.c                  | 74 ++++++++++++++++++++++++++++---
 samples/bpf/trace_event_kern.c            | 10 +++++
 samples/bpf/trace_event_user.c            | 13 +++---
 samples/bpf/tracex6_kern.c                | 26 +++++++++++
 samples/bpf/tracex6_user.c                | 13 +++++-
 tools/include/uapi/linux/bpf.h            |  4 +-
 tools/testing/selftests/bpf/bpf_helpers.h |  6 +++
 12 files changed, 182 insertions(+), 21 deletions(-)

-- 
2.9.5

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-10-05 10:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-02 22:42 [PATCH net-next v6 0/4] bpf: add two helpers to read perf event enabled/running time Yonghong Song
2017-10-02 22:42 ` [PATCH net-next v6 1/4] bpf: add helper bpf_perf_event_read_value for perf event array map Yonghong Song
2017-10-02 22:42 ` [PATCH net-next v6 2/4] bpf: add a test case for helper bpf_perf_event_read_value Yonghong Song
2017-10-02 22:42 ` [PATCH net-next v6 3/4] bpf: add helper bpf_perf_prog_read_value Yonghong Song
2017-10-02 22:42 ` [PATCH net-next v6 4/4] bpf: add a test case for " Yonghong Song
2017-10-04 23:00 ` [PATCH net-next v6 0/4] bpf: add two helpers to read perf event enabled/running time David Miller
2017-10-05  8:34   ` Peter Zijlstra
2017-10-05 10:36     ` Daniel Borkmann

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).