Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1829678pxb; Mon, 12 Apr 2021 07:40:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW1q32axoDA+9XBLVWQZnYunXripR3GRF4xkhROABKlO3FehvmbZuEMHhnIuUznENLk+Db X-Received: by 2002:a05:6402:2708:: with SMTP id y8mr30071323edd.265.1618238456654; Mon, 12 Apr 2021 07:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618238456; cv=none; d=google.com; s=arc-20160816; b=CMtlXPpG2eO9bnprlFKfgZu3N/PM6FiGopupZuNIXYDnO2aWYmJm59THoNhLgBCvSt YLy/YPt5uGs18rUriuARMBEtRkoZYgsNu50C+2LDFIEAkwRTXk3OjnzDBHyliXAG8IaS sUefcY1A9a3Qtb0DRRauOlvqf60VzTcdp3/J3ZLf0kud3bmZfAaJNai4ECsYIsAMyk9K Zpwo+tXSofP1E5qVD416pdZsXr+1bj8DLdpGSGQKAlgtYIfbs+KVEp9xtXf4MtP+56F+ zhNWUHbLesrojnIo29dm7rTR5NpF2HVEfgmNRCyho0WSr0wb5bQOoG4XYkUEMG3k78DZ nrJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=Uu6byMc8haYPYbdfZRYtoEVTPFlkZvc/jq50tugPbtY=; b=Z5Ds7ha/szHe6QyGzFTk2CHYBy/t16ECYIXVrxzXtOVPBzSSy76RVkaQYWaS04Ez/f R6iOK4zggDh4PRh32+nRMzLmRaxDHB46CzLEEHd1dQDnMqkIqPW5l5dUeRTrGFTb/+Fu HfK0HFNwqucg9WOzMlweqgs5wnI4EomF9/2cW6EIEeNomSDx+9UEJXCxLoJIG2IustlY iuyIt9mn2aBfPXKe8TWqXg6VWv80p0iXJ2AlQHf5tugLEl29MhMParHz9ve4qB8rZsEp LkUwc666plMl7Mxvv3jmk4cZ1Z0YQq8jMWVvNeRicygLPTXdepNT8qfl36ilaqoWLuRT XJDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si7755412ejt.459.2021.04.12.07.40.31; Mon, 12 Apr 2021 07:40:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242544AbhDLOjL (ORCPT + 99 others); Mon, 12 Apr 2021 10:39:11 -0400 Received: from mga09.intel.com ([134.134.136.24]:29202 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242415AbhDLOit (ORCPT ); Mon, 12 Apr 2021 10:38:49 -0400 IronPort-SDR: Q11OVG3ly4JcaVReYbHNUcY/vgpF9aQnlCx+7IleHUXgKouUBj6yc0J8Xzou6GJZGXd/QaJNt6 BPy3IfzB62Bw== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="194317984" X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="194317984" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 07:38:27 -0700 IronPort-SDR: Eu1vavvuJrd1v8PNFw/1Yf4iL2JkGJxif+610iniXaq4dtToJkXvakxDMh5sO/KwLt4xErASzI Olno2sy97LgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="398392812" Received: from otc-lr-04.jf.intel.com ([10.54.39.41]) by orsmga002.jf.intel.com with ESMTP; 12 Apr 2021 07:38:27 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: acme@kernel.org, tglx@linutronix.de, bp@alien8.de, namhyung@kernel.org, jolsa@redhat.com, ak@linux.intel.com, yao.jin@linux.intel.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, ricardo.neri-calderon@linux.intel.com, Kan Liang Subject: [PATCH V6 13/25] perf/x86/intel: Factor out intel_pmu_check_extra_regs Date: Mon, 12 Apr 2021 07:30:53 -0700 Message-Id: <1618237865-33448-14-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618237865-33448-1-git-send-email-kan.liang@linux.intel.com> References: <1618237865-33448-1-git-send-email-kan.liang@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang Each Hybrid PMU has to check and update its own extra registers before registration. The intel_pmu_check_extra_regs will be reused later to check the extra registers of each hybrid PMU. Reviewed-by: Andi Kleen Signed-off-by: Kan Liang --- arch/x86/events/intel/core.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 5c5f330..55ccfbb 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -5127,6 +5127,26 @@ static void intel_pmu_check_event_constraints(struct event_constraint *event_con } } +static void intel_pmu_check_extra_regs(struct extra_reg *extra_regs) +{ + struct extra_reg *er; + + /* + * Access extra MSR may cause #GP under certain circumstances. + * E.g. KVM doesn't support offcore event + * Check all extra_regs here. + */ + if (!extra_regs) + return; + + for (er = extra_regs; er->msr; er++) { + er->extra_msr_access = check_msr(er->msr, 0x11UL); + /* Disable LBR select mapping */ + if ((er->idx == EXTRA_REG_LBR) && !er->extra_msr_access) + x86_pmu.lbr_sel_map = NULL; + } +} + __init int intel_pmu_init(void) { struct attribute **extra_skl_attr = &empty_attrs; @@ -5138,7 +5158,6 @@ __init int intel_pmu_init(void) union cpuid10_eax eax; union cpuid10_ebx ebx; unsigned int fixed_mask; - struct extra_reg *er; bool pmem = false; int version, i; char *name; @@ -5795,19 +5814,7 @@ __init int intel_pmu_init(void) if (x86_pmu.lbr_nr) pr_cont("%d-deep LBR, ", x86_pmu.lbr_nr); - /* - * Access extra MSR may cause #GP under certain circumstances. - * E.g. KVM doesn't support offcore event - * Check all extra_regs here. - */ - if (x86_pmu.extra_regs) { - for (er = x86_pmu.extra_regs; er->msr; er++) { - er->extra_msr_access = check_msr(er->msr, 0x11UL); - /* Disable LBR select mapping */ - if ((er->idx == EXTRA_REG_LBR) && !er->extra_msr_access) - x86_pmu.lbr_sel_map = NULL; - } - } + intel_pmu_check_extra_regs(x86_pmu.extra_regs); /* Support full width counters using alternative MSR range */ if (x86_pmu.intel_cap.full_width_write) { -- 2.7.4