From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@redhat.com>, Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>,
Song Liu <songliubraving@fb.com>, Tejun Heo <tj@kernel.org>,
kernel test robot <lkp@intel.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups
Date: Tue, 20 Apr 2021 13:28:33 +0200 [thread overview]
Message-ID: <YH664QumxBAIyYpt@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CABPqkBTncWfeFWY=kYXTAr3gRjpyFVL-YJN4K1YOPpHO35PHBw@mail.gmail.com>
On Tue, Apr 20, 2021 at 01:34:40AM -0700, Stephane Eranian wrote:
> The sampling approach will certainly incur more overhead and be at
> risk of losing the ability to reconstruct the total counter
> per-cgroup, unless you set the period for SW_CGROUP_SWITCHES to 1.
> But then, you run the risk of losing samples if the buffer is full or
> sampling is throtlled. In some scenarios, we believe the number of
> context switches between cgroup could be quite high (>> 1000/s). And
> on top you would have to add the processing of the samples to extract
> the counts per cgroup. That would require a synthesis on cgroup on
> perf record and some post-processing on perf report. We are interested
> in using the data live to make some policy decisions, so a counting
> approach with perf stat will always be best.
>
> The fundamental problem Namhyung is trying to solve is the following:
>
> num_fds = num_cpus x num_events x num_cgroups
>
> On an 256-CPU AMD server running 200 cgroups with 6 events/cgroup (as
> an example):
>
> num_fds = 256 x 200 x 6 = 307,200 fds (with all the kernel memory
> associated with them).
So the PERCPU proposal would reduce that to 200 * 6 = 1200 fds, which is
a definite win.
> On each CPU, that implies: 200 x 6 = 1200
> events to schedule and 6 to find on each cgroup switch
Right, so here we could optimize; if we find the event-groups are
identical in composition we can probably frob something that swizzles
the counts around without touching the PMU. That would be very similar
to what we already have in perf_event_context_sched_out().
This gets a wee bit tricky when you consider cgroup hierarchy though;
suppose you have:
R
/ \
A B
/ \
C D
And are monitoring both B and D, then you'll end up with 12 counters
active instead of the 6. I'm not sure how to make that go away. 'Don't
do that then' might be good enough.
> This does not scale for us:
> - run against the fd limit, but also memory consumption in the
> kernel per struct file, struct inode, struct perf_event ....
> - number of events per-cpu is still also large
> - require event scheduling on cgroup switches, even with RB-tree
> improvements, still heavy
> - require event scheduling even if measuring the same events across
> all cgroups
>
> One factor in that equation above needs to disappear. The one counter
> per file descriptor is respected with Nahmyung's patch because he is
> operating a plain per-cpu mode. What changes is just how and where the
> count is accumulated in perf_events. The resulting programming on the
> hardware is the same as before.
Yes, you're aggregating differently. And that's exactly the problem. The
aggregation is a variable one with fairly poor semantics. Suppose you
create a new cgroup, then you have to tear down and recreate the whole
thing, which is pretty crap.
Ftrace had a similar issue; where people wanted aggregation, and that
resulted in the event histogram, which, quite frankla,y is a scary
monster that I've no intention of duplicating. That's half a programming
language implemented.
> As you point out, the difficulty is how to express the cgroups of
> interest and how to read the counts back. I agree that the ioctl() is
> not ideal for the latter. For the former, if you do not want ioctl()
> then you would have to overload perf_event_open() with a vector of
> cgroup fd, for instance. As for the read, you could, as you suggest,
> use the read syscall if you want to read all the cgroups at once using
> a new read_format. I don't have a problem with that. As for cgroup-id
> vs. cgroup-fd, I think you make a fair point about consistency with
> the existing approach. I don't have a problem with that either
So that is a problem of aggregation; which is basically a
programmability problem. You're asking for a variadic-fixed-function
now, but tomorrow someone else will come and want another one.
next prev parent reply other threads:[~2021-04-20 11:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=YH664QumxBAIyYpt@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=songliubraving@fb.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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