From patchwork Fri Sep 7 12:07:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Jinsong" X-Patchwork-Id: 1421801 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 1F26B3FC85 for ; Fri, 7 Sep 2012 12:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933048Ab2IGMHJ (ORCPT ); Fri, 7 Sep 2012 08:07:09 -0400 Received: from mga09.intel.com ([134.134.136.24]:13434 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760365Ab2IGMHH (ORCPT ); Fri, 7 Sep 2012 08:07:07 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 07 Sep 2012 05:06:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,385,1344236400"; d="scan'208,223";a="190246903" Received: from fmsmsx106.amr.corp.intel.com ([10.19.9.37]) by orsmga001.jf.intel.com with ESMTP; 07 Sep 2012 05:07:05 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX106.amr.corp.intel.com (10.19.9.37) with Microsoft SMTP Server (TLS) id 14.1.355.2; Fri, 7 Sep 2012 05:07:04 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.239]) by SHSMSX102.ccr.corp.intel.com ([169.254.2.92]) with mapi id 14.01.0355.002; Fri, 7 Sep 2012 20:07:03 +0800 From: "Liu, Jinsong" To: Avi Kivity CC: Marcelo Tosatti , kvm , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] KVM: tsc deadline timer works only when hrtimer high resolution configured Thread-Topic: [PATCH] KVM: tsc deadline timer works only when hrtimer high resolution configured Thread-Index: AQHNjDezEaLQ0dDCRmG5O7fBmMDyI5d+yBIw Date: Fri, 7 Sep 2012 12:07:02 +0000 Message-ID: References: <5048AC08.5050100@redhat.com> In-Reply-To: <5048AC08.5050100@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Avi Kivity wrote: >> 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. Yep, I did a draft test for kvm lapic timer, it also worked fail when CONFIG_HIGH_RES_TIMERS disabled. Attached is the udpated patch. Thanks, Jinsong ==================== From 64d0458ec50a7d6917adf1e9735ba6e6ae6024ad Mon Sep 17 00:00:00 2001 From: Liu, Jinsong Date: Sat, 8 Sep 2012 03:32:31 +0800 Subject: [PATCH] KVM: select HIGH_RES_TIMERS when KVM enabled This is for 2 reasons: 1. it's pointless for kvm lapic timer and tsc deadline timer when kernel hrtimer not configured as high resolution, since that would be not accurate based on wheel; 2. kvm lapic timer and 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 then make kvm lapic timer and tsc deadline timer fail. Signed-off-by: Liu, Jinsong --- arch/x86/kvm/Kconfig | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index a28f338..5f861ca 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -24,6 +24,8 @@ config KVM depends on PCI # for TASKSTATS/TASK_DELAY_ACCT: depends on NET + # for HIGH_RES_TIMERS + depends on !ARCH_USES_GETTIMEOFFSET select PREEMPT_NOTIFIERS select MMU_NOTIFIER select ANON_INODES @@ -37,6 +39,8 @@ config KVM select TASK_DELAY_ACCT select PERF_EVENTS select HAVE_KVM_MSI + select GENERIC_CLOCKEVENTS + select HIGH_RES_TIMERS ---help--- Support hosting fully virtualized guest machines using hardware virtualization extensions. You will need a fairly recent