Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4851328rwb; Tue, 8 Aug 2023 15:12:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxHgCSFSh3zjGL9Yc4obTDl+8JXGHt1w0W8yJaJrzrhQDZNgNJsEJAy2fJFV7pW9ZyKviA X-Received: by 2002:a2e:8556:0:b0:2b9:3db7:322f with SMTP id u22-20020a2e8556000000b002b93db7322fmr584306ljj.18.1691532754624; Tue, 08 Aug 2023 15:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691532754; cv=none; d=google.com; s=arc-20160816; b=rm2WmH4rOrVd18yZhlHjCph9hRxYuN8aHTXk20406QdNmjf3w2jlBr6kV+lMIIhZ0q OFTQal7Ql9geGRSLfxg7m+oqGsJwKZpJMdjYV0A5jFT+QCgCvV8GvWhlv4jFMxR70kWg VK4FAGWuHLnySf6tN7OCJKba9JcM9AnRDZ0iOGPA9JxCobLkklGwEfo+EMd3IlQ+UfGP S8KcE7jJahWG52RPUlllh5BfGbLRS3RfIE4+NRTeZLfWr+aG41bfUEAtpdzV/pU0SoWs ZpQ1OphMp7eawffuYUKhx6rOQrEsHUAQ0rGkZyjm7DmzaR/rwGNzsF+KuhM1lV8rRQac kHXQ== 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=Np+2jKUk8LM6BqEa65QI//Cez/n2tM8MrHMBmSWHTbk=; fh=UPwqiesAqvJCK7JcrgEpVEdaX86ysnZ9K1cUIusTBBs=; b=s1TTRkCRRxkEotyAqrWmjmdIQ0yLhIpyKUlS2qtOHnb6WegTj40Thk7NATbXtYA86Y gC1zy3Fb/cG+B7M0kKNPlfKAmsHZsYQJmxOK/kzaaSyO7/B+HlQs0WUNj7YzJJH3HGh7 mUiOmDnuTLhSP7JQXw9Xe8juDq76J0WPUtu5eIWe8D7ygtnObxi3xy0ayJcaly0LYxpk kSF3II1RaUTGQM3xx4x7QMcIhYUfkljLth6/TnSPVGTmvPViAW678J4NEX/1N3OVK+ON Z71GOA5P8rvmX531z0dkchyN2p9WDfDE13zkYuHzXaaRSzIzGkQAj4xX7DUG9Jxc4m47 8Q1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GPXTmSBv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a1709064b1000b00992f30b2983si5001168eju.849.2023.08.08.15.12.01; Tue, 08 Aug 2023 15:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GPXTmSBv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230511AbjHHTCh (ORCPT + 99 others); Tue, 8 Aug 2023 15:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232573AbjHHTBs (ORCPT ); Tue, 8 Aug 2023 15:01:48 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 003E58DCD4; Tue, 8 Aug 2023 10:31: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=1691515897; x=1723051897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vG6JB09+GdX1oexJrBx3ofjZYO0vUM/vdHaobdJsMXA=; b=GPXTmSBvKShziwPJpNMQ/NqkizdqsyKzjE+FqqleekuE2zTH1QPDwDpn FjzgaS1tOjI4xbGvAvt3y8oZpdxJcbAb9AQMwDYXzCnPCnCvy/9gAfs0V zNciEbnmDLiE4oRF2L6T2UWfp2O5aFszXvsL3C6k8dafEZx4KQ5/BN6V9 GuMp1Rg65oSJDsMxGV3cDsru5OjtTjATPL8jyv2OP3Zakix1ktBdgRmHi pk1T3SaHOFtWzIQx6FCKvMUmsZS2Srnja3uk18fxaEPYgACcDjvulRbke e8LbiwaSL6ZzzvTbcixu0wKRc7Ysn9fHf8y+xGeLG9v+DCSp41PFyM1eb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="434581889" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="434581889" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2023 23:25:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="734377216" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="734377216" Received: from dmi-pnp-i7.sh.intel.com ([10.239.159.155]) by fmsmga007.fm.intel.com with ESMTP; 07 Aug 2023 23:25:32 -0700 From: Dapeng Mi To: Sean Christopherson , Paolo Bonzini , Peter Zijlstra , Arnaldo Carvalho de Melo , Kan Liang , Like Xu , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter Cc: kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhang Xiong , Lv Zhiyuan , Yang Weijiang , Dapeng Mi , Dapeng Mi Subject: [PATCH RFV v2 01/13] KVM: x86/pmu: Add Intel CPUID-hinted TopDown slots event Date: Tue, 8 Aug 2023 14:30:59 +0800 Message-Id: <20230808063111.1870070-2-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808063111.1870070-1-dapeng1.mi@linux.intel.com> References: <20230808063111.1870070-1-dapeng1.mi@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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 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 f2efa0bf7ae8..7322f0c18565 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