public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Like Xu <like.xu.linux@gmail.com>
To: Jim Mattson <jmattson@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Joerg Roedel <joro@8bytes.org>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Like Xu <likexu@tencent.com>,
	Dongli Cao <caodongli@kingsoft.com>,
	Li RongQing <lirongqing@baidu.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	"Thomas Gleixner (kernel-recipes.org)" <tglx@linutronix.de>,
	"Borislav Petkov (kernel-recipes.org)" <bp@alien8.de>,
	Sean Christopherson <seanjc@google.com>
Subject: Re: [PATCH v2] KVM: X86: Emulate APERF/MPERF to report actual vCPU frequency
Date: Thu, 6 Jan 2022 11:29:19 +0800	[thread overview]
Message-ID: <212cea42-e445-d6f2-2730-88ccaa65b2cb@gmail.com> (raw)
In-Reply-To: <CALMp9eQmO1zS9urH_B8DeoLp30P7Yxxp9qMwavjmoyt_BSC23A@mail.gmail.com>

On 6/1/2022 6:51 am, Jim Mattson wrote:
> On Thu, Dec 30, 2021 at 11:48 PM Like Xu <like.xu.linux@gmail.com> wrote:
>>
>> On 31/12/2021 9:29 am, Jim Mattson wrote:
> 
>>> At sched-in:
>>> 1. Save host APERF/MPERF values from the MSRs.
>>> 2. Load the "current" guest APERF/MPERF values into the MSRs (if the
>>> vCPU configuration allows for unintercepted reads).
>>>
>>> At sched-out:
>>> 1. Calculate the guest APERF/MPERF deltas for use in step 3.
>>> 2. Save the "current" guest APERF/MPERF values.
>>> 3. "Restore" the host APERF/MPERF values, but add in the deltas from step 1.
>>>
>>> Without any writes to IA32_MPERF, I would expect these MSRs to be
>>> synchronized across all logical processors, and the proposal above
>>> would break that synchronization.
> 
> I am learning more about IA32_APERF and IA32_MPERF this year. :-)

Uh, thanks for your attention.

> 
> My worry above is unfounded. These MSRs only increment in C0, so they
> are not likely to be synchronized.
> 
> This also raises another issue with your original fast-path
> implementation: the host MSRs will continue to count while the guest
> is halted. However, the guest MSRs should not count while the guest is
> halted.
> 

The emulation based on guest TSC semantics w/ low precision may work it out.
TBH, I still haven't given up on the idea of a pass-through approach.


  reply	other threads:[~2022-01-06  3:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 13:34 [PATCH v2] KVM: X86: Emulate APERF/MPERF to report actual vCPU frequency Like Xu
2021-12-27 18:33 ` Jim Mattson
2021-12-28  7:10   ` Like Xu
2021-12-29  0:05     ` Jim Mattson
2021-12-29  1:11 ` Jim Mattson
2021-12-29  4:06   ` Like Xu
2021-12-30  0:28     ` Jim Mattson
2021-12-30  2:36       ` Jim Mattson
2021-12-30  8:37         ` Like Xu
2021-12-31  1:29           ` Jim Mattson
2021-12-31  7:48             ` Like Xu
2022-01-05 22:51               ` Jim Mattson
2022-01-06  3:29                 ` Like Xu [this message]
2022-01-06 18:01                   ` Jim Mattson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=212cea42-e445-d6f2-2730-88ccaa65b2cb@gmail.com \
    --to=like.xu.linux@gmail.com \
    --cc=bp@alien8.de \
    --cc=caodongli@kingsoft.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=likexu@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox