Skip to content

Commit

Permalink
perf/x86/intel: Generalize dynamic constraint creation
Browse files Browse the repository at this point in the history
Such that we can re-use it.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Peter Zijlstra (Intel) authored and Thomas Gleixner committed Mar 6, 2019
1 parent d01b1f9 commit 11f8b2d
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions arch/x86/events/intel/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,35 @@ intel_stop_scheduling(struct cpu_hw_events *cpuc)
raw_spin_unlock(&excl_cntrs->lock);
}

static struct event_constraint *
dyn_constraint(struct cpu_hw_events *cpuc, struct event_constraint *c, int idx)
{
WARN_ON_ONCE(!cpuc->constraint_list);

if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
struct event_constraint *cx;

/*
* grab pre-allocated constraint entry
*/
cx = &cpuc->constraint_list[idx];

/*
* initialize dynamic constraint
* with static constraint
*/
*cx = *c;

/*
* mark constraint as dynamic
*/
cx->flags |= PERF_X86_EVENT_DYNAMIC;
c = cx;
}

return c;
}

static struct event_constraint *
intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
int idx, struct event_constraint *c)
Expand Down Expand Up @@ -2798,27 +2827,7 @@ intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
* only needed when constraint has not yet
* been cloned (marked dynamic)
*/
if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
struct event_constraint *cx;

/*
* grab pre-allocated constraint entry
*/
cx = &cpuc->constraint_list[idx];

/*
* initialize dynamic constraint
* with static constraint
*/
*cx = *c;

/*
* mark constraint as dynamic, so we
* can free it later on
*/
cx->flags |= PERF_X86_EVENT_DYNAMIC;
c = cx;
}
c = dyn_constraint(cpuc, c, idx);

/*
* From here on, the constraint is dynamic.
Expand Down

0 comments on commit 11f8b2d

Please sign in to comment.