From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755424AbcJXXdG (ORCPT ); Mon, 24 Oct 2016 19:33:06 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35568 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbcJXXdE (ORCPT ); Mon, 24 Oct 2016 19:33:04 -0400 MIME-Version: 1.0 In-Reply-To: <20161024145016.GA2247@potion> References: <1477304593-3453-1-git-send-email-wanpeng.li@hotmail.com> <1477304593-3453-6-git-send-email-wanpeng.li@hotmail.com> <20161024145016.GA2247@potion> From: Wanpeng Li Date: Tue, 25 Oct 2016 07:33:02 +0800 Message-ID: Subject: Re: [PATCH v3 5/5] KVM: LAPIC: add APIC Timer periodic/oneshot mode VMX preemption timer support To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: "linux-kernel@vger.kernel.org" , kvm , Paolo Bonzini , Yunhong Jiang , Wanpeng Li Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u9ONXFUl018490 2016-10-24 22:50 GMT+08:00 Radim Krčmář : > 2016-10-24 18:23+0800, Wanpeng Li: >> From: Wanpeng Li >> >> Most windows guests still utilize APIC Timer periodic/oneshot mode >> instead of tsc-deadline mode, and the APIC Timer periodic/oneshot >> mode are still emulated by high overhead hrtimer on host. This patch >> converts the expected expire time of the periodic/oneshot mode to >> guest deadline tsc in order to leverage VMX preemption timer logic >> for APIC Timer tsc-deadline mode. After each preemption timer vmexit >> preemption timer is restarted to emulate LVTT current-count register >> is automatically reloaded from the initial-count register when the >> count reaches 0. This patch reduces ~5600 cycles for each APIC Timer >> periodic mode operation virtualization. >> >> Cc: Paolo Bonzini >> Cc: Radim Krčmář >> Cc: Yunhong Jiang >> Signed-off-by: Wanpeng Li >> --- >> arch/x86/kvm/lapic.c | 117 ++++++++++++++++++++++++++++++++++++++------------- >> arch/x86/kvm/lapic.h | 1 + >> 2 files changed, 89 insertions(+), 29 deletions(-) >> >> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c >> @@ -2005,8 +2060,12 @@ void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu) >> >> if (atomic_read(&apic->lapic_timer.pending) > 0) { >> kvm_apic_local_deliver(apic, APIC_LVTT); >> - if (apic_lvtt_tscdeadline(apic)) >> + if (apic_lvtt_period(apic)) > > This should remain apic_lvtt_tscdeadline(). I can change that when > applying to kvm/queue. Thanks Radim, I make a mistake here. Regards, Wanpeng Li > >> + apic->lapic_timer.tscdeadline = 0; >> + if (apic_lvtt_oneshot(apic)) { >> apic->lapic_timer.tscdeadline = 0; >> + apic->lapic_timer.target_expiration = ktime_set(0, 0); >> + } >> atomic_set(&apic->lapic_timer.pending, 0); >> } >> }