Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp103728rdb; Tue, 31 Oct 2023 01:58:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcfXm9BqVuzmxXuSl3hpMQ9D6+LkaHWn/TDtHhZDtQoHAi2yesDtCdA7FuwyE3loW6jNkl X-Received: by 2002:a17:902:778a:b0:1cc:2dae:a558 with SMTP id o10-20020a170902778a00b001cc2daea558mr9379300pll.61.1698742730641; Tue, 31 Oct 2023 01:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698742730; cv=none; d=google.com; s=arc-20160816; b=sWXP6weuOScZWfh14p/utDJT9BvV8MyMwKMCoLUxgOTZDqNz7/E+tn5D0y1nSb6cbD rxeiw8cLu4LLxTFqfHY9gPeHyAVHbTHTd+U1fsS+W/koxev3Ey6tVq7RCg1Fe/b7okRR mbQh5BCr5TD30wAMKMQfW0nGRUY+UDMRG5JhgsrdY5RviTs+vvDfjfeOa6DAbCrFGFVn buA3Sr58435ZYH63/Rqa2dV5T7/rdldOSVNr/hapQQoYWx3MPNaaiApAXkahDBQKtEJE 69H/5H4Ln+spj508sKymumcUs4jr5sFsz6OtepmUCKUhE/UPC/1JyHBrDoVYtekyVkbT TBFQ== 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 :dkim-signature; bh=GgRX77cs8rflrmNZS/8wLzNxeTB1eu2/lp9YpL+JrCA=; fh=r/CSYkmVqow/F40IE/fnZlug3mhg+bnKYMiBh80d4zU=; b=dwuzVdFoq47Kn4x+XsujzDFhW5IaYP2RznP/hIpadrqb7/iUANhZwiCh2kVEUg4R/V Tp2bLbqdI7SUvKyUWIpxJngkushztgdG5yLM/ffAr40A7nc7xXQqWl489owyh0bgyjFA U5Cg/Sv+M4O0rSC6SURjhV+UVE8JHLH+XptmMERXyEPemo0WbtUYAj/m/q8o2snv8fLC LdWBOSF7H5fZEh0HbOgaLHMuE+pb3F7ZtjeYCM+vLfme+OrZSThRqrruPpD0rq1BRJtM alpWRkaizceM8AbK4JwHEtWy4WdIkTBM+ZXyCKK4suAQfe1oTvomLAQE9wBsMn8R2NHY NkEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WTXfm0YY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a17-20020a170902ecd100b001cc467f87f8si723615plh.381.2023.10.31.01.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 01:58:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WTXfm0YY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AC705802733E; Tue, 31 Oct 2023 01:58:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235760AbjJaI6p (ORCPT + 99 others); Tue, 31 Oct 2023 04:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235752AbjJaI6j (ORCPT ); Tue, 31 Oct 2023 04:58:39 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70698E6; Tue, 31 Oct 2023 01:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698742717; x=1730278717; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s+JsvEs7Ok+DvIu+DU/KDBtPTG9fSNGUmHldnUjJuQ4=; b=WTXfm0YYVuUYEq7pFLQl/n1dtLhDpTTbt2vtE4Cs5lb1HnO/EhJKN0dK J7dheZWvubuqY0dQAR9SxhpH004ZfgGKLBsnWP/cGl9R9hreF1xt/qxyh 1+hQidcOGfBdUGyo6jPPOTojTNsDWEb0BJ5Qm8l4MaqjLKfy0q0Tu1IlI LlSuANBYJNQGxpwChUrn6p7shjkI/aACgISZFCjZ1pHudXtFnptuXbGct WikyLomzmzFHp/7MFcL1OwHUKSu2imDa6imIpGDcWVr9m0LO5BfSlpWFr SaxkFZqS30BqydKndD2+elMC3FIlvueWgTpe4tpmsI/D6Z7+289VysDHV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10879"; a="378627556" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="378627556" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 01:58:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="8257897" Received: from dmi-pnp-i7.sh.intel.com ([10.239.159.155]) by orviesa001.jf.intel.com with ESMTP; 31 Oct 2023 01:58:34 -0700 From: Dapeng Mi To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhang Xiong , Jim Mattson , Mingwei Zhang , Like Xu , Dapeng Mi , Dapeng Mi , Like Xu Subject: [Patch 1/2] KVM: x86/pmu: Add Intel CPUID-hinted TopDown slots event Date: Tue, 31 Oct 2023 17:06:12 +0800 Message-Id: <20231031090613.2872700-2-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231031090613.2872700-1-dapeng1.mi@linux.intel.com> References: <20231031090613.2872700-1-dapeng1.mi@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 01:58:49 -0700 (PDT) This patch adds support for the architectural topdown slots event which is hinted by CPUID.0AH.EBX. The topdown slots event counts the total number of available slots for an unhalted logical processor. Software can use this event as the denominator for the top-level metrics of the topDown Microarchitecture Analysis method. Although the MSR_PERF_METRICS MSR required for topdown events is not currently available in the guest, relying only on the data provided by the slots event is sufficient for pmu users to perceive differences in cpu pipeline machine-width across micro-architectures. The standalone slots event, like the instruction event, can be counted with gp counter or fixed counter 3 (if any). Its availability is also controlled by CPUID.AH.EBX. On Linux, perf user may encode "-e cpu/event=0xa4,umask=0x01/" or "-e cpu/slots/" to count slots events. This patch only enables slots event on GP counters. The enabling on fixed counter 3 will be supported in subsequent patches. Co-developed-by: Like Xu Signed-off-by: Like Xu Signed-off-by: Dapeng Mi --- arch/x86/kvm/vmx/pmu_intel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 820d3e1f6b4f..e32353f1143f 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -34,6 +34,7 @@ enum intel_pmu_architectural_events { INTEL_ARCH_LLC_MISSES, INTEL_ARCH_BRANCHES_RETIRED, INTEL_ARCH_BRANCHES_MISPREDICTED, + INTEL_ARCH_TOPDOWN_SLOTS, NR_REAL_INTEL_ARCH_EVENTS, @@ -58,6 +59,7 @@ static struct { [INTEL_ARCH_LLC_MISSES] = { 0x2e, 0x41 }, [INTEL_ARCH_BRANCHES_RETIRED] = { 0xc4, 0x00 }, [INTEL_ARCH_BRANCHES_MISPREDICTED] = { 0xc5, 0x00 }, + [INTEL_ARCH_TOPDOWN_SLOTS] = { 0xa4, 0x01 }, [PSEUDO_ARCH_REFERENCE_CYCLES] = { 0x00, 0x03 }, }; -- 2.34.1