Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147443
b: refs/heads/master
c: 6751b71
h: refs/heads/master
i:
  147441: cfcab72
  147439: 335f59e
v: v3
  • Loading branch information
Paul Mackerras authored and Ingo Molnar committed May 11, 2009
1 parent 194ce40 commit df64c3e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 49 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: 8823392360dc4992f87bf4c623834d315f297493
refs/heads/master: 6751b71ea2c7ab8c0d65f01973a3fc8ea16992f4
99 changes: 51 additions & 48 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,54 @@ counter_sched_in(struct perf_counter *counter,
return 0;
}

static int
group_sched_in(struct perf_counter *group_counter,
struct perf_cpu_context *cpuctx,
struct perf_counter_context *ctx,
int cpu)
{
struct perf_counter *counter, *partial_group;
int ret;

if (group_counter->state == PERF_COUNTER_STATE_OFF)
return 0;

ret = hw_perf_group_sched_in(group_counter, cpuctx, ctx, cpu);
if (ret)
return ret < 0 ? ret : 0;

group_counter->prev_state = group_counter->state;
if (counter_sched_in(group_counter, cpuctx, ctx, cpu))
return -EAGAIN;

/*
* Schedule in siblings as one group (if any):
*/
list_for_each_entry(counter, &group_counter->sibling_list, list_entry) {
counter->prev_state = counter->state;
if (counter_sched_in(counter, cpuctx, ctx, cpu)) {
partial_group = counter;
goto group_error;
}
}

return 0;

group_error:
/*
* Groups can be scheduled in as one unit only, so undo any
* partial group before returning:
*/
list_for_each_entry(counter, &group_counter->sibling_list, list_entry) {
if (counter == partial_group)
break;
counter_sched_out(counter, cpuctx, ctx);
}
counter_sched_out(group_counter, cpuctx, ctx);

return -EAGAIN;
}

/*
* Return 1 for a group consisting entirely of software counters,
* 0 if the group contains any hardware counters.
Expand Down Expand Up @@ -643,6 +691,9 @@ static void __perf_counter_enable(void *info)

if (!group_can_go_on(counter, cpuctx, 1))
err = -EEXIST;
else if (counter == leader)
err = group_sched_in(counter, cpuctx, ctx,
smp_processor_id());
else
err = counter_sched_in(counter, cpuctx, ctx,
smp_processor_id());
Expand Down Expand Up @@ -791,54 +842,6 @@ static void perf_counter_cpu_sched_out(struct perf_cpu_context *cpuctx)
__perf_counter_sched_out(&cpuctx->ctx, cpuctx);
}

static int
group_sched_in(struct perf_counter *group_counter,
struct perf_cpu_context *cpuctx,
struct perf_counter_context *ctx,
int cpu)
{
struct perf_counter *counter, *partial_group;
int ret;

if (group_counter->state == PERF_COUNTER_STATE_OFF)
return 0;

ret = hw_perf_group_sched_in(group_counter, cpuctx, ctx, cpu);
if (ret)
return ret < 0 ? ret : 0;

group_counter->prev_state = group_counter->state;
if (counter_sched_in(group_counter, cpuctx, ctx, cpu))
return -EAGAIN;

/*
* Schedule in siblings as one group (if any):
*/
list_for_each_entry(counter, &group_counter->sibling_list, list_entry) {
counter->prev_state = counter->state;
if (counter_sched_in(counter, cpuctx, ctx, cpu)) {
partial_group = counter;
goto group_error;
}
}

return 0;

group_error:
/*
* Groups can be scheduled in as one unit only, so undo any
* partial group before returning:
*/
list_for_each_entry(counter, &group_counter->sibling_list, list_entry) {
if (counter == partial_group)
break;
counter_sched_out(counter, cpuctx, ctx);
}
counter_sched_out(group_counter, cpuctx, ctx);

return -EAGAIN;
}

static void
__perf_counter_sched_in(struct perf_counter_context *ctx,
struct perf_cpu_context *cpuctx, int cpu)
Expand Down

0 comments on commit df64c3e

Please sign in to comment.