Re: [PATCH 3/4] perf cgroup: Clean up perf_cgroup_create()

From: Stephane Eranian
Date: Thu Mar 03 2011 - 03:40:47 EST


Ok,


I checked and yes, alloc_percpu() does return zeroed out memory.
So the patch looks good to me.
Thanks.


On Thu, Mar 3, 2011 at 9:37 AM, Stephane Eranian <eranian@xxxxxxxxxx> wrote:
> Li,
>
> I have to NACK this patch or at least request more information.
>
> The for_each_possible_cpu() is initializing
> what's allocated via alloc_percpu(), jc->info and NOT jc.
>
> I don't think this gets zeroed by this allocator. But I could
> be wrong.
>
>
> On Thu, Mar 3, 2011 at 7:26 AM, Li Zefan <lizf@xxxxxxxxxxxxxx> wrote:
>> - Use kzalloc() to replace kmalloc() + memset().
>> - Remove redundant initialization, since alloc_percpu() returns
>> Âzero-filled percpu memory.
>>
>> Signed-off-by: Li Zefan <lizf@xxxxxxxxxxxxxx>
>> ---
>> Âkernel/perf_event.c | Â 11 +----------
>> Â1 files changed, 1 insertions(+), 10 deletions(-)
>>
>> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
>> index dca92b2..d6b3d16 100644
>> --- a/kernel/perf_event.c
>> +++ b/kernel/perf_event.c
>> @@ -7341,26 +7341,17 @@ static struct cgroup_subsys_state *perf_cgroup_create(
>> Â Â Â Âstruct cgroup_subsys *ss, struct cgroup *cont)
>> Â{
>> Â Â Â Âstruct perf_cgroup *jc;
>> - Â Â Â struct perf_cgroup_info *t;
>> - Â Â Â int c;
>>
>> - Â Â Â jc = kmalloc(sizeof(*jc), GFP_KERNEL);
>> + Â Â Â jc = kzalloc(sizeof(*jc), GFP_KERNEL);
>> Â Â Â Âif (!jc)
>> Â Â Â Â Â Â Â Âreturn ERR_PTR(-ENOMEM);
>>
>> - Â Â Â memset(jc, 0, sizeof(*jc));
>> -
>> Â Â Â Âjc->info = alloc_percpu(struct perf_cgroup_info);
>> Â Â Â Âif (!jc->info) {
>> Â Â Â Â Â Â Â Âkfree(jc);
>> Â Â Â Â Â Â Â Âreturn ERR_PTR(-ENOMEM);
>> Â Â Â Â}
>>
>> - Â Â Â for_each_possible_cpu(c) {
>> - Â Â Â Â Â Â Â t = per_cpu_ptr(jc->info, c);
>> - Â Â Â Â Â Â Â t->time = 0;
>> - Â Â Â Â Â Â Â t->timestamp = 0;
>> - Â Â Â }
>> Â Â Â Âreturn &jc->css;
>> Â}
>>
>> --
>> 1.6.3
>>
>
--
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/