Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155710
b: refs/heads/master
c: 71a851b
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jul 10, 2009
1 parent 8e38cf3 commit 6f58087
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 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: 984b838ce69c063a91b87550598ab7f3439dd94a
refs/heads/master: 71a851b4d2a815adcfac09c1adda7ef6811fde66
36 changes: 17 additions & 19 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ static void put_ctx(struct perf_counter_context *ctx)
}
}

static void unclone_ctx(struct perf_counter_context *ctx)
{
if (ctx->parent_ctx) {
put_ctx(ctx->parent_ctx);
ctx->parent_ctx = NULL;
}
}

/*
* Get the perf_counter_context for a task and lock it.
* This has to cope with with the fact that until it is locked,
Expand Down Expand Up @@ -1463,10 +1471,8 @@ static void perf_counter_enable_on_exec(struct task_struct *task)
/*
* Unclone this context if we enabled any counter.
*/
if (enabled && ctx->parent_ctx) {
put_ctx(ctx->parent_ctx);
ctx->parent_ctx = NULL;
}
if (enabled)
unclone_ctx(ctx);

spin_unlock(&ctx->lock);

Expand Down Expand Up @@ -1526,7 +1532,6 @@ __perf_counter_init_context(struct perf_counter_context *ctx,

static struct perf_counter_context *find_get_context(pid_t pid, int cpu)
{
struct perf_counter_context *parent_ctx;
struct perf_counter_context *ctx;
struct perf_cpu_context *cpuctx;
struct task_struct *task;
Expand Down Expand Up @@ -1586,11 +1591,7 @@ static struct perf_counter_context *find_get_context(pid_t pid, int cpu)
retry:
ctx = perf_lock_task_context(task, &flags);
if (ctx) {
parent_ctx = ctx->parent_ctx;
if (parent_ctx) {
put_ctx(parent_ctx);
ctx->parent_ctx = NULL; /* no longer a clone */
}
unclone_ctx(ctx);
spin_unlock_irqrestore(&ctx->lock, flags);
}

Expand Down Expand Up @@ -4255,15 +4256,12 @@ void perf_counter_exit_task(struct task_struct *child)
*/
spin_lock(&child_ctx->lock);
child->perf_counter_ctxp = NULL;
if (child_ctx->parent_ctx) {
/*
* This context is a clone; unclone it so it can't get
* swapped to another process while we're removing all
* the counters from it.
*/
put_ctx(child_ctx->parent_ctx);
child_ctx->parent_ctx = NULL;
}
/*
* If this context is a clone; unclone it so it can't get
* swapped to another process while we're removing all
* the counters from it.
*/
unclone_ctx(child_ctx);
spin_unlock(&child_ctx->lock);
local_irq_restore(flags);

Expand Down

0 comments on commit 6f58087

Please sign in to comment.