Commit b58064da authored by Madhavan Srinivasan's avatar Madhavan Srinivasan Committed by Michael Ellerman

powerpc/perf: Infrastructure to support addition of blacklisted events

Introduce code to support addition of blacklisted events for a
processor version. Blacklisted events are events that are known to not
count correctly on that CPU revision, and so should be prevented from
being counted so as to avoid user confusion.

A 'pointer' and 'int' variable to hold the number of events are added
to 'struct power_pmu', along with a generic function to loop through
the list to validate the given event. Generic function
'is_event_blacklisted' is called in power_pmu_event_init() to detect
and reject early.
Signed-off-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent cd1231d7
...@@ -53,6 +53,8 @@ struct power_pmu { ...@@ -53,6 +53,8 @@ struct power_pmu {
[PERF_COUNT_HW_CACHE_OP_MAX] [PERF_COUNT_HW_CACHE_OP_MAX]
[PERF_COUNT_HW_CACHE_RESULT_MAX]; [PERF_COUNT_HW_CACHE_RESULT_MAX];
int n_blacklist_ev;
int *blacklist_ev;
/* BHRB entries in the PMU */ /* BHRB entries in the PMU */
int bhrb_nr; int bhrb_nr;
}; };
......
...@@ -1839,6 +1839,18 @@ static int hw_perf_cache_event(u64 config, u64 *eventp) ...@@ -1839,6 +1839,18 @@ static int hw_perf_cache_event(u64 config, u64 *eventp)
return 0; return 0;
} }
static bool is_event_blacklisted(u64 ev)
{
int i;
for (i=0; i < ppmu->n_blacklist_ev; i++) {
if (ppmu->blacklist_ev[i] == ev)
return true;
}
return false;
}
static int power_pmu_event_init(struct perf_event *event) static int power_pmu_event_init(struct perf_event *event)
{ {
u64 ev; u64 ev;
...@@ -1864,15 +1876,24 @@ static int power_pmu_event_init(struct perf_event *event) ...@@ -1864,15 +1876,24 @@ static int power_pmu_event_init(struct perf_event *event)
ev = event->attr.config; ev = event->attr.config;
if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0) if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (ppmu->blacklist_ev && is_event_blacklisted(ev))
return -EINVAL;
ev = ppmu->generic_events[ev]; ev = ppmu->generic_events[ev];
break; break;
case PERF_TYPE_HW_CACHE: case PERF_TYPE_HW_CACHE:
err = hw_perf_cache_event(event->attr.config, &ev); err = hw_perf_cache_event(event->attr.config, &ev);
if (err) if (err)
return err; return err;
if (ppmu->blacklist_ev && is_event_blacklisted(ev))
return -EINVAL;
break; break;
case PERF_TYPE_RAW: case PERF_TYPE_RAW:
ev = event->attr.config; ev = event->attr.config;
if (ppmu->blacklist_ev && is_event_blacklisted(ev))
return -EINVAL;
break; break;
default: default:
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment