KVM Archive on lore.kernel.org
 help / color / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 6/8] KVM: timer: optimize next_timer_event and vcpu_arm_exit
Date: Sun, 05 Jul 2009 22:55:17 -0300
Message-ID: <20090706015813.001127585@localhost.localdomain> (raw)
In-Reply-To: <20090706015511.923596553@localhost.localdomain>


[-- Attachment #0: kvm-armexit-optimize --]
[-- Type: text/plain, Size: 1445 bytes --]

Which reduces the added entry/exit overhead down to ~= 30 cycles.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm-new/arch/x86/kvm/timer.c
===================================================================
--- kvm-new.orig/arch/x86/kvm/timer.c
+++ kvm-new/arch/x86/kvm/timer.c
@@ -135,14 +135,15 @@ ktime_t kvm_vcpu_next_timer_event(struct
 void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu)
 {
 	struct kvm_timer *ktimer, *n;
-	ktime_t now = ktime_get();
 
 	list_for_each_entry_safe(ktimer, n, &vcpu->arch.timers, vcpu_timer) {
-		ktime_t expire;
+		ktime_t expire, now;
 
 		if (!ktimer->can_inject)
 			continue;
 
+		now = ktime_get();
+
 		expire = kvm_timer_next_event(ktimer);
 		if (ktime_to_ns(now) < ktime_to_ns(expire))
 			continue;
@@ -173,8 +174,12 @@ void kvm_vcpu_arm_exit(struct kvm_vcpu *
 {
 	ktime_t expire;
 	ktime_t now;
-	struct kvm_timer *ktimer = kvm_vcpu_injectable_timer_event(vcpu);
+	struct kvm_timer *ktimer;
+
+	if (hrtimer_active(&vcpu->arch.exit_timer))
+		return;
 
+	ktimer = kvm_vcpu_injectable_timer_event(vcpu);
 	if (!ktimer)
 		return;
 
Index: kvm-new/arch/x86/kvm/x86.c
===================================================================
--- kvm-new.orig/arch/x86/kvm/x86.c
+++ kvm-new/arch/x86/kvm/x86.c
@@ -3567,8 +3567,6 @@ static int vcpu_enter_guest(struct kvm_v
 
 	preempt_enable();
 
-	kvm_vcpu_cleanup_timer(vcpu);
-
 	down_read(&vcpu->kvm->slots_lock);
 
 	/*

-- 


  parent reply index

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-06  1:55 [patch 0/8] RFC: in-kernel timer emulation changes Marcelo Tosatti
2009-07-06  1:55 ` [patch 1/8] KVM: timer interface unification Marcelo Tosatti
2009-07-08 13:33   ` Avi Kivity
2009-07-06  1:55 ` [patch 2/8] KVM: move lapic timer ack to EOI handler Marcelo Tosatti
2009-07-06  1:55 ` [patch 3/8] KVM: x86: per-vcpu timer list Marcelo Tosatti
2009-07-06  1:55 ` [patch 4/8] KVM: x86: replace hrtimer based timer emulation Marcelo Tosatti
2009-07-08 12:58   ` Gleb Natapov
2009-07-08 13:17     ` Marcelo Tosatti
2009-07-08 13:39       ` Gleb Natapov
2009-07-08 15:42         ` Marcelo Tosatti
2009-07-08 16:13           ` Gleb Natapov
2009-07-08 16:29       ` Gleb Natapov
2009-07-08 16:37         ` Marcelo Tosatti
2009-07-08 16:40           ` Gleb Natapov
2009-07-08 16:47             ` Marcelo Tosatti
2009-07-08 13:41   ` Avi Kivity
2009-07-08 16:24     ` Marcelo Tosatti
2009-07-08 16:36       ` Avi Kivity
2009-07-06  1:55 ` [patch 5/8] KVM: timer: honor noreinject tunable Marcelo Tosatti
2009-07-06  1:55 ` Marcelo Tosatti [this message]
2009-07-06  1:55 ` [patch 7/8] KVM: PIT: removed unused code Marcelo Tosatti
2009-07-06  1:55 ` [patch 8/8] kvmctl: time testcase Marcelo Tosatti
2009-07-08 13:43 ` [patch 0/8] RFC: in-kernel timer emulation changes Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090706015813.001127585@localhost.localdomain \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git