diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2009-12-08 22:28:13 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-09 03:56:27 -0500 |
commit | aa5452d70c0d559310598b243b8b1033c10056e7 (patch) | |
tree | 80f1c0b1137722a71623254c93bec20e33f4b19d /kernel/perf_event.c | |
parent | 44234adcdce38f83c56e05f808ce656175b4beeb (diff) |
perf_event: Clean up __perf_event_init_context()
Clean up the code a bit:
- define 'perf_cpu_context' variable with 'static'
- use kzalloc() instead of kmalloc() and memset()
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Reviewed-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <4B1F194D.7080306@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_event.c')
-rw-r--r-- | kernel/perf_event.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 3b0cf86eee84..2b06c45bfba9 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -36,7 +36,7 @@ | |||
36 | /* | 36 | /* |
37 | * Each CPU has a list of per CPU events: | 37 | * Each CPU has a list of per CPU events: |
38 | */ | 38 | */ |
39 | DEFINE_PER_CPU(struct perf_cpu_context, perf_cpu_context); | 39 | static DEFINE_PER_CPU(struct perf_cpu_context, perf_cpu_context); |
40 | 40 | ||
41 | int perf_max_events __read_mostly = 1; | 41 | int perf_max_events __read_mostly = 1; |
42 | static int perf_reserved_percpu __read_mostly; | 42 | static int perf_reserved_percpu __read_mostly; |
@@ -1579,7 +1579,6 @@ static void | |||
1579 | __perf_event_init_context(struct perf_event_context *ctx, | 1579 | __perf_event_init_context(struct perf_event_context *ctx, |
1580 | struct task_struct *task) | 1580 | struct task_struct *task) |
1581 | { | 1581 | { |
1582 | memset(ctx, 0, sizeof(*ctx)); | ||
1583 | spin_lock_init(&ctx->lock); | 1582 | spin_lock_init(&ctx->lock); |
1584 | mutex_init(&ctx->mutex); | 1583 | mutex_init(&ctx->mutex); |
1585 | INIT_LIST_HEAD(&ctx->group_list); | 1584 | INIT_LIST_HEAD(&ctx->group_list); |
@@ -1654,7 +1653,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu) | |||
1654 | } | 1653 | } |
1655 | 1654 | ||
1656 | if (!ctx) { | 1655 | if (!ctx) { |
1657 | ctx = kmalloc(sizeof(struct perf_event_context), GFP_KERNEL); | 1656 | ctx = kzalloc(sizeof(struct perf_event_context), GFP_KERNEL); |
1658 | err = -ENOMEM; | 1657 | err = -ENOMEM; |
1659 | if (!ctx) | 1658 | if (!ctx) |
1660 | goto errout; | 1659 | goto errout; |
@@ -5105,7 +5104,7 @@ int perf_event_init_task(struct task_struct *child) | |||
5105 | * First allocate and initialize a context for the child. | 5104 | * First allocate and initialize a context for the child. |
5106 | */ | 5105 | */ |
5107 | 5106 | ||
5108 | child_ctx = kmalloc(sizeof(struct perf_event_context), GFP_KERNEL); | 5107 | child_ctx = kzalloc(sizeof(struct perf_event_context), GFP_KERNEL); |
5109 | if (!child_ctx) | 5108 | if (!child_ctx) |
5110 | return -ENOMEM; | 5109 | return -ENOMEM; |
5111 | 5110 | ||