Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753687AbbFCIgg (ORCPT ); Wed, 3 Jun 2015 04:36:36 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:48071 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753178AbbFCIg0 (ORCPT ); Wed, 3 Jun 2015 04:36:26 -0400 Date: Wed, 3 Jun 2015 10:36:15 +0200 From: Peter Zijlstra To: Imre Palik 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 Message-ID: <20150603083615.GZ3644@twins.programming.kicks-ass.net> References: <1433318628-6330-1-git-send-email-imrep.amz@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433318628-6330-1-git-send-email-imrep.amz@gmail.com> 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: 1765 Lines: 47 On Wed, Jun 03, 2015 at 10:03:48AM +0200, Imre Palik wrote: > From: "Palik, Imre" > > perf doesn't seem to honor the number of fixed counters specified by cpuid > leaf 0xa. It always assume that intel CPUs have at least 3 fixed counters. > > So if some of the fixed counters are masked out by the hypervisor, it still > tries to check/set them. This is good for testing the masking code in the > hypervisor, but not so nice otherwise. > > This patch makes perf pehave somewhat nicer when the number of fixed > counters is less than three. > @@ -3042,13 +3042,6 @@ __init int intel_pmu_init(void) > > x86_pmu.max_pebs_events = min_t(unsigned, MAX_PEBS_EVENTS, x86_pmu.num_counters); > > - /* > - * Quirk: v2 perfmon does not report fixed-purpose events, so > - * assume at least 3 events: > - */ > - if (version > 1) > - x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3); > - > if (boot_cpu_has(X86_FEATURE_PDCM)) { > u64 capabilities; So the problem is that there is real hardware out there that gets the CPUID stuff wrong, and this patch penalizes that by then not using the fixed counters. Further, the Intel Arch PerfMon v2 spec actually specifies there to be 3 fixed function counters. So anything that says it is v2+ and does not have the 3, is non compliant. I would suggest you go fix your hypervisor. Lacking that option; you could probe the MSRs to see if they're really there using wrmsr_safe() or something like that -- see check_hw_exists(). -- 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/