Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757527AbcJZJUS (ORCPT ); Wed, 26 Oct 2016 05:20:18 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36084 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752941AbcJZJUQ (ORCPT ); Wed, 26 Oct 2016 05:20:16 -0400 Date: Wed, 26 Oct 2016 11:16:44 +0200 From: Peter Zijlstra To: Imre Palik Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Andi Kleen , Stephane Eranian , Kan Liang , David Carrillo-Cisneros , linux-kernel@vger.kernel.org, Alexander Kozyrev , Artyom Kuanbekov , Imre Palik , Matt Wilson , David Woodhouse Subject: Re: [RFC PATCH v2] perf: honouring the cpuid for number of fixed counters in hypervisors Message-ID: <20161026091644.GB3102@twins.programming.kicks-ass.net> References: <1477037939-15605-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: <1477037939-15605-1-git-send-email-imrep.amz@gmail.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 875 Lines: 31 On Fri, Oct 21, 2016 at 01:18:59AM -0700, Imre Palik wrote: > +++ b/arch/x86/events/intel/core.c > @@ -3607,10 +3607,14 @@ __init int intel_pmu_init(void) > > /* > * Quirk: v2 perfmon does not report fixed-purpose events, so > + * assume at least 3 events, when not running in a hypervisor: > */ > + if (version > 1) { > + if (static_cpu_has(X86_FEATURE_HYPERVISOR)) > + x86_pmu.num_counters_fixed = edx.split.num_counters_fixed; > + else > + x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3); > + } I made that: /* * Quirk: v2 perfmon does not report fixed-purpose events, so + * assume at least 3 events, when not running in a hypervisor: */ + if (version > 1) { + int assume = 3 * !boot_cpu_has(X86_FEATURE_HYPERVISOR); + + x86_pmu.num_counters_fixed = + max((int)edx.split.num_counters_fixed, assume); + } Thanks!