Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3233253pxb; Tue, 20 Apr 2021 03:49:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOmeAFWa3TW5kEIDTZyB1AZ+C+TcPHULv9IRru0eQHY9yRfJtJm3aRS0Mgy7b6g/KgDsdS X-Received: by 2002:a17:906:c290:: with SMTP id r16mr26991250ejz.241.1618915774503; Tue, 20 Apr 2021 03:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618915774; cv=none; d=google.com; s=arc-20160816; b=mosplf5ULYyjA6nyFew0djazbsHSECjvU+EATYA1CU+mb1jzm4v3X8kGSJS52+9Bmy mu0gipz8rFA5p++uhTRvIn+O8R9wub0GsfPW8LcndDNFSe8uZLElUXZ/bV88QZzcfnF9 gxdacSknfWqD5FiArAjcjlSPaBA7Mv+cYw5xU2BkFWI9Fl7COd4X/DhoNr35k0oz9AST mJP/ihHnQG/d5evdgD1RfRWJZs+LKV4VUwe9TmQFrQeNmu7Puav0aRfabC357jfvZOvu Tq1Kb7VuE2piFDUWubtkUW8W5rklqkxQ6quSz05qFGRjxSYZNDy79tl+V2/G6aBLJq9f ayhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=iUhV24AHF2gQf7jCEY6harnTV3RREe8Kfa2IMBsStjU=; b=AiPI/f2P2qmi05i45Btr/YHt/BqrYN9J8PB3APlg2Ngi4L0laGjBS1Ya1K/IqPgist Th+jPXvD41WeKmZFkzXb04sl3tPMT88rdhxTVKiBKIRKUFCnVA/iQaNQDYLM6a7QfWp+ Fj+rR+qIQxoWSi3ElJ7Mb13ZpmSPvoozXlGDoVaWEvXyAMtbhgE8AhChAfmspqyfgrTg nHSPw1N4+1fpXmssp+KJ8WxbUX/l67dbV52Y8KnGbOgNyt3ftHfxdI3V0kXE8jBZleQO +SXdxv+S57CTlfcX3Qrc1E4nsk3xsAhPcPkAHWS2FBzC4PVl97WSdkT2k1+ojRA7jaOy /y0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZL8FGYfl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="pm/8yNET"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fv22si13874238ejc.409.2021.04.20.03.49.10; Tue, 20 Apr 2021 03:49:34 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZL8FGYfl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="pm/8yNET"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232025AbhDTKsA (ORCPT + 99 others); Tue, 20 Apr 2021 06:48:00 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:51760 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231699AbhDTKrS (ORCPT ); Tue, 20 Apr 2021 06:47:18 -0400 Date: Tue, 20 Apr 2021 10:46:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1618915606; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iUhV24AHF2gQf7jCEY6harnTV3RREe8Kfa2IMBsStjU=; b=ZL8FGYflNYvcvC3ddLvZAuIdV3/5VB9Qqu68Dq3eJDZmBuXuyJzn5ROhwVh4pLjLFmt6BH Y6BnEo6v0W8m4tZPRImyQS0zJP5Fs0kwXTxVWHq+2BXDIwnKqpQV+EIdcU+yUT3tqXx+C4 nANeOR0tOWJNx9+PVCowrRHXkHKQeaQVdNYTf2PhYCV2BD8Xag6iJjMpwaqwkucLSHNu6i isD8mLR+yJ2NWEw24q9S+uc8uIDYaVYLwA8RuDXL+9Wjkm16ueDPY5Hd8z5aLR2U08rGl/ BlXx79MgEk9JhNomB0pdiaMCApz5l+ts8Gf/Qj9CXzlwCA5A42F0hR+EH8t0VQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1618915606; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iUhV24AHF2gQf7jCEY6harnTV3RREe8Kfa2IMBsStjU=; b=pm/8yNETuxXde9y2y1xmLeIshLEVyFhns/vi87INW/xYAqR7cFAqs3gCJYfrmG7qmOkZJm DQahu1mKEt7ZMZBQ== From: "tip-bot2 for Kan Liang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/intel: Factor out intel_pmu_check_extra_regs Cc: Kan Liang , "Peter Zijlstra (Intel)" , Andi Kleen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1618237865-33448-14-git-send-email-kan.liang@linux.intel.com> References: <1618237865-33448-14-git-send-email-kan.liang@linux.intel.com> MIME-Version: 1.0 Message-ID: <161891560539.29796.12004051168002944954.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 34d5b61f29eea656be4283213273c33d5987e4d2 Gitweb: https://git.kernel.org/tip/34d5b61f29eea656be4283213273c33d5987e4d2 Author: Kan Liang AuthorDate: Mon, 12 Apr 2021 07:30:53 -07:00 Committer: Peter Zijlstra CommitterDate: Mon, 19 Apr 2021 20:03:26 +02:00 perf/x86/intel: Factor out intel_pmu_check_extra_regs 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. Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Andi Kleen Link: https://lkml.kernel.org/r/1618237865-33448-14-git-send-email-kan.liang@linux.intel.com --- 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) {