1 From foo@baz Tue Mar 12 09:29:14 PDT 2019
2 From: "Peter Zijlstra (Intel)" <peterz@infradead.org>
3 Date: Tue, 5 Mar 2019 22:23:16 +0100
4 Subject: perf/x86/intel: Generalize dynamic constraint creation
6 From: "Peter Zijlstra (Intel)" <peterz@infradead.org>
8 Such that we can re-use it.
10 Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
11 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
12 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 arch/x86/events/intel/core.c | 51 +++++++++++++++++++++++++------------------
15 1 file changed, 30 insertions(+), 21 deletions(-)
17 --- a/arch/x86/events/intel/core.c
18 +++ b/arch/x86/events/intel/core.c
19 @@ -2769,6 +2769,35 @@ intel_stop_scheduling(struct cpu_hw_even
22 static struct event_constraint *
23 +dyn_constraint(struct cpu_hw_events *cpuc, struct event_constraint *c, int idx)
25 + WARN_ON_ONCE(!cpuc->constraint_list);
27 + if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
28 + struct event_constraint *cx;
31 + * grab pre-allocated constraint entry
33 + cx = &cpuc->constraint_list[idx];
36 + * initialize dynamic constraint
37 + * with static constraint
42 + * mark constraint as dynamic
44 + cx->flags |= PERF_X86_EVENT_DYNAMIC;
51 +static struct event_constraint *
52 intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
53 int idx, struct event_constraint *c)
55 @@ -2798,27 +2827,7 @@ intel_get_excl_constraints(struct cpu_hw
56 * only needed when constraint has not yet
57 * been cloned (marked dynamic)
59 - if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
60 - struct event_constraint *cx;
63 - * grab pre-allocated constraint entry
65 - cx = &cpuc->constraint_list[idx];
68 - * initialize dynamic constraint
69 - * with static constraint
74 - * mark constraint as dynamic, so we
75 - * can free it later on
77 - cx->flags |= PERF_X86_EVENT_DYNAMIC;
80 + c = dyn_constraint(cpuc, c, idx);
83 * From here on, the constraint is dynamic.