Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-20 Thread Peter Zijlstra
On Wed, Apr 21, 2021 at 03:37:11AM +0900, Namhyung Kim wrote: > On Tue, Apr 20, 2021 at 7:28 PM Peter Zijlstra wrote: > > You forgot NMI. > > Thanks for your explanation. Maybe I'm missing something but > this event is basically for counting and doesn't allow sampling. > Do you say it's affecte

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-20 Thread Namhyung Kim
Hi Peter, On Tue, Apr 20, 2021 at 7:28 PM Peter Zijlstra wrote: > > On Fri, Apr 16, 2021 at 06:49:09PM +0900, Namhyung Kim wrote: > > On Thu, Apr 15, 2021 at 11:51 PM Peter Zijlstra > > wrote: > > > > +static void perf_update_cgroup_node(struct perf_event *event, struct > > > > cgroup *cgrp) >

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-20 Thread Peter Zijlstra
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

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-20 Thread Peter Zijlstra
On Fri, Apr 16, 2021 at 06:49:09PM +0900, Namhyung Kim wrote: > On Thu, Apr 15, 2021 at 11:51 PM Peter Zijlstra wrote: > > > +static void perf_update_cgroup_node(struct perf_event *event, struct > > > cgroup *cgrp) > > > +{ > > > + u64 delta_count, delta_time_enabled, delta_time_running; > >

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-20 Thread Peter Zijlstra
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 o

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-20 Thread Stephane Eranian
Hi Peter, On Thu, Apr 15, 2021 at 7:51 AM Peter Zijlstra wrote: > > On Tue, Apr 13, 2021 at 08:53:36AM -0700, Namhyung Kim wrote: > > As we can run many jobs (in container) on a big machine, we want to > > measure each job's performance during the run. To do that, the > > perf_event can be assoc

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Peter Zijlstra
On Fri, Apr 16, 2021 at 09:19:08PM +0900, Namhyung Kim wrote: > > Are you actually using mmap() to read? I had a proposal for FORMAT_GROUP > > like thing for mmap(), but I never implemented that (didn't get the > > enthousiatic response I thought it would). But yeah, there's nowhere > > near enough

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Namhyung Kim
On Fri, Apr 16, 2021 at 8:59 PM Peter Zijlstra wrote: > > On Fri, Apr 16, 2021 at 08:22:38PM +0900, Namhyung Kim wrote: > > On Fri, Apr 16, 2021 at 7:28 PM Peter Zijlstra wrote: > > > > > > On Fri, Apr 16, 2021 at 11:29:30AM +0200, Peter Zijlstra wrote: > > > > > > > > So I think we've had propos

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Peter Zijlstra
On Fri, Apr 16, 2021 at 08:22:38PM +0900, Namhyung Kim wrote: > On Fri, Apr 16, 2021 at 7:28 PM Peter Zijlstra wrote: > > > > On Fri, Apr 16, 2021 at 11:29:30AM +0200, Peter Zijlstra wrote: > > > > > > So I think we've had proposals for being able to close fds in the past; > > > > while preserving

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Namhyung Kim
On Fri, Apr 16, 2021 at 7:28 PM Peter Zijlstra wrote: > > On Fri, Apr 16, 2021 at 11:29:30AM +0200, Peter Zijlstra wrote: > > > > So I think we've had proposals for being able to close fds in the past; > > > while preserving groups etc. We've always pushed back on that because of > > > the resourc

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Peter Zijlstra
On Fri, Apr 16, 2021 at 11:29:30AM +0200, Peter Zijlstra wrote: > > So I think we've had proposals for being able to close fds in the past; > > while preserving groups etc. We've always pushed back on that because of > > the resource limit issue. By having each counter be a filedesc we get a > > n

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Namhyung Kim
On Fri, Apr 16, 2021 at 6:29 PM Peter Zijlstra wrote: > > > Duh.. this is a half-finished email I meant to save for later. Anyway, > I'll reply more. Nevermind, and thanks for your time! :-) Namhyung

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Namhyung Kim
On Fri, Apr 16, 2021 at 6:27 PM Peter Zijlstra wrote: > > On Fri, Apr 16, 2021 at 08:48:12AM +0900, Namhyung Kim wrote: > > On Thu, Apr 15, 2021 at 11:51 PM Peter Zijlstra > > wrote: > > > On Tue, Apr 13, 2021 at 08:53:36AM -0700, Namhyung Kim wrote: > > > > > cgroup event counting (i.e. perf st

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Namhyung Kim
On Thu, Apr 15, 2021 at 11:51 PM Peter Zijlstra wrote: > Lots of random comments below. > > > This attaches all cgroups in a single syscall and I didn't add the > > DETACH command deliberately to make the implementation simple. The > > attached cgroup nodes would be deleted when the file descript

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Peter Zijlstra
Duh.. this is a half-finished email I meant to save for later. Anyway, I'll reply more. On Fri, Apr 16, 2021 at 11:26:39AM +0200, Peter Zijlstra wrote: > On Fri, Apr 16, 2021 at 08:48:12AM +0900, Namhyung Kim wrote: > > On Thu, Apr 15, 2021 at 11:51 PM Peter Zijlstra > > wrote: > > > On Tue, A

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-16 Thread Peter Zijlstra
On Fri, Apr 16, 2021 at 08:48:12AM +0900, Namhyung Kim wrote: > On Thu, Apr 15, 2021 at 11:51 PM Peter Zijlstra wrote: > > On Tue, Apr 13, 2021 at 08:53:36AM -0700, Namhyung Kim wrote: > > > cgroup event counting (i.e. perf stat). > > > > > > * PERF_EVENT_IOC_ATTACH_CGROUP - it takes a buffer co

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-15 Thread Namhyung Kim
Hi Peter, Thanks for your review! On Thu, Apr 15, 2021 at 11:51 PM Peter Zijlstra wrote: > > On Tue, Apr 13, 2021 at 08:53:36AM -0700, Namhyung Kim wrote: > > As we can run many jobs (in container) on a big machine, we want to > > measure each job's performance during the run. To do that, the >

Re: [PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-15 Thread Peter Zijlstra
On Tue, Apr 13, 2021 at 08:53:36AM -0700, Namhyung Kim wrote: > As we can run many jobs (in container) on a big machine, we want to > measure each job's performance during the run. To do that, the > perf_event can be associated to a cgroup to measure it only. > > However such cgroup events need t

[PATCH v3 1/2] perf/core: Share an event with multiple cgroups

2021-04-13 Thread Namhyung Kim
As we can run many jobs (in container) on a big machine, we want to measure each job's performance during the run. To do that, the perf_event can be associated to a cgroup to measure it only. However such cgroup events need to be opened separately and it causes significant overhead in event multi