All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: speck@linutronix.de
Subject: [MODERATED] [PATCH v2 2/4] perf/x86/intel: Generalize dynamic constraint creation
Date: Tue, 05 Mar 2019 22:23:16 +0100	[thread overview]
Message-ID: <20190305212524.492323410@infradead.org> (raw)
In-Reply-To: 20190305212314.203073493@infradead.org

Such that we can re-use it.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/events/intel/core.c |   51 +++++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 21 deletions(-)

--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -2770,6 +2770,35 @@ intel_stop_scheduling(struct cpu_hw_even
 }
 
 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)
 {
@@ -2799,27 +2828,7 @@ intel_get_excl_constraints(struct cpu_hw
 	 * 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.

  parent reply	other threads:[~2019-03-05 21:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05 21:23 [MODERATED] [PATCH v2 0/4] performance walnuts Peter Zijlstra
2019-03-05 21:23 ` [MODERATED] [PATCH v2 1/4] perf/x86/intel: Make cpuc allocations consistent Peter Zijlstra
2019-03-05 21:23 ` Peter Zijlstra [this message]
2019-03-05 21:23 ` [MODERATED] [PATCH v2 3/4] x86: Add TSX Force Abort CPUID/MSR Peter Zijlstra
2019-03-05 21:23 ` [MODERATED] [PATCH v2 4/4] perf/x86/intel: Implement support for TSX Force Abort Peter Zijlstra
2019-03-05 22:19 ` [MODERATED] Re: [PATCH v2 0/4] performance walnuts Linus Torvalds
2019-03-05 22:26   ` Jiri Kosina
2019-03-05 22:33   ` Nelson D'Souza
2019-03-06  9:23 ` Thomas Gleixner
2019-03-06 11:56   ` [MODERATED] " Greg KH
2019-03-06 13:02     ` David Woodhouse
2019-03-06 18:08       ` Greg KH
2019-03-06 18:32         ` Mark Hatle
2019-03-07 14:12           ` Greg KH
2019-03-07 17:42             ` Mark Hatle
2019-03-07 20:07             ` Thomas Gleixner
2019-03-07 14:13     ` [MODERATED] " Greg KH
2019-03-07 21:42       ` mark gross
2019-03-07 22:06         ` Greg KH
2019-03-08  9:15           ` Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190305212524.492323410@infradead.org \
    --to=peterz@infradead.org \
    --cc=speck@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.