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

From: Stephane Eranian
Date: Thu Sep 09 2010 - 17:41:50 EST


Eric,

On Thu, Sep 9, 2010 at 3:52 PM, Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
> Le jeudi 09 septembre 2010 Ã 06:09 -0700, Stephane Eranian a Ãcrit :
>> This kernel patch adds the ability to filter monitoring based on
>> container groups (cgroups). This is for use in per-cpu mode only.
>>
>> The patch adds perf_event_attr.cgroup, a boolean, to activate
>> this new mode. The cgroup is designated by passing in
>> perf_event_attr.cgroup_fd, an opened file descriptor to
>> the <mnt>/<cgroup>/perf_event.perf file.
>>
>> This is the second version of this patch. It corrects the way
>> time_enabled is accounted for. In cgroup mode, time_enabled reflects
>> the time the cgroup was active, i.e., threads from the cgroup executed
>> on the monitored CPU. ÂThis is a more useful metric than just
>> wall-clock. The meaning of time_enabled without cgroup is unaffected.
>>
>> Signed-off-by: Stephane Eranian <eranian@xxxxxxxxxx>
>
>
>> +#ifdef CONFIG_CGROUPS
>> +struct perf_cgroup_time {
>> + Â Â u64 time;
>> + Â Â u64 timestamp;
>> +};
>> +
>> +struct perf_cgroup {
>> + Â Â struct cgroup_subsys_state css;
>> + Â Â struct perf_cgroup_time *time;
>
> Â Â Â Âstruct perf_cgroup_time __percpu *time;
>
> Please run sparse Âafter this "__percpu" change.
>
>
Will do.

>> + Â Â jc->time = alloc_percpu(struct perf_cgroup_time);
>> + Â Â if (!jc->time) {
>> + Â Â Â Â Â Â vfree(jc);
>> + Â Â Â Â Â Â return ERR_PTR(-ENOMEM);
>> + Â Â }
>> +
>> + Â Â for_each_possible_cpu(c) {
>> + Â Â Â Â Â Â t = per_cpu_ptr(jc->time, c);
>> + Â Â Â Â Â Â t->time = 0;
>> + Â Â Â Â Â Â t->timestamp = 0;
>> + Â Â }
>
> alloc_percpu() is zalloc_percpu() in fact, memory is already cleared.
>
I remember thinking about this and trying to trace to the code down
to figure this out. But it is rather complicated. If alloc_percpu() always
clears the memory, then I think that calling is zalloc_percpu()
would be more helpful....

>
>
--
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/