|
@@ -568,7 +568,7 @@ struct sched_state {
|
|
|
struct perf_sched {
|
|
|
int max_weight;
|
|
|
int max_events;
|
|
|
- struct event_constraint **constraints;
|
|
|
+ struct perf_event **events;
|
|
|
struct sched_state state;
|
|
|
int saved_states;
|
|
|
struct sched_state saved[SCHED_STATES_MAX];
|
|
@@ -577,7 +577,7 @@ struct perf_sched {
|
|
|
/*
|
|
|
* Initialize interator that runs through all events and counters.
|
|
|
*/
|
|
|
-static void perf_sched_init(struct perf_sched *sched, struct event_constraint **c,
|
|
|
+static void perf_sched_init(struct perf_sched *sched, struct perf_event **events,
|
|
|
int num, int wmin, int wmax)
|
|
|
{
|
|
|
int idx;
|
|
@@ -585,10 +585,10 @@ static void perf_sched_init(struct perf_sched *sched, struct event_constraint **
|
|
|
memset(sched, 0, sizeof(*sched));
|
|
|
sched->max_events = num;
|
|
|
sched->max_weight = wmax;
|
|
|
- sched->constraints = c;
|
|
|
+ sched->events = events;
|
|
|
|
|
|
for (idx = 0; idx < num; idx++) {
|
|
|
- if (c[idx]->weight == wmin)
|
|
|
+ if (events[idx]->hw.constraint->weight == wmin)
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -635,8 +635,7 @@ static bool __perf_sched_find_counter(struct perf_sched *sched)
|
|
|
if (sched->state.event >= sched->max_events)
|
|
|
return false;
|
|
|
|
|
|
- c = sched->constraints[sched->state.event];
|
|
|
-
|
|
|
+ c = sched->events[sched->state.event]->hw.constraint;
|
|
|
/* Prefer fixed purpose counters */
|
|
|
if (c->idxmsk64 & (~0ULL << INTEL_PMC_IDX_FIXED)) {
|
|
|
idx = INTEL_PMC_IDX_FIXED;
|
|
@@ -694,7 +693,7 @@ static bool perf_sched_next_event(struct perf_sched *sched)
|
|
|
if (sched->state.weight > sched->max_weight)
|
|
|
return false;
|
|
|
}
|
|
|
- c = sched->constraints[sched->state.event];
|
|
|
+ c = sched->events[sched->state.event]->hw.constraint;
|
|
|
} while (c->weight != sched->state.weight);
|
|
|
|
|
|
sched->state.counter = 0; /* start with first counter */
|
|
@@ -705,12 +704,12 @@ static bool perf_sched_next_event(struct perf_sched *sched)
|
|
|
/*
|
|
|
* Assign a counter for each event.
|
|
|
*/
|
|
|
-int perf_assign_events(struct event_constraint **constraints, int n,
|
|
|
+int perf_assign_events(struct perf_event **events, int n,
|
|
|
int wmin, int wmax, int *assign)
|
|
|
{
|
|
|
struct perf_sched sched;
|
|
|
|
|
|
- perf_sched_init(&sched, constraints, n, wmin, wmax);
|
|
|
+ perf_sched_init(&sched, events, n, wmin, wmax);
|
|
|
|
|
|
do {
|
|
|
if (!perf_sched_find_counter(&sched))
|
|
@@ -724,7 +723,7 @@ int perf_assign_events(struct event_constraint **constraints, int n,
|
|
|
|
|
|
int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
|
{
|
|
|
- struct event_constraint *c, *constraints[X86_PMC_IDX_MAX];
|
|
|
+ struct event_constraint *c;
|
|
|
unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
|
|
|
int i, wmin, wmax, num = 0;
|
|
|
struct hw_perf_event *hwc;
|
|
@@ -732,8 +731,10 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
|
bitmap_zero(used_mask, X86_PMC_IDX_MAX);
|
|
|
|
|
|
for (i = 0, wmin = X86_PMC_IDX_MAX, wmax = 0; i < n; i++) {
|
|
|
+ hwc = &cpuc->event_list[i]->hw;
|
|
|
c = x86_pmu.get_event_constraints(cpuc, cpuc->event_list[i]);
|
|
|
- constraints[i] = c;
|
|
|
+ hwc->constraint = c;
|
|
|
+
|
|
|
wmin = min(wmin, c->weight);
|
|
|
wmax = max(wmax, c->weight);
|
|
|
}
|
|
@@ -743,7 +744,7 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
|
*/
|
|
|
for (i = 0; i < n; i++) {
|
|
|
hwc = &cpuc->event_list[i]->hw;
|
|
|
- c = constraints[i];
|
|
|
+ c = hwc->constraint;
|
|
|
|
|
|
/* never assigned */
|
|
|
if (hwc->idx == -1)
|
|
@@ -764,7 +765,8 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
|
|
|
|
/* slow path */
|
|
|
if (i != n)
|
|
|
- num = perf_assign_events(constraints, n, wmin, wmax, assign);
|
|
|
+ num = perf_assign_events(cpuc->event_list, n, wmin,
|
|
|
+ wmax, assign);
|
|
|
|
|
|
/*
|
|
|
* scheduling failed or is just a simulation,
|