From: zhenwei pi <pizhenwei@bytedance.com>
To: tglx@linutronix.de, pbonzini@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, zhenwei pi <pizhenwei@bytedance.com>
Subject: [PATCH 2/2] KVM: x86: use x86_get_freq to get freq for kvmclock
Date: Mon, 29 Nov 2021 13:20:38 +0800 [thread overview]
Message-ID: <20211129052038.43758-2-pizhenwei@bytedance.com> (raw)
In-Reply-To: <20211129052038.43758-1-pizhenwei@bytedance.com>
If the host side supports APERF&MPERF feature, the guest side may get
mismatched freq.
KVM uses x86_get_freq to get the same freq for guest side.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
---
arch/x86/kvm/x86.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5a403d92833f..0c2a2188700f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8305,10 +8305,8 @@ static void tsc_khz_changed(void *data)
if (data)
khz = freq->new;
- else if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
- khz = cpufreq_quick_get(raw_smp_processor_id());
if (!khz)
- khz = tsc_khz;
+ khz = x86_get_freq(raw_smp_processor_id());
__this_cpu_write(cpu_tsc_khz, khz);
}
--
2.25.1
next prev parent reply other threads:[~2021-11-29 5:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-29 5:20 [PATCH 1/2] x86/cpu: introduce x86_get_freq zhenwei pi
2021-11-29 5:20 ` zhenwei pi [this message]
2021-11-30 21:36 ` Thomas Gleixner
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=20211129052038.43758-2-pizhenwei@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).