Port-xen archive

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

Re: A Timecounter for Xen



yamt%mwd.biglobe.ne.jp@localhost (YAMAMOTO Takashi) writes:

[...]
> is it correct for XEN3?
> see clock.c rev.1.27 and xen c/s 43564304cf94.

Indeed, you're right; I don't know how I missed that.  Thanks for
pointing it out.

The attached should take care of that (tested for Xen3, compile-tested
only for Xen2).

-- 
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l))))))  (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k)))))))    '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))
Index: sys/arch/xen/xen/clock.c
===================================================================
RCS file: /lfs/nb/repo/src/sys/arch/xen/xen/clock.c,v
retrieving revision 1.36
diff -u -p -r1.36 clock.c
--- sys/arch/xen/xen/clock.c    25 Jun 2007 19:57:32 -0000      1.36
+++ sys/arch/xen/xen/clock.c    1 Jul 2007 06:59:28 -0000
@@ -276,11 +276,32 @@ get_system_time(void)
        return stime;
 }
 
+static void
+xen_wall_time(struct timespec *wt)
+{
+       uint64_t nsec;
+       int s;
+
+       s = splhigh();
+       get_time_values_from_xen();
+       *wt = shadow_ts;
+       nsec = wt->tv_nsec;
+#ifdef XEN3
+       /* Under Xen3, this is the wall time less system time */
+       nsec += get_system_time();
+       splx(s);
+       wt->tv_sec += nsec / 1000000000L;
+       wt->tv_nsec = nsec % 1000000000L;
+#else
+       /* Under Xen2 , this is the current wall time. */
+       splx(s);
+#endif
+}
+
 void
 inittodr(time_t base)
 {
-       struct timespec sts;
-       int s;
+       struct timespec wt;
 
        /*
         * if the file system time is more than a year older than the
@@ -291,12 +312,8 @@ inittodr(time_t base)
                base = CONFIG_TIME;
        }
 
-       s = splhigh();
-       get_time_values_from_xen();
-       sts = shadow_ts;
-       splx(s);
-
-       tc_setclock(&sts); /* XXX what about rtc_offset? */
+       xen_wall_time(&wt);
+       tc_setclock(&wt); /* XXX what about rtc_offset? */
        
        if (base != 0 && base < time_second - 5*SECYR)
                printf("WARNING: file system time much less than clock time\n");
@@ -311,8 +328,8 @@ inittodr(time_t base)
 
 fstime:
        timeset = 1;
-       sts.tv_sec = base;
-       tc_setclock(&sts);
+       wt.tv_sec = base;
+       tc_setclock(&wt);
        printf("WARNING: CHECK AND RESET THE DATE!\n");
 }
 


Home | Main Index | Thread Index | Old Index