[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Fix wallclock timebase extraction in XenLinux.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 2ecb91fb6cdbdfa001a48bc2bb2b1db320a19485
# Parent  bf68b5fcbc9bc2673ce19817c01e362fc18af6fe

Fix wallclock timebase extraction in XenLinux.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r bf68b5fcbc9b -r 2ecb91fb6cdb 
linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c  Tue Jul 19 08:52:32 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c  Tue Jul 19 09:26:18 2005
@@ -227,9 +227,9 @@
 static void update_wallclock(void)
 {
        shared_info_t *s = HYPERVISOR_shared_info;
-       long wtm_nsec;
-       time_t wtm_sec, sec;
-       s64 nsec;
+       long wtm_nsec, xtime_nsec;
+       time_t wtm_sec, xtime_sec;
+       u64 tmp, usec;
 
        shadow_tv.tv_sec  = s->wc_sec;
        shadow_tv.tv_usec = s->wc_usec;
@@ -240,20 +240,22 @@
        if ((time_status & STA_UNSYNC) != 0)
                return;
 
-       /* Adjust shadow for jiffies that haven't updated xtime yet. */
-       shadow_tv.tv_usec -= 
-               (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
-       HANDLE_USEC_UNDERFLOW(shadow_tv);
-
-       /* Update our unsynchronised xtime appropriately. */
-       sec = shadow_tv.tv_sec;
-       nsec = shadow_tv.tv_usec * NSEC_PER_USEC;
-
-       __normalize_time(&sec, &nsec);
-       wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
-       wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
-
-       set_normalized_timespec(&xtime, sec, nsec);
+       /* Adjust wall-clock time base based on wall_jiffies ticks. */
+       usec = processed_system_time;
+       do_div(usec, 1000);
+       usec += (u64)shadow_tv.tv_sec * 1000000ULL;
+       usec += (u64)shadow_tv.tv_usec;
+       usec -= (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
+
+       /* Split wallclock base into seconds and nanoseconds. */
+       tmp = usec;
+       xtime_nsec = do_div(tmp, 1000000) * 1000ULL;
+       xtime_sec  = (time_t)tmp;
+
+       wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - xtime_sec);
+       wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - xtime_nsec);
+
+       set_normalized_timespec(&xtime, xtime_sec, xtime_nsec);
        set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
 }
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.