Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754958AbbETQII (ORCPT ); Wed, 20 May 2015 12:08:08 -0400 Received: from casper.infradead.org ([85.118.1.10]:34644 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754919AbbETQIG (ORCPT ); Wed, 20 May 2015 12:08:06 -0400 Date: Wed, 20 May 2015 18:08:02 +0200 From: Peter Zijlstra To: Vince Weaver Cc: LKML , Stephane Eranian , Arnaldo Carvalho de Melo , Jiri Olsa , Ingo Molnar , Paul Mackerras Subject: Re: perf: odd event scheduling issue Message-ID: <20150520160802.GL18673@twins.programming.kicks-ass.net> References: <20150520070057.GK3644@twins.programming.kicks-ass.net> <20150520092842.GF18673@twins.programming.kicks-ass.net> <20150520135209.GI18673@twins.programming.kicks-ass.net> <20150520152534.GJ18673@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150520152534.GJ18673@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2900 Lines: 86 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 */ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/