Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754617AbbFENCj (ORCPT ); Fri, 5 Jun 2015 09:02:39 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:35933 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754471AbbFENCf (ORCPT ); Fri, 5 Jun 2015 09:02:35 -0400 Message-ID: <55719DDB.9060507@gmail.com> Date: Fri, 05 Jun 2015 15:02:19 +0200 From: Imre Palik User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Peter Zijlstra CC: Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, "Palik, Imre" , Anthony Liguori Subject: Re: [RFC PATCH] perf: honoring cpuid for number of fixed counters References: <1433318628-6330-1-git-send-email-imrep.amz@gmail.com> <20150603083615.GZ3644@twins.programming.kicks-ass.net> <557029DC.6080201@gmail.com> <20150604114917.GI3644@twins.programming.kicks-ass.net> <557044ED.8060508@gmail.com> <20150604132955.GJ3644@twins.programming.kicks-ass.net> In-Reply-To: <20150604132955.GJ3644@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2252 Lines: 62 On 06/04/15 15:29, Peter Zijlstra wrote: > On Thu, Jun 04, 2015 at 02:30:37PM +0200, Imre Palik wrote: >> The trouble is that the number of fixed counters is not taken into >> account when scheduling the events, and the cpu model based event >> constraints will favour fixed counters. So perf tries to use them. > > Ah! so that is what your hunk below does. Tricky, and without comment > that. > > --- > > diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c > index 87848eb..eaa0b5e 100644 > --- a/arch/x86/kernel/cpu/perf_event.c > +++ b/arch/x86/kernel/cpu/perf_event.c > @@ -647,6 +647,8 @@ static void perf_sched_init(struct perf_sched *sched, struct perf_event **events > sched->state.event = idx; /* start with min weight */ > sched->state.weight = wmin; > sched->state.unassigned = num; > + sched->state.used[0] = > + ~0UL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed); > } > > static void perf_sched_save_state(struct perf_sched *sched) > > --- > > Please change the FIXED_EVENT constraints init instead; that way > validate_event() will actually work too, otherwise it thinks it can > schedule the fixed function only events. > > That is, change the below loop from intel_pmu_init(): > > if (x86_pmu.event_constraints) { > /* > * event on fixed counter2 (REF_CYCLES) only works on this > * counter, so do not extend mask to generic counters > */ > for_each_event_constraint(c, x86_pmu.event_constraints) { > if (c->cmask != FIXED_EVENT_FLAGS > || c->idxmsk64 == INTEL_PMC_MSK_FIXED_REF_CYCLES) { > continue; > } > > c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1; > c->weight += x86_pmu.num_counters; > } > } > > To clear all counters that are not in fact present, that way we keep the > event constraints correct instead of working around invalid constraints. Thanks. I knew there should be a better way ... Will post a new patch soon. -- 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/