Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288718
b: refs/heads/master
c: ff3fb51
h: refs/heads/master
v: v3
  • Loading branch information
Stephane Eranian authored and Ingo Molnar committed Mar 5, 2012
1 parent 48a68e1 commit effe746
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b36817e8863090f1f24e538106ca50fa1d9e4003
refs/heads/master: ff3fb511ba377e8a0a7f553cc352237f70d08121
60 changes: 60 additions & 0 deletions trunk/arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,36 @@ int x86_setup_perfctr(struct perf_event *event)
return 0;
}

/*
* check that branch_sample_type is compatible with
* settings needed for precise_ip > 1 which implies
* using the LBR to capture ALL taken branches at the
* priv levels of the measurement
*/
static inline int precise_br_compat(struct perf_event *event)
{
u64 m = event->attr.branch_sample_type;
u64 b = 0;

/* must capture all branches */
if (!(m & PERF_SAMPLE_BRANCH_ANY))
return 0;

m &= PERF_SAMPLE_BRANCH_KERNEL | PERF_SAMPLE_BRANCH_USER;

if (!event->attr.exclude_user)
b |= PERF_SAMPLE_BRANCH_USER;

if (!event->attr.exclude_kernel)
b |= PERF_SAMPLE_BRANCH_KERNEL;

/*
* ignore PERF_SAMPLE_BRANCH_HV, not supported on x86
*/

return m == b;
}

int x86_pmu_hw_config(struct perf_event *event)
{
if (event->attr.precise_ip) {
Expand All @@ -369,6 +399,36 @@ int x86_pmu_hw_config(struct perf_event *event)

if (event->attr.precise_ip > precise)
return -EOPNOTSUPP;
/*
* check that PEBS LBR correction does not conflict with
* whatever the user is asking with attr->branch_sample_type
*/
if (event->attr.precise_ip > 1) {
u64 *br_type = &event->attr.branch_sample_type;

if (has_branch_stack(event)) {
if (!precise_br_compat(event))
return -EOPNOTSUPP;

/* branch_sample_type is compatible */

} else {
/*
* user did not specify branch_sample_type
*
* For PEBS fixups, we capture all
* the branches at the priv level of the
* event.
*/
*br_type = PERF_SAMPLE_BRANCH_ANY;

if (!event->attr.exclude_user)
*br_type |= PERF_SAMPLE_BRANCH_USER;

if (!event->attr.exclude_kernel)
*br_type |= PERF_SAMPLE_BRANCH_KERNEL;
}
}
}

/*
Expand Down

0 comments on commit effe746

Please sign in to comment.