WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Align periodic vpts

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Align periodic vpts
From: "Wei, Gang" <gang.wei@xxxxxxxxx>
Date: Wed, 11 Feb 2009 19:05:30 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Wed, 11 Feb 2009 03:05:59 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcmMOKb7clHaVWfpTWKVxXzVWUXrbA==
Thread-topic: [PATCH] Align periodic vpts
Hi,

Aligned periodic vpts can improve the HVM guest power consumption a lot, 
especially while the guest using high HZ such as 1000HZ.
This patch aligns all periodic vpts except vlapic to the period bound. For 
vlapic, only make it aligned while using the new option "align_periodic_vpt".

Signed-off-by: Wei Gang <gang.wei@xxxxxxxxx>

diff -r 4ac8bc60c000 xen/arch/x86/hvm/vpt.c
--- a/xen/arch/x86/hvm/vpt.c    Tue Feb 10 05:51:00 2009 +0000
+++ b/xen/arch/x86/hvm/vpt.c    Wed Feb 11 18:12:27 2009 +0800
@@ -354,6 +354,22 @@ void pt_migrate(struct vcpu *v)
     spin_unlock(&v->arch.hvm_vcpu.tm_lock);
 }
 
+/* 
+ * option "align_periodic_vpt" will make vlapic's expires aligned with other
+ * vpts while possible.
+ *
+ * CAUTION:
+ * While vlapic timer ticking too close to the pit.  We saw a userspace
+ * application getting the wrong answer because long CPU bound sequences
+ * appeared to run with zero CPU time. This only showed up with old Linux
+ * kernels (IIRC, it was with Red Hat 3 U8). So this option may cause a
+ * regression in this case.
+ */
+static int opt_align_periodic_vpt = 0;
+boolean_param("align_periodic_vpt", opt_align_periodic_vpt);
+
+extern s_time_t align_timer(s_time_t firsttick, uint64_t period);
+
 void create_periodic_time(
     struct vcpu *v, struct periodic_time *pt, uint64_t delta,
     uint64_t period, uint8_t irq, time_cb *cb, void *data)
@@ -389,8 +405,13 @@ void create_periodic_time(
      * LAPIC ticks for process accounting can see long sequences of process
      * ticks incorrectly accounted to interrupt processing.
      */
-    if ( !pt->one_shot && (pt->source == PTSRC_lapic) )
-        pt->scheduled += delta >> 1;
+    if ( !pt->one_shot )
+    {
+        pt->scheduled = align_timer(pt->scheduled, pt->period);
+        if ( !opt_align_periodic_vpt && (pt->source == PTSRC_lapic) )
+            pt->scheduled += delta >> 1;
+    }
+
     pt->cb = cb;
     pt->priv = data;
 
diff -r 4ac8bc60c000 xen/common/timer.c
--- a/xen/common/timer.c        Tue Feb 10 05:51:00 2009 +0000
+++ b/xen/common/timer.c        Wed Feb 11 18:12:27 2009 +0800
@@ -473,6 +473,14 @@ void process_pending_timers(void)
         timer_softirq_action();
 }
 
+/* calculate the aligned first tick time for the given periodic vpt */ 
+s_time_t align_timer(s_time_t firsttick, uint64_t period)
+{
+    if ( !period )
+        return firsttick;
+
+    return firsttick + period - (firsttick % period);
+}
 
 static void dump_timerq(unsigned char key)
 {

Attachment: vpt-align-0211-2.patch
Description: vpt-align-0211-2.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel