提交 aa5452d7 编写于 作者: X Xiao Guangrong 提交者: Ingo Molnar

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: NXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Reviewed-by: NFrederic 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: NIngo Molnar <mingo@elte.hu>
上级 44234adc
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
/* /*
* Each CPU has a list of per CPU events: * Each CPU has a list of per CPU events:
*/ */
DEFINE_PER_CPU(struct perf_cpu_context, perf_cpu_context); static DEFINE_PER_CPU(struct perf_cpu_context, perf_cpu_context);
int perf_max_events __read_mostly = 1; int perf_max_events __read_mostly = 1;
static int perf_reserved_percpu __read_mostly; static int perf_reserved_percpu __read_mostly;
...@@ -1579,7 +1579,6 @@ static void ...@@ -1579,7 +1579,6 @@ static void
__perf_event_init_context(struct perf_event_context *ctx, __perf_event_init_context(struct perf_event_context *ctx,
struct task_struct *task) struct task_struct *task)
{ {
memset(ctx, 0, sizeof(*ctx));
spin_lock_init(&ctx->lock); spin_lock_init(&ctx->lock);
mutex_init(&ctx->mutex); mutex_init(&ctx->mutex);
INIT_LIST_HEAD(&ctx->group_list); INIT_LIST_HEAD(&ctx->group_list);
...@@ -1654,7 +1653,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu) ...@@ -1654,7 +1653,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu)
} }
if (!ctx) { if (!ctx) {
ctx = kmalloc(sizeof(struct perf_event_context), GFP_KERNEL); ctx = kzalloc(sizeof(struct perf_event_context), GFP_KERNEL);
err = -ENOMEM; err = -ENOMEM;
if (!ctx) if (!ctx)
goto errout; goto errout;
...@@ -5105,7 +5104,7 @@ int perf_event_init_task(struct task_struct *child) ...@@ -5105,7 +5104,7 @@ int perf_event_init_task(struct task_struct *child)
* First allocate and initialize a context for the child. * First allocate and initialize a context for the child.
*/ */
child_ctx = kmalloc(sizeof(struct perf_event_context), GFP_KERNEL); child_ctx = kzalloc(sizeof(struct perf_event_context), GFP_KERNEL);
if (!child_ctx) if (!child_ctx)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册