Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753221AbbFCIFL (ORCPT ); Wed, 3 Jun 2015 04:05:11 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:36059 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753022AbbFCIFB (ORCPT ); Wed, 3 Jun 2015 04:05:01 -0400 From: Imre Palik To: Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, "Palik, Imre" , Anthony Liguori Subject: [RFC PATCH] perf: honoring cpuid for number of fixed counters Date: Wed, 3 Jun 2015 10:03:48 +0200 Message-Id: <1433318628-6330-1-git-send-email-imrep.amz@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2174 Lines: 58 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. Signed-off-by: Imre Palik Cc: Anthony Liguori --- arch/x86/kernel/cpu/perf_event.c | 2 ++ arch/x86/kernel/cpu/perf_event_intel.c | 7 ------- 2 files changed, 2 insertions(+), 7 deletions(-) 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) diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index 3998131..60beb98 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c @@ -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; -- 1.7.9.5 -- 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/