|
@@ -620,7 +620,7 @@ struct sched_state {
|
|
struct perf_sched {
|
|
struct perf_sched {
|
|
int max_weight;
|
|
int max_weight;
|
|
int max_events;
|
|
int max_events;
|
|
- struct perf_event **events;
|
|
|
|
|
|
+ struct event_constraint **constraints;
|
|
struct sched_state state;
|
|
struct sched_state state;
|
|
int saved_states;
|
|
int saved_states;
|
|
struct sched_state saved[SCHED_STATES_MAX];
|
|
struct sched_state saved[SCHED_STATES_MAX];
|
|
@@ -629,7 +629,7 @@ struct perf_sched {
|
|
/*
|
|
/*
|
|
* Initialize interator that runs through all events and counters.
|
|
* Initialize interator that runs through all events and counters.
|
|
*/
|
|
*/
|
|
-static void perf_sched_init(struct perf_sched *sched, struct perf_event **events,
|
|
|
|
|
|
+static void perf_sched_init(struct perf_sched *sched, struct event_constraint **constraints,
|
|
int num, int wmin, int wmax)
|
|
int num, int wmin, int wmax)
|
|
{
|
|
{
|
|
int idx;
|
|
int idx;
|
|
@@ -637,10 +637,10 @@ static void perf_sched_init(struct perf_sched *sched, struct perf_event **events
|
|
memset(sched, 0, sizeof(*sched));
|
|
memset(sched, 0, sizeof(*sched));
|
|
sched->max_events = num;
|
|
sched->max_events = num;
|
|
sched->max_weight = wmax;
|
|
sched->max_weight = wmax;
|
|
- sched->events = events;
|
|
|
|
|
|
+ sched->constraints = constraints;
|
|
|
|
|
|
for (idx = 0; idx < num; idx++) {
|
|
for (idx = 0; idx < num; idx++) {
|
|
- if (events[idx]->hw.constraint->weight == wmin)
|
|
|
|
|
|
+ if (constraints[idx]->weight == wmin)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -687,7 +687,7 @@ static bool __perf_sched_find_counter(struct perf_sched *sched)
|
|
if (sched->state.event >= sched->max_events)
|
|
if (sched->state.event >= sched->max_events)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- c = sched->events[sched->state.event]->hw.constraint;
|
|
|
|
|
|
+ c = sched->constraints[sched->state.event];
|
|
/* Prefer fixed purpose counters */
|
|
/* Prefer fixed purpose counters */
|
|
if (c->idxmsk64 & (~0ULL << INTEL_PMC_IDX_FIXED)) {
|
|
if (c->idxmsk64 & (~0ULL << INTEL_PMC_IDX_FIXED)) {
|
|
idx = INTEL_PMC_IDX_FIXED;
|
|
idx = INTEL_PMC_IDX_FIXED;
|
|
@@ -745,7 +745,7 @@ static bool perf_sched_next_event(struct perf_sched *sched)
|
|
if (sched->state.weight > sched->max_weight)
|
|
if (sched->state.weight > sched->max_weight)
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- c = sched->events[sched->state.event]->hw.constraint;
|
|
|
|
|
|
+ c = sched->constraints[sched->state.event];
|
|
} while (c->weight != sched->state.weight);
|
|
} while (c->weight != sched->state.weight);
|
|
|
|
|
|
sched->state.counter = 0; /* start with first counter */
|
|
sched->state.counter = 0; /* start with first counter */
|
|
@@ -756,12 +756,12 @@ static bool perf_sched_next_event(struct perf_sched *sched)
|
|
/*
|
|
/*
|
|
* Assign a counter for each event.
|
|
* Assign a counter for each event.
|
|
*/
|
|
*/
|
|
-int perf_assign_events(struct perf_event **events, int n,
|
|
|
|
|
|
+int perf_assign_events(struct event_constraint **constraints, int n,
|
|
int wmin, int wmax, int *assign)
|
|
int wmin, int wmax, int *assign)
|
|
{
|
|
{
|
|
struct perf_sched sched;
|
|
struct perf_sched sched;
|
|
|
|
|
|
- perf_sched_init(&sched, events, n, wmin, wmax);
|
|
|
|
|
|
+ perf_sched_init(&sched, constraints, n, wmin, wmax);
|
|
|
|
|
|
do {
|
|
do {
|
|
if (!perf_sched_find_counter(&sched))
|
|
if (!perf_sched_find_counter(&sched))
|
|
@@ -788,9 +788,9 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
x86_pmu.start_scheduling(cpuc);
|
|
x86_pmu.start_scheduling(cpuc);
|
|
|
|
|
|
for (i = 0, wmin = X86_PMC_IDX_MAX, wmax = 0; i < n; i++) {
|
|
for (i = 0, wmin = X86_PMC_IDX_MAX, wmax = 0; i < n; i++) {
|
|
- hwc = &cpuc->event_list[i]->hw;
|
|
|
|
|
|
+ cpuc->event_constraint[i] = NULL;
|
|
c = x86_pmu.get_event_constraints(cpuc, i, cpuc->event_list[i]);
|
|
c = x86_pmu.get_event_constraints(cpuc, i, cpuc->event_list[i]);
|
|
- hwc->constraint = c;
|
|
|
|
|
|
+ cpuc->event_constraint[i] = c;
|
|
|
|
|
|
wmin = min(wmin, c->weight);
|
|
wmin = min(wmin, c->weight);
|
|
wmax = max(wmax, c->weight);
|
|
wmax = max(wmax, c->weight);
|
|
@@ -801,7 +801,7 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
*/
|
|
*/
|
|
for (i = 0; i < n; i++) {
|
|
for (i = 0; i < n; i++) {
|
|
hwc = &cpuc->event_list[i]->hw;
|
|
hwc = &cpuc->event_list[i]->hw;
|
|
- c = hwc->constraint;
|
|
|
|
|
|
+ c = cpuc->event_constraint[i];
|
|
|
|
|
|
/* never assigned */
|
|
/* never assigned */
|
|
if (hwc->idx == -1)
|
|
if (hwc->idx == -1)
|
|
@@ -821,9 +821,10 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
}
|
|
}
|
|
|
|
|
|
/* slow path */
|
|
/* slow path */
|
|
- if (i != n)
|
|
|
|
- unsched = perf_assign_events(cpuc->event_list, n, wmin,
|
|
|
|
|
|
+ if (i != n) {
|
|
|
|
+ unsched = perf_assign_events(cpuc->event_constraint, n, wmin,
|
|
wmax, assign);
|
|
wmax, assign);
|
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
/*
|
|
* In case of success (unsched = 0), mark events as committed,
|
|
* In case of success (unsched = 0), mark events as committed,
|
|
@@ -840,7 +841,7 @@ int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)
|
|
e = cpuc->event_list[i];
|
|
e = cpuc->event_list[i];
|
|
e->hw.flags |= PERF_X86_EVENT_COMMITTED;
|
|
e->hw.flags |= PERF_X86_EVENT_COMMITTED;
|
|
if (x86_pmu.commit_scheduling)
|
|
if (x86_pmu.commit_scheduling)
|
|
- x86_pmu.commit_scheduling(cpuc, e, assign[i]);
|
|
|
|
|
|
+ x86_pmu.commit_scheduling(cpuc, i, assign[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1292,8 +1293,10 @@ static void x86_pmu_del(struct perf_event *event, int flags)
|
|
x86_pmu.put_event_constraints(cpuc, event);
|
|
x86_pmu.put_event_constraints(cpuc, event);
|
|
|
|
|
|
/* Delete the array entry. */
|
|
/* Delete the array entry. */
|
|
- while (++i < cpuc->n_events)
|
|
|
|
|
|
+ while (++i < cpuc->n_events) {
|
|
cpuc->event_list[i-1] = cpuc->event_list[i];
|
|
cpuc->event_list[i-1] = cpuc->event_list[i];
|
|
|
|
+ cpuc->event_constraint[i-1] = cpuc->event_constraint[i];
|
|
|
|
+ }
|
|
--cpuc->n_events;
|
|
--cpuc->n_events;
|
|
|
|
|
|
perf_event_update_userpage(event);
|
|
perf_event_update_userpage(event);
|