linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET v4 0/4] perf stat: Enable BPF counters with --for-each-cgroup
@ 2021-06-25  7:18 Namhyung Kim
  2021-06-25  7:18 ` [PATCH 1/4] perf tools: Add read_cgroup_id() function Namhyung Kim
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Namhyung Kim @ 2021-06-25  7:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Andi Kleen, Ian Rogers,
	Stephane Eranian, Song Liu

Hello,

This is to add BPF support for --for-each-cgroup to handle many cgroup
events on big machines.  You can use the --bpf-counters to enable the
new behavior.

 * changes in v4
  - convert cgrp_readings to a per-cpu array map
  - remove now-unused cpu_idx map
  - move common functions to a header file
  - reuse bpftool bootstrap binary
  - fix build error in the cgroup code
  
 * changes in v3
  - support cgroup hierarchy with ancestor ids
  - add and trigger raw_tp BPF program
  - add a build rule for vmlinux.h

 * changes in v2
  - remove incorrect use of BPF_F_PRESERVE_ELEMS
  - add missing map elements after lookup
  - handle cgroup v1

Basic idea is to use a single set of per-cpu events to count
interested events and aggregate them to each cgroup.  I used bperf
mechanism to use a BPF program for cgroup-switches and save the
results in a matching map element for given cgroups.

Without this, we need to have separate events for cgroups, and it
creates unnecessary multiplexing overhead (and PMU programming) when
tasks in different cgroups are switched.  I saw this makes a big
difference on 256 cpu machines with hundreds of cgroups.

Actually this is what I wanted to do it in the kernel [1], but we can
do the job using BPF!


Thanks,
Namhyung


[1] https://lore.kernel.org/lkml/20210413155337.644993-1-namhyung@kernel.org/


Namhyung Kim (4):
  perf tools: Add read_cgroup_id() function
  perf tools: Add cgroup_is_v2() helper
  perf tools: Move common bpf functions to bpf_counter.h
  perf stat: Enable BPF counter with --for-each-cgroup

 tools/perf/Makefile.perf                    |  17 +-
 tools/perf/util/Build                       |   1 +
 tools/perf/util/bpf_counter.c               |  57 +---
 tools/perf/util/bpf_counter.h               |  52 ++++
 tools/perf/util/bpf_counter_cgroup.c        | 299 ++++++++++++++++++++
 tools/perf/util/bpf_skel/bperf_cgroup.bpf.c | 191 +++++++++++++
 tools/perf/util/cgroup.c                    |  46 +++
 tools/perf/util/cgroup.h                    |  12 +
 8 files changed, 622 insertions(+), 53 deletions(-)
 create mode 100644 tools/perf/util/bpf_counter_cgroup.c
 create mode 100644 tools/perf/util/bpf_skel/bperf_cgroup.bpf.c

-- 
2.32.0.93.g670b81a890-goog


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

end of thread, other threads:[~2021-07-01 20:16 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25  7:18 [PATCHSET v4 0/4] perf stat: Enable BPF counters with --for-each-cgroup Namhyung Kim
2021-06-25  7:18 ` [PATCH 1/4] perf tools: Add read_cgroup_id() function Namhyung Kim
2021-07-01 17:59   ` Arnaldo Carvalho de Melo
2021-06-25  7:18 ` [PATCH 2/4] perf tools: Add cgroup_is_v2() helper Namhyung Kim
2021-06-29 15:51   ` Ian Rogers
2021-06-30  6:35     ` Namhyung Kim
2021-06-30 18:43       ` Arnaldo Carvalho de Melo
2021-06-25  7:18 ` [PATCH 3/4] perf tools: Move common bpf functions to bpf_counter.h Namhyung Kim
2021-06-30 18:28   ` Song Liu
2021-07-01 19:09   ` Arnaldo Carvalho de Melo
2021-07-01 20:11     ` Namhyung Kim
2021-06-25  7:18 ` [PATCH 4/4] perf stat: Enable BPF counter with --for-each-cgroup Namhyung Kim
2021-06-30 18:47   ` Song Liu
2021-06-30 20:09     ` Namhyung Kim
2021-07-01 20:16       ` Namhyung Kim
2021-06-30 18:50   ` Arnaldo Carvalho de Melo
2021-06-30 20:12     ` Namhyung Kim
2021-07-01 13:43     ` Arnaldo Carvalho de Melo
2021-07-01 17:10       ` Namhyung Kim
2021-06-27 15:29 ` [PATCHSET v4 0/4] perf stat: Enable BPF counters " Namhyung Kim
2021-06-30  6:19   ` Namhyung Kim

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