Re: [RFC PATCH 0/2] perf_events: add support for per-cpu per-cgroupmonitoring (v3)

From: Stephane Eranian
Date: Tue Sep 21 2010 - 12:18:12 EST


On Tue, Sep 21, 2010 at 4:03 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Tue, 2010-09-21 at 15:38 +0200, Stephane Eranian wrote:
>> > Hmm, indeed. One thing we can do about that is move perf into the
>> > cgroup, create the counter (disabled) using self to identify the cgroup,
>> > move perf back to where it came from, and enable the counter.
>> >
>> Yes, that's another possibility. I wonder if there are any non-obvious
>> difficulties with this approach.
>
> Yes, there is, but I think we can fix it. The problem with moving perf
> itself around is that perf is not a fully dormant process and can thus
> interact with the cgroup state.
>
I was thinking about memory accounting for instance.

> If we were to fork a child that's simply sitting idle in waitpid() (or
> any other blocking syscall) we can move that around cgroup without
> affecting the cgroup itself.

But then things get a bit more complicated because the perf_event_open()
has to be done in that child. File descriptors created in child processes
and not shared with their parent. You'd have to pass file descriptors around.
That seems overly complicated.

I wonder if overloading pid to be a file descriptor open to a cgroup_fs file
would not be easier in the end.


>> ÂIs it as simple as:
>> Â ÂFILE *fp;
>> Â Âfp = fopen("/dev/cgroup/test/tasks", "w");
>> Â Âfprintf(fp, "%d", gettid());
>> Â Âclose(fp):
>
> Except I've never in my life mounted a cgroup filesystem in /dev/ :-)
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/