Skip to content

Commit 11f8b2d

Browse files
Peter Zijlstra (Intel)KAGA-KOKO
authored andcommitted
perf/x86/intel: Generalize dynamic constraint creation
Such that we can re-use it. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent d01b1f9 commit 11f8b2d

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

arch/x86/events/intel/core.c

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,6 +2768,35 @@ intel_stop_scheduling(struct cpu_hw_events *cpuc)
27682768
raw_spin_unlock(&excl_cntrs->lock);
27692769
}
27702770

2771+
static struct event_constraint *
2772+
dyn_constraint(struct cpu_hw_events *cpuc, struct event_constraint *c, int idx)
2773+
{
2774+
WARN_ON_ONCE(!cpuc->constraint_list);
2775+
2776+
if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
2777+
struct event_constraint *cx;
2778+
2779+
/*
2780+
* grab pre-allocated constraint entry
2781+
*/
2782+
cx = &cpuc->constraint_list[idx];
2783+
2784+
/*
2785+
* initialize dynamic constraint
2786+
* with static constraint
2787+
*/
2788+
*cx = *c;
2789+
2790+
/*
2791+
* mark constraint as dynamic
2792+
*/
2793+
cx->flags |= PERF_X86_EVENT_DYNAMIC;
2794+
c = cx;
2795+
}
2796+
2797+
return c;
2798+
}
2799+
27712800
static struct event_constraint *
27722801
intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
27732802
int idx, struct event_constraint *c)
@@ -2798,27 +2827,7 @@ intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
27982827
* only needed when constraint has not yet
27992828
* been cloned (marked dynamic)
28002829
*/
2801-
if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
2802-
struct event_constraint *cx;
2803-
2804-
/*
2805-
* grab pre-allocated constraint entry
2806-
*/
2807-
cx = &cpuc->constraint_list[idx];
2808-
2809-
/*
2810-
* initialize dynamic constraint
2811-
* with static constraint
2812-
*/
2813-
*cx = *c;
2814-
2815-
/*
2816-
* mark constraint as dynamic, so we
2817-
* can free it later on
2818-
*/
2819-
cx->flags |= PERF_X86_EVENT_DYNAMIC;
2820-
c = cx;
2821-
}
2830+
c = dyn_constraint(cpuc, c, idx);
28222831

28232832
/*
28242833
* From here on, the constraint is dynamic.

0 commit comments

Comments
 (0)