* [PATCH] x86/vmware: avoid TSC recalibration
@ 2021-01-05 0:47 ` Alexey Makhalov
0 siblings, 0 replies; 7+ messages in thread
From: Alexey Makhalov @ 2021-01-05 0:47 UTC (permalink / raw)
To: linux-kernel, virtualization, hpa, bp, mingo, tglx, pv-drivers, sdeep
Cc: Alexey Makhalov
When TSC frequency is known (retrieved from hypervisor), we should skip
TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
---
arch/x86/kernel/cpu/vmware.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index c6ede3b3d302..83164110ccc5 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -378,6 +378,8 @@ static void __init vmware_set_capabilities(void)
{
setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC);
setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
+ if (vmware_tsc_khz)
+ setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL)
setup_force_cpu_cap(X86_FEATURE_VMCALL);
else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL)
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] x86/vmware: avoid TSC recalibration
@ 2021-01-05 0:47 ` Alexey Makhalov
0 siblings, 0 replies; 7+ messages in thread
From: Alexey Makhalov @ 2021-01-05 0:47 UTC (permalink / raw)
To: linux-kernel, virtualization, hpa, bp, mingo, tglx, pv-drivers, sdeep
Cc: Alexey Makhalov
When TSC frequency is known (retrieved from hypervisor), we should skip
TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
---
arch/x86/kernel/cpu/vmware.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index c6ede3b3d302..83164110ccc5 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -378,6 +378,8 @@ static void __init vmware_set_capabilities(void)
{
setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC);
setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
+ if (vmware_tsc_khz)
+ setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL)
setup_force_cpu_cap(X86_FEATURE_VMCALL);
else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL)
--
2.11.0
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/vmware: avoid TSC recalibration
2021-01-05 0:47 ` Alexey Makhalov
@ 2021-01-05 13:06 ` Vitaly Kuznetsov
-1 siblings, 0 replies; 7+ messages in thread
From: Vitaly Kuznetsov @ 2021-01-05 13:06 UTC (permalink / raw)
To: Alexey Makhalov
Cc: linux-kernel, virtualization, hpa, bp, mingo, tglx, pv-drivers, sdeep
Alexey Makhalov <amakhalov@vmware.com> writes:
> When TSC frequency is known (retrieved from hypervisor), we should skip
> TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
>
> Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
> ---
> arch/x86/kernel/cpu/vmware.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> index c6ede3b3d302..83164110ccc5 100644
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -378,6 +378,8 @@ static void __init vmware_set_capabilities(void)
> {
> setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC);
> setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
> + if (vmware_tsc_khz)
> + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL)
> setup_force_cpu_cap(X86_FEATURE_VMCALL);
> else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL)
The same trick is being used in Xen/Jailhouse/KVM code already and
Hyper-V overwrites x86_platform.calibrate_tsc/x86_platform.calibrate_cpu
hooks to basically achive the same goal. Should we maybe introduce a
flag in 'struct hypervisor_x86' or something like that to unify all
this?
Just a suggestion.
--
Vitaly
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/vmware: avoid TSC recalibration
@ 2021-01-05 13:06 ` Vitaly Kuznetsov
0 siblings, 0 replies; 7+ messages in thread
From: Vitaly Kuznetsov @ 2021-01-05 13:06 UTC (permalink / raw)
To: Alexey Makhalov
Cc: pv-drivers, linux-kernel, virtualization, mingo, bp, hpa, tglx
Alexey Makhalov <amakhalov@vmware.com> writes:
> When TSC frequency is known (retrieved from hypervisor), we should skip
> TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
>
> Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
> ---
> arch/x86/kernel/cpu/vmware.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
> index c6ede3b3d302..83164110ccc5 100644
> --- a/arch/x86/kernel/cpu/vmware.c
> +++ b/arch/x86/kernel/cpu/vmware.c
> @@ -378,6 +378,8 @@ static void __init vmware_set_capabilities(void)
> {
> setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC);
> setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
> + if (vmware_tsc_khz)
> + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
> if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL)
> setup_force_cpu_cap(X86_FEATURE_VMCALL);
> else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL)
The same trick is being used in Xen/Jailhouse/KVM code already and
Hyper-V overwrites x86_platform.calibrate_tsc/x86_platform.calibrate_cpu
hooks to basically achive the same goal. Should we maybe introduce a
flag in 'struct hypervisor_x86' or something like that to unify all
this?
Just a suggestion.
--
Vitaly
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/vmware: avoid TSC recalibration
2021-01-05 13:06 ` Vitaly Kuznetsov
@ 2021-03-15 22:24 ` Alexey Makhalov
-1 siblings, 0 replies; 7+ messages in thread
From: Alexey Makhalov @ 2021-03-15 22:24 UTC (permalink / raw)
To: Vitaly Kuznetsov
Cc: linux-kernel, virtualization, H . Peter Anvin, Borislav Petkov,
mingo, tglx, pv-drivers, sdeep
Hi Vitaly,
I believe, it is responsibility of each guest code to set X86_FEATURE_TSC_KNOWN_FREQ cap.
Regarding VMware guest, there is a case where vmware_tsc_khz is zero (not provided by hypervisor)
and TSC frequency should be calculated.
Sorry for late response.
Regards,
—Alexey
> On Jan 5, 2021, at 5:06 AM, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Alexey Makhalov <amakhalov@vmware.com> writes:
>
>> When TSC frequency is known (retrieved from hypervisor), we should skip
>> TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
>>
>> Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
>> ---
>> arch/x86/kernel/cpu/vmware.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
>> index c6ede3b3d302..83164110ccc5 100644
>> --- a/arch/x86/kernel/cpu/vmware.c
>> +++ b/arch/x86/kernel/cpu/vmware.c
>> @@ -378,6 +378,8 @@ static void __init vmware_set_capabilities(void)
>> {
>> setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC);
>> setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
>> + if (vmware_tsc_khz)
>> + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
>> if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL)
>> setup_force_cpu_cap(X86_FEATURE_VMCALL);
>> else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL)
>
> The same trick is being used in Xen/Jailhouse/KVM code already and
> Hyper-V overwrites x86_platform.calibrate_tsc/x86_platform.calibrate_cpu
> hooks to basically achive the same goal. Should we maybe introduce a
> flag in 'struct hypervisor_x86' or something like that to unify all
> this?
>
> Just a suggestion.
>
> --
> Vitaly
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86/vmware: avoid TSC recalibration
@ 2021-03-15 22:24 ` Alexey Makhalov
0 siblings, 0 replies; 7+ messages in thread
From: Alexey Makhalov @ 2021-03-15 22:24 UTC (permalink / raw)
To: Vitaly Kuznetsov
Cc: pv-drivers, linux-kernel, virtualization, mingo, Borislav Petkov,
H . Peter Anvin, tglx
Hi Vitaly,
I believe, it is responsibility of each guest code to set X86_FEATURE_TSC_KNOWN_FREQ cap.
Regarding VMware guest, there is a case where vmware_tsc_khz is zero (not provided by hypervisor)
and TSC frequency should be calculated.
Sorry for late response.
Regards,
—Alexey
> On Jan 5, 2021, at 5:06 AM, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Alexey Makhalov <amakhalov@vmware.com> writes:
>
>> When TSC frequency is known (retrieved from hypervisor), we should skip
>> TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
>>
>> Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
>> ---
>> arch/x86/kernel/cpu/vmware.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
>> index c6ede3b3d302..83164110ccc5 100644
>> --- a/arch/x86/kernel/cpu/vmware.c
>> +++ b/arch/x86/kernel/cpu/vmware.c
>> @@ -378,6 +378,8 @@ static void __init vmware_set_capabilities(void)
>> {
>> setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC);
>> setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
>> + if (vmware_tsc_khz)
>> + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
>> if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL)
>> setup_force_cpu_cap(X86_FEATURE_VMCALL);
>> else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL)
>
> The same trick is being used in Xen/Jailhouse/KVM code already and
> Hyper-V overwrites x86_platform.calibrate_tsc/x86_platform.calibrate_cpu
> hooks to basically achive the same goal. Should we maybe introduce a
> flag in 'struct hypervisor_x86' or something like that to unify all
> this?
>
> Just a suggestion.
>
> --
> Vitaly
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip: x86/vmware] x86/vmware: Avoid TSC recalibration when frequency is known
2021-01-05 0:47 ` Alexey Makhalov
(?)
(?)
@ 2021-03-28 19:14 ` tip-bot2 for Alexey Makhalov
-1 siblings, 0 replies; 7+ messages in thread
From: tip-bot2 for Alexey Makhalov @ 2021-03-28 19:14 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Alexey Makhalov, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the x86/vmware branch of tip:
Commit-ID: 0b4a285e2c65c2c9449c6eccb87298e385213e7b
Gitweb: https://git.kernel.org/tip/0b4a285e2c65c2c9449c6eccb87298e385213e7b
Author: Alexey Makhalov <amakhalov@vmware.com>
AuthorDate: Mon, 04 Jan 2021 16:47:52 -08:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Sun, 28 Mar 2021 21:11:43 +02:00
x86/vmware: Avoid TSC recalibration when frequency is known
When the TSC frequency is known because it is retrieved from the
hypervisor, skip TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.
Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210105004752.131069-1-amakhalov@vmware.com
---
arch/x86/kernel/cpu/vmware.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index c6ede3b..8316411 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -378,6 +378,8 @@ static void __init vmware_set_capabilities(void)
{
setup_force_cpu_cap(X86_FEATURE_CONSTANT_TSC);
setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
+ if (vmware_tsc_khz)
+ setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMCALL)
setup_force_cpu_cap(X86_FEATURE_VMCALL);
else if (vmware_hypercall_mode == CPUID_VMWARE_FEATURES_ECX_VMMCALL)
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-03-28 19:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 0:47 [PATCH] x86/vmware: avoid TSC recalibration Alexey Makhalov
2021-01-05 0:47 ` Alexey Makhalov
2021-01-05 13:06 ` Vitaly Kuznetsov
2021-01-05 13:06 ` Vitaly Kuznetsov
2021-03-15 22:24 ` Alexey Makhalov
2021-03-15 22:24 ` Alexey Makhalov
2021-03-28 19:14 ` [tip: x86/vmware] x86/vmware: Avoid TSC recalibration when frequency is known tip-bot2 for Alexey Makhalov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.