Skip to content

Commit 1b15d05

Browse files
Li ZefanIngo Molnar
authored andcommitted
perf cgroup: Clean up perf_cgroup_create()
- Use kzalloc() to replace kmalloc() + memset(). - Remove redundant initialization, since alloc_percpu() returns zero-filled percpu memory. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Stephane Eranian <eranian@google.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <4D6F347E.2010806@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent f75e18c commit 1b15d05

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

kernel/perf_event.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7346,26 +7346,17 @@ static struct cgroup_subsys_state *perf_cgroup_create(
73467346
struct cgroup_subsys *ss, struct cgroup *cont)
73477347
{
73487348
struct perf_cgroup *jc;
7349-
struct perf_cgroup_info *t;
7350-
int c;
73517349

7352-
jc = kmalloc(sizeof(*jc), GFP_KERNEL);
7350+
jc = kzalloc(sizeof(*jc), GFP_KERNEL);
73537351
if (!jc)
73547352
return ERR_PTR(-ENOMEM);
73557353

7356-
memset(jc, 0, sizeof(*jc));
7357-
73587354
jc->info = alloc_percpu(struct perf_cgroup_info);
73597355
if (!jc->info) {
73607356
kfree(jc);
73617357
return ERR_PTR(-ENOMEM);
73627358
}
73637359

7364-
for_each_possible_cpu(c) {
7365-
t = per_cpu_ptr(jc->info, c);
7366-
t->time = 0;
7367-
t->timestamp = 0;
7368-
}
73697360
return &jc->css;
73707361
}
73717362

0 commit comments

Comments
 (0)