Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147308
b: refs/heads/master
c: d5d2bc0
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mackerras authored and Ingo Molnar committed Apr 6, 2009
1 parent eb64b76 commit 5092bdb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 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: 7595d63b3a9ce65d14c4fbd0e7de448a343d7215
refs/heads/master: d5d2bc0dd0379deddb9ede66fec90a3083eaec57
14 changes: 7 additions & 7 deletions trunk/arch/powerpc/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,13 @@ hw_perf_counter_init(struct perf_counter *counter)
int err;

if (!ppmu)
return NULL;
return ERR_PTR(-ENXIO);
if ((s64)counter->hw_event.irq_period < 0)
return NULL;
return ERR_PTR(-EINVAL);
if (!perf_event_raw(&counter->hw_event)) {
ev = perf_event_id(&counter->hw_event);
if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0)
return NULL;
return ERR_PTR(-EOPNOTSUPP);
ev = ppmu->generic_events[ev];
} else {
ev = perf_event_config(&counter->hw_event);
Expand All @@ -656,14 +656,14 @@ hw_perf_counter_init(struct perf_counter *counter)
n = collect_events(counter->group_leader, ppmu->n_counter - 1,
ctrs, events);
if (n < 0)
return NULL;
return ERR_PTR(-EINVAL);
}
events[n] = ev;
ctrs[n] = counter;
if (check_excludes(ctrs, n, 1))
return NULL;
return ERR_PTR(-EINVAL);
if (power_check_constraints(events, n + 1))
return NULL;
return ERR_PTR(-EINVAL);

counter->hw.config = events[n];
atomic64_set(&counter->hw.period_left, counter->hw_event.irq_period);
Expand All @@ -687,7 +687,7 @@ hw_perf_counter_init(struct perf_counter *counter)
counter->destroy = hw_perf_counter_destroy;

if (err)
return NULL;
return ERR_PTR(err);
return &power_perf_ops;
}

Expand Down
35 changes: 22 additions & 13 deletions trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2453,10 +2453,11 @@ perf_counter_alloc(struct perf_counter_hw_event *hw_event,
{
const struct hw_perf_counter_ops *hw_ops;
struct perf_counter *counter;
long err;

counter = kzalloc(sizeof(*counter), gfpflags);
if (!counter)
return NULL;
return ERR_PTR(-ENOMEM);

/*
* Single counters are their own group leaders, with an
Expand Down Expand Up @@ -2505,12 +2506,18 @@ perf_counter_alloc(struct perf_counter_hw_event *hw_event,
hw_ops = tp_perf_counter_init(counter);
break;
}
done:
err = 0;
if (!hw_ops)
err = -EINVAL;
else if (IS_ERR(hw_ops))
err = PTR_ERR(hw_ops);

if (!hw_ops) {
if (err) {
kfree(counter);
return NULL;
return ERR_PTR(err);
}
done:

counter->hw_ops = hw_ops;

return counter;
Expand Down Expand Up @@ -2583,10 +2590,10 @@ SYSCALL_DEFINE5(perf_counter_open,
goto err_put_context;
}

ret = -EINVAL;
counter = perf_counter_alloc(&hw_event, cpu, ctx, group_leader,
GFP_KERNEL);
if (!counter)
ret = PTR_ERR(counter);
if (IS_ERR(counter))
goto err_put_context;

ret = anon_inode_getfd("[perf_counter]", &perf_fops, counter, 0);
Expand Down Expand Up @@ -2658,8 +2665,8 @@ inherit_counter(struct perf_counter *parent_counter,
child_counter = perf_counter_alloc(&parent_counter->hw_event,
parent_counter->cpu, child_ctx,
group_leader, GFP_KERNEL);
if (!child_counter)
return NULL;
if (IS_ERR(child_counter))
return child_counter;

/*
* Link it up in the child's context:
Expand Down Expand Up @@ -2710,15 +2717,17 @@ static int inherit_group(struct perf_counter *parent_counter,
{
struct perf_counter *leader;
struct perf_counter *sub;
struct perf_counter *child_ctr;

leader = inherit_counter(parent_counter, parent, parent_ctx,
child, NULL, child_ctx);
if (!leader)
return -ENOMEM;
if (IS_ERR(leader))
return PTR_ERR(leader);
list_for_each_entry(sub, &parent_counter->sibling_list, list_entry) {
if (!inherit_counter(sub, parent, parent_ctx,
child, leader, child_ctx))
return -ENOMEM;
child_ctr = inherit_counter(sub, parent, parent_ctx,
child, leader, child_ctx);
if (IS_ERR(child_ctr))
return PTR_ERR(child_ctr);
}
return 0;
}
Expand Down

0 comments on commit 5092bdb

Please sign in to comment.