diff mbox

KVM: tsc deadline timer works only when hrtimer high resolution configured

Message ID DE8DF0795D48FD4CA783C40EC829233531F0E4@SHSMSX101.ccr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liu, Jinsong Sept. 4, 2012, 3:07 p.m. UTC
From 728a17e2de591b557c3c8ba31076b4bf2ca5ab42 Mon Sep 17 00:00:00 2001
From: Liu, Jinsong <jinsong.liu@intel.com>
Date: Wed, 5 Sep 2012 03:18:15 +0800
Subject: [PATCH] KVM: tsc deadline timer works only when hrtimer high resolution configured

This is for 2 reasons:
1. it's pointless to enable tsc deadline timer to guest when kernel hrtimer
not configured as high resolution, since that would be un-precise based on wheel;
2. tsc deadline timer based on hrtimer, setting a leftmost node to rb tree
and then do hrtimer reprogram. If hrtimer not configured as high resolution,
hrtimer_enqueue_reprogram do nothing and would make tsc deadline timer fail.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
---
 arch/x86/kvm/x86.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Avi Kivity Sept. 6, 2012, 1:58 p.m. UTC | #1
On 09/04/2012 06:07 PM, Liu, Jinsong wrote:
> From 728a17e2de591b557c3c8ba31076b4bf2ca5ab42 Mon Sep 17 00:00:00 2001
> From: Liu, Jinsong <jinsong.liu@intel.com>
> Date: Wed, 5 Sep 2012 03:18:15 +0800
> Subject: [PATCH] KVM: tsc deadline timer works only when hrtimer high resolution configured
> 
> This is for 2 reasons:
> 1. it's pointless to enable tsc deadline timer to guest when kernel hrtimer
> not configured as high resolution, since that would be un-precise based on wheel;
> 2. tsc deadline timer based on hrtimer, setting a leftmost node to rb tree
> and then do hrtimer reprogram. If hrtimer not configured as high resolution,
> hrtimer_enqueue_reprogram do nothing and would make tsc deadline timer fail.
> 
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 148ed66..0e64997 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2210,7 +2210,11 @@ int kvm_dev_ioctl_check_extension(long ext)
>  		r = kvm_has_tsc_control;
>  		break;
>  	case KVM_CAP_TSC_DEADLINE_TIMER:
> +#ifdef CONFIG_HIGH_RES_TIMERS
>  		r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
> +#else
> +		r = 0;
> +#endif
>  		break;

I prefer a patch making kvm for x86 depend on hrtimers.  kvm already
provides a high resolution timer to the guest in the local apic, backing
it with the jiffies event source will likely cause some guests to
malfunction.
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 148ed66..0e64997 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2210,7 +2210,11 @@  int kvm_dev_ioctl_check_extension(long ext)
 		r = kvm_has_tsc_control;
 		break;
 	case KVM_CAP_TSC_DEADLINE_TIMER:
+#ifdef CONFIG_HIGH_RES_TIMERS
 		r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+#else
+		r = 0;
+#endif
 		break;
 	default:
 		r = 0;