All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] perf core: Sharing events with multiple cgroups
@ 2021-04-13 15:53 Namhyung Kim
  2021-04-13 15:53 ` [PATCH v3 1/2] perf/core: Share an event " Namhyung Kim
  2021-04-13 15:53 ` [PATCH v3 2/2] perf/core: Support reading group events with shared cgroups Namhyung Kim
  0 siblings, 2 replies; 24+ messages in thread
From: Namhyung Kim @ 2021-04-13 15:53 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Jiri Olsa, Mark Rutland,
	Alexander Shishkin, LKML, Stephane Eranian, Andi Kleen,
	Ian Rogers, Song Liu

Hello,

This work is to make perf stat more scalable with a lot of cgroups.

Changes in V3)
 * fix build error when !CONFIG_CGROUP_PERF

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


*** BLURB HERE ***

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            | 594 ++++++++++++++++++++++++++++++--
 3 files changed, 591 insertions(+), 27 deletions(-)


base-commit: cface0326a6c2ae5c8f47bd466f07624b3e348a7
-- 
2.31.1.295.g9ea45b61b8-goog


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

end of thread, other threads:[~2021-05-09  7:14 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 15:53 [PATCH v3 0/2] perf core: Sharing events with multiple cgroups Namhyung Kim
2021-04-13 15:53 ` [PATCH v3 1/2] perf/core: Share an event " Namhyung Kim
2021-04-15 14:51   ` Peter Zijlstra
2021-04-15 23:48     ` Namhyung Kim
2021-04-16  9:26       ` Peter Zijlstra
2021-04-16  9:29         ` Peter Zijlstra
2021-04-16 10:19           ` Namhyung Kim
2021-04-16 10:27           ` Peter Zijlstra
2021-04-16 11:22             ` Namhyung Kim
2021-04-16 11:59               ` Peter Zijlstra
2021-04-16 12:19                 ` Namhyung Kim
2021-04-16 13:39                   ` Peter Zijlstra
2021-05-09  7:13                 ` Namhyung Kim
2021-04-16 10:18         ` Namhyung Kim
2021-04-16  9:49     ` Namhyung Kim
2021-04-20 10:28       ` Peter Zijlstra
2021-04-20 18:37         ` Namhyung Kim
2021-04-20 18:43           ` Peter Zijlstra
2021-04-20  8:34     ` Stephane Eranian
2021-04-20  9:48       ` Peter Zijlstra
2021-04-20 11:28       ` Peter Zijlstra
2021-04-21 19:37         ` Namhyung Kim
2021-05-03 21:53           ` Namhyung Kim
2021-04-13 15:53 ` [PATCH v3 2/2] perf/core: Support reading group events with shared cgroups Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.