Skip to content

Commit

Permalink
perf cgroup: Clean up perf_cgroup_create()
Browse files Browse the repository at this point in the history
- Use kzalloc() to replace kmalloc() + memset().

- Remove redundant initialization, since alloc_percpu() returns
  zero-filled percpu memory.

Signed-off-by: Li Zefan <[email protected]>
Acked-by: Stephane Eranian <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Li Zefan authored and Ingo Molnar committed Mar 4, 2011
1 parent f75e18c commit 1b15d05
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -7346,26 +7346,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;
}

Expand Down

0 comments on commit 1b15d05

Please sign in to comment.