Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1770516ybg; Thu, 4 Jun 2020 19:35:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGzhz9re9UQRsAHFZJE5pkEAa4olCx0BqElN/IXu2BLqE8aWxCRh2r4EiXIoEEAyGFa7Ns X-Received: by 2002:aa7:c254:: with SMTP id y20mr7133573edo.363.1591324508492; Thu, 04 Jun 2020 19:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591324508; cv=none; d=google.com; s=arc-20160816; b=zfT24dw5yT+qZvQ2npJcXKdelMF0kkBjIknEk0LH7HvKs9GjFHI/8eTT2EyM4mMm1J RYJiaQhg7X6NMzZiZgOATXSZ7vCE9KSIOYcj87DnRMiArNY4f6j8PZ1UD6rCIvkgsbZj q2lTx+64N/fudr3cb58x65tIe4TfssbBpTpBD1+lKblIv9S8WBtlRpKShkMFizZUjz+K TvPHXNf+DxTOabOm0rRVvbY20cj6naMlbv3fldjmuJXl5tDiP3jh+y3wJmPpdKhqRSha vzJmuU3WM3uz5Xm5s7eldGF769ncBF+z9Uc6ZuxYp+uUSl+HWhY0YnLb1qjXhgvrEjbp z2jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:cc:references:to:subject:reply-to :ironport-sdr:ironport-sdr; bh=PTcMSHx6rWIDrBc1GYXEgJu/VGBBuNyqy/iO2Fne5aM=; b=BPidyGr+qAMNnYw2POlVqjBNaFraYXOmgucWJf6YvyPaM4Dv6fsQpAvyIcFuYEFyhm DfmmR14NmEE46oSONFAEzRzKxbjjqvOAdhU8BMZq2DCUJhWTwQFfl/ZGd1wiY/LixpEM Dtz4qio0XapmitbGRmk7seeRLtowbHx9W0MFWOE4oqOl8K6ZGRAhnOh1aLi/S8uYIhoN fJNmV/rpYdxPpDVH7WSJxMCdHLwsBsGDhJZYfOHtk02J2OhYG7ecSY161qnGF6n1x5Wt 77OFfHELcYHLrMGPtF0qla3oukbs3NyF3S1QwGoJ+BMaGP3JQ6Najbnc7O3cQusQtdyk 89CA== 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 dg28si2652904edb.495.2020.06.04.19.34.45; Thu, 04 Jun 2020 19:35:08 -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 S1726072AbgFECc3 (ORCPT + 99 others); Thu, 4 Jun 2020 22:32:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:49832 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbgFECc2 (ORCPT ); Thu, 4 Jun 2020 22:32:28 -0400 IronPort-SDR: Zz5tm6WpH3scY/quHL0PfDsaB+xCA05FidCGxV6F9KXU9PxUPL7OkKb1pwLX6/+3xqk5igBhQw sODVQzNf6tUg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2020 19:32:21 -0700 IronPort-SDR: WobUmolIS7EeRo2skFMP8m8/Y/sJgss61yNsN0YN3mOJiaqoP7yByWQlnWM56W0XUNdVW4ZBB6 58yNl/qI4A3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,474,1583222400"; d="scan'208";a="294542056" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.238.4.141]) ([10.238.4.141]) by fmsmga004.fm.intel.com with ESMTP; 04 Jun 2020 19:32:18 -0700 Reply-To: like.xu@intel.com Subject: Re: [PATCH][v6] KVM: X86: support APERF/MPERF registers To: Li RongQing References: <1591321466-2046-1-git-send-email-lirongqing@baidu.com> Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org, hpa@zytor.com, bp@alien8.de, mingo@redhat.com, tglx@linutronix.de, jmattson@google.com, wanpengli@tencent.com, vkuznets@redhat.com, sean.j.christopherson@intel.com, pbonzini@redhat.com, xiaoyao.li@intel.com, wei.huang2@amd.com From: "Xu, Like" Organization: Intel OTC Message-ID: Date: Fri, 5 Jun 2020 10:32:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <1591321466-2046-1-git-send-email-lirongqing@baidu.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi RongQing, On 2020/6/5 9:44, Li RongQing wrote: > Guest kernel reports a fixed cpu frequency in /proc/cpuinfo, > this is confused to user when turbo is enable, and aperf/mperf > can be used to show current cpu frequency after 7d5905dc14a > "(x86 / CPU: Always show current CPU frequency in /proc/cpuinfo)" > so guest should support aperf/mperf capability > > This patch implements aperf/mperf by three mode: none, software > emulation, and pass-through > > None: default mode, guest does not support aperf/mperf s/None/Note > > Software emulation: the period of aperf/mperf in guest mode are > accumulated as emulated value > > Pass-though: it is only suitable for KVM_HINTS_REALTIME, Because > that hint guarantees we have a 1:1 vCPU:CPU binding and guaranteed > no over-commit. The flag "KVM_HINTS_REALTIME 0" (in the Documentation/virt/kvm/cpuid.rst) is claimed as "guest checks this feature bit to determine that vCPUs are never preempted for an unlimited time allowing optimizations". I couldn't see its relationship with "1:1 vCPU: pCPU binding". The patch doesn't check this flag as well for your pass-through purpose. Thanks, Like Xu > > And a per-VM capability is added to configure aperfmperf mode > > Signed-off-by: Li RongQing > Signed-off-by: Chai Wen > Signed-off-by: Jia Lina > --- > diff v5: > return error if guest is configured with mperf/aperf, but host cpu has not > > diff v4: > fix maybe-uninitialized warning > > diff v3: > fix interception of MSR_IA32_MPERF/APERF in svm > > diff v2: > support aperfmperf pass though > move common codes to kvm_get_msr_common > > diff v1: > 1. support AMD, but not test > 2. support per-vm capability to enable > > > Documentation/virt/kvm/api.rst | 10 ++++++++++ > arch/x86/include/asm/kvm_host.h | 11 +++++++++++ > arch/x86/kvm/cpuid.c | 15 ++++++++++++++- > arch/x86/kvm/svm/svm.c | 8 ++++++++ > arch/x86/kvm/vmx/vmx.c | 6 ++++++ > arch/x86/kvm/x86.c | 42 +++++++++++++++++++++++++++++++++++++++++ > arch/x86/kvm/x86.h | 15 +++++++++++++++ > include/uapi/linux/kvm.h | 1 + > 8 files changed, 107 insertions(+), 1 deletion(-)