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

From: Stephane Eranian
Date: Fri Oct 08 2010 - 04:36:21 EST


On Fri, Oct 8, 2010 at 2:46 AM, Li Zefan <lizf@xxxxxxxxxxxxxx> wrote:
>>>>> +#ifdef CONFIG_CGROUPS
>>>>> +struct perf_cgroup_time {
>>>>> + Â Â u64 time;
>>>>> + Â Â u64 timestamp;
>>>>> +};
>>>>> +
>>>>> +struct perf_cgroup {
>>>>> + Â Â struct cgroup_subsys_state css;
>>>>> + Â Â struct perf_cgroup_time *time;
>>>>> +};
>>>> Can we avoid adding this perf cgroup subsystem? It has 2 disavantages:
>>>>
>>> Well, I need to maintain some timing information for each cgroup. This has
>>> to be stored somewhere.
>>>
>
> Seems you can simply store it in struct perf_event?
>
No, timing has to be shared by events monitoring the same cgroup at
the same time.
Works like a timestamp. It needs to be centralized for all events
attached to the same
cgroup.

>>>> - If one mounted cgroup fs without perf cgroup subsys, he can't monitor it.
>>> That's unfortunately true ;-)
>>>
>>>> - If there are several different cgroup mount points, only one can be
>>>> Âmonitored.
>>>>
>>>> To choose which cgroup hierarchy to monitor, hierarchy id can be passed
>>>> from userspace, which is the 2nd column below:
>>>>
>>> Ok, I will investigate this. As long as the hierarchy id is unique AND it can be
>>> searched, then we can use it. Using /proc is fine with me.
>>>
>>>> $ cat /proc/cgroups
>>>> #subsys_name  Âhierarchy    num_cgroups   enabled
>>>> debug  0    1    1
>>>> net_cls 0 Â Â Â 1 Â Â Â 1
>>>>
>>
>> If I mount all subsystems:
>> mount -t cgroup none /dev/cgroup
>> Then, I get:
>> #subsys_name Âhierarchy    num_cgroups   enabled
>> cpuset    Â1    1    1
>> cpu      1    1    1
>> perf_event  Â1    1    1
>>
>> In other words, the hierarchy id is not unique.
>> If the perf_event is not mounted, then hierarchy id = 0.
>>
>
> Yes, it's unique. ;)
>
> You mounted them together, and that's a cgroup hierarchy, so
> they have the same hierarchy id.
>
> If you mount them seperately:
>
> # mount -t cgroup -o debug xxx /cgroup1
> # mount -t cgroup -o net_cls xxx /cgroup2/
> # cat /proc/cgroups
> #subsys_name  Âhierarchy    num_cgroups   enabled
> debug  1    1    1
> net_cls 2 Â Â Â 1 Â Â Â 1
>
Ok, but if you mount perf_event twice, you get the
same hierarchy id for it:

# mount -t cgroup -operf_event none /cgroup
# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
cpuset 0 1 1
cpu 0 1 1
perf_event 1 1 1

# mount -t cgroup -operf_event none /cgroup2
# cat /proc/cgroups
#subsys_name hierarchy num_cgroups enabled
cpuset 0 1 1
cpu 0 1 1
perf_event 1 1 1

It does not seem like I can mount the same subsystem
twice with difference hierarchies:

# umount /cgroup2
# mount -t cgroup -operf_event,cpuset none /cgroup2
mount: none already mounted or /cgroup2 busy
# mount -t cgroup none /cgroup2
mount: none already mounted or /cgroup2 busy

> They now have different hierarchy id, because they belong
> to different cgroup hierarchy.
>
> So pid + hierarchy_id locates the cgroup.
>

I cannot do task's pid + cgroup hierarchy_id. It's one or the
other.

>> I have tried mounting cgroupfs in multiple places at the same
>> time. Whatever directory I used, I got to the right css.
>>
>> Am I missing your point here?
>>
>
> I should use the words "cgroup hierarchies" instead of mount points..
>
Can you mount the same subsystem multiple times with DIFFERENT
hierarchies?
--
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/