Hello, This work is to make perf stat more scalable with a lot of cgroups.
Changes in v2) * use ____cacheline_aligned macro instead of the padding * enclose the cgroup node list initialization * add more comments * add Acked-by from Song Liu Currently we need to open a separate perf_event to count an event in a cgroup. For a big machine, this requires lots of events like 256 cpu x 8 events x 200 cgroups = 409600 events This is very wasteful and not scalable. In this case, the perf stat actually counts exactly same events for each cgroup. I think we can just use a single event to measure all cgroups running on that cpu. So I added new ioctl commands to add per-cgroup counters to an existing perf_event and to read the per-cgroup counters from the event. The per-cgroup counters are updated during the context switch if tasks' cgroups are different (and no need to change the HW PMU). It keeps the counters in a hash table with cgroup id as a key. With this change, average processing time of my internal test workload which runs tasks in a different cgroup and communicates by pipes dropped from 11.3 usec to 5.8 usec. Thanks, Namhyung Namhyung Kim (2): perf/core: Share an event with multiple cgroups perf/core: Support reading group events with shared cgroups include/linux/perf_event.h | 22 ++ include/uapi/linux/perf_event.h | 2 + kernel/events/core.c | 591 ++++++++++++++++++++++++++++++-- 3 files changed, 588 insertions(+), 27 deletions(-) -- 2.31.1.295.g9ea45b61b8-goog