Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 175427
b: refs/heads/master
c: b93f797
h: refs/heads/master
i:
  175425: dac4c0d
  175423: 04ceff4
v: v3
  • Loading branch information
Xiao Guangrong authored and Ingo Molnar committed Dec 9, 2009
1 parent 592ddc6 commit 26c66cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aa5452d70c0d559310598b243b8b1033c10056e7
refs/heads/master: b93f7978ad6b46133e9453b90ccc057dc2429e75
37 changes: 22 additions & 15 deletions trunk/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -5083,7 +5083,7 @@ void perf_event_free_task(struct task_struct *task)
*/
int perf_event_init_task(struct task_struct *child)
{
struct perf_event_context *child_ctx, *parent_ctx;
struct perf_event_context *child_ctx = NULL, *parent_ctx;
struct perf_event_context *cloned_ctx;
struct perf_event *event;
struct task_struct *parent = current;
Expand All @@ -5098,20 +5098,6 @@ int perf_event_init_task(struct task_struct *child)
if (likely(!parent->perf_event_ctxp))
return 0;

/*
* This is executed from the parent task context, so inherit
* events that have been marked for cloning.
* First allocate and initialize a context for the child.
*/

child_ctx = kzalloc(sizeof(struct perf_event_context), GFP_KERNEL);
if (!child_ctx)
return -ENOMEM;

__perf_event_init_context(child_ctx, child);
child->perf_event_ctxp = child_ctx;
get_task_struct(child);

/*
* If the parent's context is a clone, pin it so it won't get
* swapped under us.
Expand Down Expand Up @@ -5142,6 +5128,26 @@ int perf_event_init_task(struct task_struct *child)
continue;
}

if (!child->perf_event_ctxp) {
/*
* This is executed from the parent task context, so
* inherit events that have been marked for cloning.
* First allocate and initialize a context for the
* child.
*/

child_ctx = kzalloc(sizeof(struct perf_event_context),
GFP_KERNEL);
if (!child_ctx) {
ret = -ENOMEM;
goto exit;
}

__perf_event_init_context(child_ctx, child);
child->perf_event_ctxp = child_ctx;
get_task_struct(child);
}

ret = inherit_group(event, parent, parent_ctx,
child, child_ctx);
if (ret) {
Expand Down Expand Up @@ -5170,6 +5176,7 @@ int perf_event_init_task(struct task_struct *child)
get_ctx(child_ctx->parent_ctx);
}

exit:
mutex_unlock(&parent_ctx->mutex);

perf_unpin_context(parent_ctx);
Expand Down

0 comments on commit 26c66cf

Please sign in to comment.