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-changelog

[Xen-changelog] [xen-4.0-testing] x86: Detect and handle unexpected plat

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-4.0-testing] x86: Detect and handle unexpected platform-timer counter wrap.
From: "Xen patchbot-4.0-testing" <patchbot-4.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Aug 2010 02:45:22 -0700
Delivery-date: Thu, 12 Aug 2010 02:46:11 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1281541443 -3600
# Node ID 8e8dd38374e9758412b079bf2edda1909ef157dd
# Parent  954754745f65f0a76519924184062958d62f6744
x86: Detect and handle unexpected platform-timer counter wrap.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   21346:7d4deb86b966
xen-unstable date:        Tue May 11 11:21:27 2010 +0100
---
 xen/arch/x86/time.c |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diff -r 954754745f65 -r 8e8dd38374e9 xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Wed Aug 11 16:43:44 2010 +0100
+++ b/xen/arch/x86/time.c       Wed Aug 11 16:44:03 2010 +0100
@@ -571,24 +571,46 @@ static u64 plt_stamp;            /* hard
 static u64 plt_stamp;            /* hardware-width platform counter stamp   */
 static struct timer plt_overflow_timer;
 
+static s_time_t __read_platform_stime(u64 platform_time)
+{
+    u64 diff = platform_time - platform_timer_stamp;
+    ASSERT(spin_is_locked(&platform_timer_lock));
+    return (stime_platform_stamp + scale_delta(diff, &plt_scale));
+}
+
 static void plt_overflow(void *unused)
 {
+    int i;
     u64 count;
+    s_time_t now, plt_now, plt_wrap;
 
     spin_lock_irq(&platform_timer_lock);
+
     count = plt_src.read_counter();
     plt_stamp64 += (count - plt_stamp) & plt_mask;
     plt_stamp = count;
+
+    now = NOW();
+    plt_wrap = __read_platform_stime(plt_stamp64);
+    for ( i = 0; i < 10; i++ )
+    {
+        plt_now = plt_wrap;
+        plt_wrap = __read_platform_stime(plt_stamp64 + plt_mask + 1);
+        if ( ABS(plt_wrap - now) > ABS(plt_now - now) )
+            break;
+        plt_stamp64 += plt_mask + 1;
+    }
+    if ( i != 0 )
+    {
+        static bool_t warned_once;
+        if ( !test_and_set_bool(warned_once) )
+            printk("Platform timer appears to have unexpectedly wrapped "
+                   "%u%s times.\n", i, (i == 10) ? " or more" : "");
+    }
+
     spin_unlock_irq(&platform_timer_lock);
 
     set_timer(&plt_overflow_timer, NOW() + plt_overflow_period);
-}
-
-static s_time_t __read_platform_stime(u64 platform_time)
-{
-    u64 diff = platform_time - platform_timer_stamp;
-    ASSERT(spin_is_locked(&platform_timer_lock));
-    return (stime_platform_stamp + scale_delta(diff, &plt_scale));
 }
 
 static s_time_t read_platform_stime(void)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-4.0-testing] x86: Detect and handle unexpected platform-timer counter wrap., Xen patchbot-4.0-testing <=