Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147196
b: refs/heads/master
c: dd0e6ba
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mackerras committed Jan 12, 2009
1 parent 1e71299 commit 8e128b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 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: c0d362a832ee70435fc4555a64f820893b1da0bd
refs/heads/master: dd0e6ba22ea21bcc2c420b385a170593c58f4c08
33 changes: 30 additions & 3 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,37 @@ group_sched_in(struct perf_counter *group_counter,
return -EAGAIN;
}

/*
* Return 1 for a software counter, 0 for a hardware counter
*/
static inline int is_software_counter(struct perf_counter *counter)
{
return !counter->hw_event.raw && counter->hw_event.type < 0;
}

/*
* Return 1 for a group consisting entirely of software counters,
* 0 if the group contains any hardware counters.
*/
static int is_software_only_group(struct perf_counter *leader)
{
struct perf_counter *counter;

if (!is_software_counter(leader))
return 0;
list_for_each_entry(counter, &leader->sibling_list, list_entry)
if (!is_software_counter(counter))
return 0;
return 1;
}

static void
__perf_counter_sched_in(struct perf_counter_context *ctx,
struct perf_cpu_context *cpuctx, int cpu)
{
struct perf_counter *counter;
u64 flags;
int can_add_hw = 1;

if (likely(!ctx->nr_counters))
return;
Expand All @@ -477,10 +502,12 @@ __perf_counter_sched_in(struct perf_counter_context *ctx,

/*
* If we scheduled in a group atomically and exclusively,
* or if this group can't go on, break out:
* or if this group can't go on, don't add any more
* hardware counters.
*/
if (group_sched_in(counter, cpuctx, ctx, cpu))
break;
if (can_add_hw || is_software_only_group(counter))
if (group_sched_in(counter, cpuctx, ctx, cpu))
can_add_hw = 0;
}
hw_perf_restore(flags);
spin_unlock(&ctx->lock);
Expand Down

0 comments on commit 8e128b4

Please sign in to comment.