All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Vince Weaver <vincent.weaver@maine.edu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Ingo Molnar <mingo@redhat.com>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: perf: odd event scheduling issue
Date: Wed, 20 May 2015 18:08:02 +0200	[thread overview]
Message-ID: <20150520160802.GL18673@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20150520152534.GJ18673@twins.programming.kicks-ass.net>

On Wed, May 20, 2015 at 05:25:34PM +0200, Peter Zijlstra wrote:

> > 
> > OK, so if you have the watchdog enabled, that's 1 event, and having a
> > max of 2 GP events, adding another 2 events is fail.
> 
> Hmm, so we count all events, including those scheduled on fixed purpose
> counters.
> 
> Lemme see if I can cure that.


Stephane, does something like the below make sense?

---
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 3998131..7e779e9 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -2008,27 +2039,15 @@ intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
 	xl = &excl_cntrs->states[tid];
 	xlo = &excl_cntrs->states[o_tid];
 
-	/*
-	 * do not allow scheduling of more than max_alloc_cntrs
-	 * which is set to half the available generic counters.
-	 * this helps avoid counter starvation of sibling thread
-	 * by ensuring at most half the counters cannot be in
-	 * exclusive mode. There is not designated counters for the
-	 * limits. Any N/2 counters can be used. This helps with
-	 * events with specifix counter constraints
-	 */
-	if (xl->num_alloc_cntrs++ == xl->max_alloc_cntrs)
-		return &emptyconstraint;
-
 	cx = c;
 
 	/*
-	 * because we modify the constraint, we need
+	 * Because we modify the constraint, we need
 	 * to make a copy. Static constraints come
 	 * from static const tables.
 	 *
-	 * only needed when constraint has not yet
-	 * been cloned (marked dynamic)
+	 * Only needed when constraint has not yet
+	 * been cloned (marked dynamic).
 	 */
 	if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) {
 
@@ -2062,6 +2081,22 @@ intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
 	 */
 
 	/*
+	 * Do not allow scheduling of more than max_alloc_cntrs
+	 * which is set to half the available generic counters.
+	 *
+	 * This helps avoid counter starvation of sibling thread
+	 * by ensuring at most half the counters cannot be in
+	 * exclusive mode. There is not designated counters for the
+	 * limits. Any N/2 counters can be used. This helps with
+	 * events with specifix counter constraints
+	 */
+	if (xl->num_alloc_cntrs++ >= xl->max_alloc_cntrs) {
+		/* wipe the GP counters */
+		cx->idxmsk64 &= ~((1ULL << INTEL_PMC_IDX_FIXED) - 1);
+		goto done;
+	}
+
+	/*
 	 * Modify static constraint with current dynamic
 	 * state of thread
 	 *
@@ -2086,6 +2121,7 @@ intel_get_excl_constraints(struct cpu_hw_events *cpuc, struct perf_event *event,
 			__clear_bit(i, cx->idxmsk);
 	}
 
+done:
 	/*
 	 * recompute actual bit weight for scheduling algorithm
 	 */

  reply	other threads:[~2015-05-20 16:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20  3:07 perf: odd event scheduling issue Vince Weaver
2015-05-20  7:00 ` Peter Zijlstra
2015-05-20  7:11   ` Jiri Olsa
2015-05-20  9:28   ` Peter Zijlstra
2015-05-20 13:52     ` Peter Zijlstra
2015-05-20 15:25       ` Peter Zijlstra
2015-05-20 16:08         ` Peter Zijlstra [this message]
2015-05-20 16:28           ` Peter Zijlstra
2015-05-20 23:10             ` Andi Kleen
2015-05-21 12:04               ` Stephane Eranian
2015-05-20 16:25       ` Jiri Olsa
2015-05-21 12:05         ` Stephane Eranian

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=20150520160802.GL18673@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=vincent.weaver@maine.edu \
    /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.