Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7152455rwb; Tue, 6 Dec 2022 01:45:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6rtepFZIpD8kqf+KgqNl+ZSPoHXdRy71fSgubLVOjotjE51cSoEpCw2iGSLY7uHe+AdEU6 X-Received: by 2002:a17:902:f707:b0:176:b0ce:3472 with SMTP id h7-20020a170902f70700b00176b0ce3472mr80997080plo.169.1670319948285; Tue, 06 Dec 2022 01:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670319948; cv=none; d=google.com; s=arc-20160816; b=ZT2ZooErr4VM92JhA6C1r0xwkIsamZmJL6+w9yyDhQIDKgFxvY4fUzn6pR322++txZ rwpFnjKVG3U5laJehvUZiZ0qOogKK5H6t16bEzonfZ0caQi6FNS96JvqU0Ki0+WNK0sv wznc3rrJcd05C8iwohlS8+to6z3tMiNRIOOQPfDocnX8Gmjvoeb6Xq3DCaaiklMZA83d zmLOH+cAcdfH5VKIf7cvL8pA9JVOzjTKAQe/2Aay94OnzUh8THFfEJzm/RtKAcIn7RNq Pyf6re0qIPN2wSuMeB/04bUIAn9TSF7wSTmjM2aV0B99AyG2xg0609oFekHNpJGqA1M/ 8SLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=xzDeAn3T9on2rhW/eu6X6jP1Lx7aE5A0px8AsSjmKbY=; b=proJICKq79Agh9t902Nvw83Tr0KU9w7ULQgjgiTY3o28DRoJJa1CILCERESoY4vHIa 5gkZOYkvcJfCm/yZvhM0aH0dCYcJqLdB97EfoWIeNEet/kFSpw2HUah206+dQcbwNuns B8fVJDML7kPa4p1ubbBvn63RKf8sUct5rtuFKIbazjs+uvjDITFzI2FEew+qPAa+wzRu j+zv1buLN0a5w6WChJtncPGYateI8FaVnYmnHZwOjPjZsALz8WdCQk2UV3FyCgT5uqjO 8udQ9VbQSlZrbNs26PeQ1vIF76D9G/0x5089OIQtkBqROmk5x1b6DUQXU9kmtIPWCuiV 4K/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HzG+bpie; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 95-20020a17090a0fe800b002192eb35333si18888531pjz.52.2022.12.06.01.45.37; Tue, 06 Dec 2022 01:45:48 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=HzG+bpie; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233826AbiLFIcr (ORCPT + 79 others); Tue, 6 Dec 2022 03:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234073AbiLFIce (ORCPT ); Tue, 6 Dec 2022 03:32:34 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FD6E1A3B5; Tue, 6 Dec 2022 00:32:28 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id a9so13238156pld.7; Tue, 06 Dec 2022 00:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=xzDeAn3T9on2rhW/eu6X6jP1Lx7aE5A0px8AsSjmKbY=; b=HzG+bpiecMEfO22N7lBkxACnq/O+0V3QU5FuXQr0lwwVxE66GaQaaboH2Wc1EnhwVO YgpdxC1GizKaRkV2Z397wVRgNC+/AecDzbPkJw0sJ7gRVwY646PhhUp5JSOIp/lgrePJ 98FZxjeuxMSeKdRY89V2aAd4hcGpj4x4rv/G7lFZAISZ78J+WzcnZna7XzzvIjXllube YVhFEUxQVAstvUjIb6LlJPmEllCozwJCVy/VbXBWNGhLS6ZCNhdkW+m3Jz/HYLFbSIJC aDj6188h5Ll3bDIe+X/xzKhgPJ/lvJf0Eg5xO52l/df0P2DGHMsEBnsIMzLQwNwyAPZ8 AEeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xzDeAn3T9on2rhW/eu6X6jP1Lx7aE5A0px8AsSjmKbY=; b=h/SqTFBsRP74P3z/opuqYfE2LxuCc8OJCkTyfJPwrmh3rosEnCp/8r9oMpsoA+3U10 qIjfknZLRtiZsFR1j7jQh544GOQtvtaW2o39nkxK6Gi882J69TnOzWd/YGL9e7R7hVp7 fesDBQH2xtM2XDnwEybeNSQ+AXL1Qh+uNFp3Ltjc7xbyZuJ30S9RxhdlmQ0bn4Wu4sKP c6OH/qO9mIFOZZnAOWPnpg6UvxrrGnWUPOodLBpfqqqeZmWGXp2BPnMIurNIaE4CV3Jy qWKvPLg+QYewzT95jSRQfQTkjBE5U4nKIsesGjqLyUaPojDt5/i9kNz9wiLinxKjYTxh NkIg== X-Gm-Message-State: ANoB5pkWzzrvF+dd94Suugx24CBftFb35UXxg8NBi6HVzk8PV6A876se r1HNRBlUHSF2wZ+HER90v8Q= X-Received: by 2002:a17:902:b48f:b0:189:8b6:95f6 with SMTP id y15-20020a170902b48f00b0018908b695f6mr69709447plr.71.1670315547707; Tue, 06 Dec 2022 00:32:27 -0800 (PST) Received: from [192.168.255.10] ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id bv5-20020a17090af18500b00219e38b42f5sm1709904pjb.26.2022.12.06.00.32.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Dec 2022 00:32:27 -0800 (PST) Message-ID: <8d49bc2c-796b-f122-225f-bdb4ca815ee6@gmail.com> Date: Tue, 6 Dec 2022 16:32:17 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v3 0/8] KVM: x86: Add AMD Guest PerfMonV2 PMU support Content-Language: en-US From: Like Xu To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson References: <20221111102645.82001-1-likexu@tencent.com> In-Reply-To: <20221111102645.82001-1-likexu@tencent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Any comments to move it forward ? On 11/11/2022 6:26 pm, Like Xu wrote: > Starting with Zen4, core PMU on AMD platforms such as Genoa and > Ryzen-7000 will support PerfMonV2, and it is also compatible with > legacy PERFCTR_CORE behavior and msr addresses. > > If you don't have access to the hardware specification, the commits > d6d0c7f681fd..7685665c390d for host perf can also bring a quick > overview. Its main change is the addition of three msr's equivalent > to Intel V2, namely global_ctrl, global_status, global_status_clear. > > It is worth noting that this feature is very attractive for reducing the > overhead of PMU virtualization, since multiple msr accesses to multiple > counters will be replaced by a single access to the global register, > plus more accuracy gain when multiple guest counters are used. > > All related testcases are passed on a Genoa box. > Please feel free to run more tests, add more or share comments. > > Previous: > https://lore.kernel.org/kvm/20220919093453.71737-1-likexu@tencent.com/ > > V2 -> V3 Changelog: > - Renme pmc_is_enabled(); (Jim) > - Move the reprogram_counters() changes as a separate patch; (Jim) > - Refactoring to align with other set_msr() helper; (Sean) > - Fix the issue if userspace wants to expose v1 for whatever reason; (Sean) > - Add the feature flag X86_FEATURE_AMD_PMU_V2; (Sean) > - Check enable_pmu for intel 0xa as well; (Sean) > - Limit AMD pmu's KVM support to version 2 as well; > - Other nit changes around C code taste; (Sean) > > Like Xu (7): > KVM: x86/pmu: Rename pmc_is_enabled() to pmc_is_globally_enabled() > KVM: x86/pmu: Rewrite reprogram_counters() to improve performance > KVM: x86/pmu: Make part of the Intel v2 PMU MSRs handling x86 generic > KVM: x86/cpuid: Add X86_FEATURE_AMD_PMU_V2 as a KVM-only leaf entry > KVM: x86/svm/pmu: Add AMD PerfMonV2 support > KVM: x86/cpuid: Add AMD CPUID ExtPerfMonAndDbg leaf 0x80000022 > KVM: x86/cpuid: Use fast return for cpuid "0xa" leaf when !enable_pmu > > Sean Christopherson (1): > KVM: VMX: Refactor intel_pmu_set_msr() to align with other set_msr() > helpers > > arch/x86/include/asm/kvm-x86-pmu-ops.h | 1 - > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/cpuid.c | 32 ++++++- > arch/x86/kvm/pmu.c | 65 +++++++++++++-- > arch/x86/kvm/pmu.h | 28 ++++++- > arch/x86/kvm/reverse_cpuid.h | 10 +++ > arch/x86/kvm/svm/pmu.c | 73 +++++++++++----- > arch/x86/kvm/svm/svm.c | 11 ++- > arch/x86/kvm/vmx/pmu_intel.c | 111 +++++++------------------ > arch/x86/kvm/x86.c | 14 +++- > 10 files changed, 228 insertions(+), 118 deletions(-) >