Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp705131pxt; Fri, 6 Aug 2021 11:38:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY22jxEpqP+FX8o+nRQcVq17onMKtxPVxXdclK+7Tz79jX72oC1S4DN6660b6xmJ4SlPuC X-Received: by 2002:a05:6638:39c2:: with SMTP id o2mr10778349jav.87.1628275086447; Fri, 06 Aug 2021 11:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628275086; cv=none; d=google.com; s=arc-20160816; b=PcVKl0/9zQ/bTTLjYRltGB7lbKLD9d32njDM0k6ppLFB+fBzpr43deGAtIOw4if2E0 6Hx9Y+NpztnfLJclJYcNTYVJh6sp3wTRGH+rtmnsl7361/bY6gA7uKTb8uTu+FBMzDTv Nvr5mHEFxreLBfKg+wKj60iholh7mQVnbzXnGPcqfgVcj7ns7gt5ZuElAlXTL0CtV1wn KJLW2oBtxw3LQSVPyAj9YyrEeKPrrFWMjyJABE4kws8ddnGhlhkyD8z8LDjdqvBx1tHb y3LrwsK2ctHbcBE/f9hIeW89LUgTCnxIXtTQZVL0dK1gK2pT65N5zKFnDKa/UQfKPie0 ohAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LlotFyihHBWPnbdempWFImlJZdk5aJV7fRFikZbVeLg=; b=VeQUPOQkIfhMGI9LXz1F76tCkljkGQiP0jA4FDl9SSRD+wEkY69IpgkvfnI2Rb22Ky xISoGbO7MCxgHDPCJzTP2f/vqTf2P/04svB6uFUFkCwZ75V6BovPacJ0AruTOOpNPF3G RTkSCI2Xh5Ip9exc/EpRQBY5FQHpwM+V38DxUDxyPZi3P0piWw+rdXMPakxVJeI4UUka /OTNlft1tY8Q0ex5gpfFlZggxfSvaIBK2fkG52wGHxIvVTg8+2wgz/Hs3mJafwlmIZrq MEfnMpudmHE4YxMXxhlLVVVqXfbEfT/KCFM+yPctlwLA2a0upAkQf4lh8j943uDOzUaF P3tQ== 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 y5si9005683ilb.113.2021.08.06.11.37.52; Fri, 06 Aug 2021 11:38:06 -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 S1344289AbhHFNjS (ORCPT + 99 others); Fri, 6 Aug 2021 09:39:18 -0400 Received: from mga18.intel.com ([134.134.136.126]:16714 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344278AbhHFNjL (ORCPT ); Fri, 6 Aug 2021 09:39:11 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10068"; a="201553572" X-IronPort-AV: E=Sophos;i="5.84,300,1620716400"; d="scan'208";a="201553572" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2021 06:38:55 -0700 X-IronPort-AV: E=Sophos;i="5.84,300,1620716400"; d="scan'208";a="523463468" Received: from vmm_a4_icx.sh.intel.com (HELO localhost.localdomain) ([10.239.53.245]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2021 06:38:50 -0700 From: Zhu Lingshan To: peterz@infradead.org, pbonzini@redhat.com Cc: bp@alien8.de, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kan.liang@linux.intel.com, ak@linux.intel.com, wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, like.xu.linux@gmail.com, boris.ostrvsky@oracle.com, Zhu Lingshan Subject: [PATCH V10 07/18] x86/perf/core: Add pebs_capable to store valid PEBS_COUNTER_MASK value Date: Fri, 6 Aug 2021 21:37:51 +0800 Message-Id: <20210806133802.3528-8-lingshan.zhu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210806133802.3528-1-lingshan.zhu@intel.com> References: <20210806133802.3528-1-lingshan.zhu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Peter Zijlstra (Intel)" The value of pebs_counter_mask will be accessed frequently for repeated use in the intel_guest_get_msrs(). So it can be optimized instead of endlessly mucking about with branches. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Zhu Lingshan --- arch/x86/events/intel/core.c | 14 ++++++-------- arch/x86/events/perf_event.h | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index e09cc8901524..552a623dc886 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2867,10 +2867,7 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status) * counters from the GLOBAL_STATUS mask and we always process PEBS * events via drain_pebs(). */ - if (x86_pmu.flags & PMU_FL_PEBS_ALL) - status &= ~cpuc->pebs_enabled; - else - status &= ~(cpuc->pebs_enabled & PEBS_COUNTER_MASK); + status &= ~(cpuc->pebs_enabled & x86_pmu.pebs_capable); /* * PEBS overflow sets bit 62 in the global status register @@ -3908,10 +3905,7 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) arr[0].msr = MSR_CORE_PERF_GLOBAL_CTRL; arr[0].host = intel_ctrl & ~cpuc->intel_ctrl_guest_mask; arr[0].guest = intel_ctrl & ~cpuc->intel_ctrl_host_mask; - if (x86_pmu.flags & PMU_FL_PEBS_ALL) - arr[0].guest &= ~cpuc->pebs_enabled; - else - arr[0].guest &= ~(cpuc->pebs_enabled & PEBS_COUNTER_MASK); + arr[0].guest &= ~(cpuc->pebs_enabled & x86_pmu.pebs_capable); *nr = 1; if (x86_pmu.pebs && x86_pmu.pebs_no_isolation) { @@ -5594,6 +5588,7 @@ __init int intel_pmu_init(void) x86_pmu.events_mask_len = eax.split.mask_length; x86_pmu.max_pebs_events = min_t(unsigned, MAX_PEBS_EVENTS, x86_pmu.num_counters); + x86_pmu.pebs_capable = PEBS_COUNTER_MASK; /* * Quirk: v2 perfmon does not report fixed-purpose events, so @@ -5778,6 +5773,7 @@ __init int intel_pmu_init(void) x86_pmu.pebs_aliases = NULL; x86_pmu.pebs_prec_dist = true; x86_pmu.lbr_pt_coexist = true; + x86_pmu.pebs_capable = ~0ULL; x86_pmu.flags |= PMU_FL_HAS_RSP_1; x86_pmu.flags |= PMU_FL_PEBS_ALL; x86_pmu.get_event_constraints = glp_get_event_constraints; @@ -6135,6 +6131,7 @@ __init int intel_pmu_init(void) x86_pmu.pebs_aliases = NULL; x86_pmu.pebs_prec_dist = true; x86_pmu.pebs_block = true; + x86_pmu.pebs_capable = ~0ULL; x86_pmu.flags |= PMU_FL_HAS_RSP_1; x86_pmu.flags |= PMU_FL_NO_HT_SHARING; x86_pmu.flags |= PMU_FL_PEBS_ALL; @@ -6178,6 +6175,7 @@ __init int intel_pmu_init(void) x86_pmu.pebs_aliases = NULL; x86_pmu.pebs_prec_dist = true; x86_pmu.pebs_block = true; + x86_pmu.pebs_capable = ~0ULL; x86_pmu.flags |= PMU_FL_HAS_RSP_1; x86_pmu.flags |= PMU_FL_NO_HT_SHARING; x86_pmu.flags |= PMU_FL_PEBS_ALL; diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index 1518f2754842..35d0a7ec5f20 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -807,6 +807,7 @@ struct x86_pmu { void (*pebs_aliases)(struct perf_event *event); unsigned long large_pebs_flags; u64 rtm_abort_event; + u64 pebs_capable; /* * Intel LBR -- 2.27.0