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

[Minios-devel] [PATCH 2/2] Fix time update



The timer handler should actually not update the shadowed copy, since that
makes reading them non-atomic. Users of the shadowed copy should just update
it themselves, which is already the case in monotonic_clock(), we just need
to make to make gettimeofday() update the wallclock.

This also fixes an issue reported by David Vercauteren: when the timer
interrupt was not called yet, gettimeofday was returning bogus values.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
---
 arch/x86/time.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/x86/time.c b/arch/x86/time.c
index cf5fab0..af45e56 100644
--- a/arch/x86/time.c
+++ b/arch/x86/time.c
@@ -79,6 +79,12 @@ static inline int time_values_up_to_date(void)
        return (shadow.version == src->version);
 }
 
+static inline int wc_values_up_to_date(void)
+{
+       shared_info_t *s= HYPERVISOR_shared_info;
+
+       return (shadow_ts_version == s->wc_version);
+}
 
 /*
  * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
@@ -186,9 +192,12 @@ static void update_wallclock(void)
 int gettimeofday(struct timeval *tv, void *tz)
 {
     uint64_t nsec = monotonic_clock();
+
+    if (!wc_values_up_to_date())
+       update_wallclock();
+
     nsec += shadow_ts.tv_nsec;
-    
-    
+
     tv->tv_sec = shadow_ts.tv_sec;
     tv->tv_sec += NSEC_TO_SEC(nsec);
     tv->tv_usec = NSEC_TO_USEC(nsec % 1000000000UL);
@@ -214,8 +223,6 @@ void block_domain(s_time_t until)
  */
 static void timer_handler(evtchn_port_t ev, struct pt_regs *regs, void *ign)
 {
-    get_time_values_from_xen();
-    update_wallclock();
 }
 
 
-- 
2.8.0.rc3


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/minios-devel

 


Rackspace

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