All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun Sharma <arun.sharma@intel.com>
To: Ian Pratt <Ian.Pratt@cl.cam.ac.uk>,
	Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: [PATCH][9/9] Improve guest time keeping
Date: Mon, 25 Jul 2005 14:01:59 -0700	[thread overview]
Message-ID: <20050725210159.GA24440@intel.com> (raw)

Improve guest time keeping

Even though we accounted for lost ticks, the accounting was not precise.
Specifically, we didn't account for the delay in calling the ac_timer
handler.

Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>

diff -r d016dd226b0d -r 83180ee86481 xen/arch/x86/vmx_intercept.c
--- a/xen/arch/x86/vmx_intercept.c	Mon Jul 18 23:15:02 2005
+++ b/xen/arch/x86/vmx_intercept.c	Mon Jul 18 23:47:48 2005
@@ -197,12 +197,23 @@
 static void pit_timer_fn(void *data)
 {
     struct vmx_virpit_t *vpit = data;
+    s_time_t   next;
+    int        missed_ticks;
+
+    missed_ticks = (NOW() - vpit->scheduled) / MILLISECS(vpit->period);
 
     /* Set the pending intr bit, and send evtchn notification to myself. */
     if (test_and_set_bit(vpit->vector, vpit->intr_bitmap))
         vpit->pending_intr_nr++; /* already set, then count the pending intr */
 
-    set_ac_timer(&vpit->pit_timer, NOW() + MILLISECS(vpit->period));
+    /* pick up missed timer tick */
+    if ( missed_ticks > 0 ) {
+        vpit->pending_intr_nr+= missed_ticks;
+        vpit->scheduled += missed_ticks * MILLISECS(vpit->period);
+    }
+    next = vpit->scheduled + MILLISECS(vpit->period);
+    set_ac_timer(&vpit->pit_timer, next);
+    vpit->scheduled = next;
 }
 
 
@@ -263,7 +274,8 @@
 
         vpit->intr_bitmap = intr;
 
-	set_ac_timer(&vpit->pit_timer, NOW() + MILLISECS(vpit->period));
+        vpit->scheduled = NOW() + MILLISECS(vpit->period);
+        set_ac_timer(&vpit->pit_timer, vpit->scheduled);
 
         /*restore the state*/
         p->state = STATE_IORESP_READY;
diff -r d016dd226b0d -r 83180ee86481 xen/include/asm-x86/vmx_virpit.h
--- a/xen/include/asm-x86/vmx_virpit.h	Mon Jul 18 23:15:02 2005
+++ b/xen/include/asm-x86/vmx_virpit.h	Mon Jul 18 23:47:48 2005
@@ -19,6 +19,7 @@
     /* for simulation of counter 0 in mode 2*/
     int vector;				/* the pit irq vector */
     unsigned int period;		/* the frequency. e.g. 10ms*/
+    s_time_t scheduled;                 /* scheduled timer interrupt */
     unsigned int channel;		/* the pit channel, counter 0~2 */
     u64  *intr_bitmap;
     unsigned int pending_intr_nr;	/* the couner for pending timer interrupts */

                 reply	other threads:[~2005-07-25 21:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20050725210159.GA24440@intel.com \
    --to=arun.sharma@intel.com \
    --cc=Ian.Pratt@cl.cam.ac.uk \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=xen-devel@lists.xensource.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.