[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <947de021-df91-9219-7378-8addc6f66612@bytedance.com>
Date: Fri, 3 Dec 2021 15:34:04 +0800
From: zhenwei pi <pizhenwei@...edance.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: tglx@...utronix.de, pbonzini@...hat.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, x86@...nel.org
Subject: Re: Re: [PATCH v2 1/2] x86/cpu: Introduce x86_get_cpufreq_khz()
On 12/3/21 6:25 AM, Peter Zijlstra wrote:
> On Wed, Dec 01, 2021 at 10:46:49AM +0800, zhenwei pi wrote:
>> Wrapper function x86_get_cpufreq_khz() to get frequency on a x86
>> platform, hide detailed implementation from proc routine.
>>
>> Also export this function for the further use, a typical case is that
>> kvm module gets the frequency of the host and tell the guest side by
>> kvmclock.
>
> This function was already complete crap, and now you want to export it,
> *WHY* ?!
>
> What possible use does KVM have for this random number generator?
>
A KVM guest overwrites the '.calibrate_tsc' and '.calibrate_cpu' if
kvmclock is supported:
in function kvmclock_init(void) (linux/arch/x86/kernel/kvmclock.c)
...
x86_platform.calibrate_tsc = kvm_get_tsc_khz;
x86_platform.calibrate_cpu = kvm_get_tsc_khz;
...
And kvm_get_tsc_khz reads PV data from host side. Before guest reads
this, KVM should writes the frequency into the PV data structure.
And the problem is that KVM gets tsc_khz directly without aperf/mperf
detection. So user may gets different frequency(cat /proc/cpuinfo) from
guest & host.
Or is that possible to export function 'aperfmperf_get_khz'?
--
zhenwei pi
Powered by blists - more mailing lists