ia64/xen-unstable

changeset 5830:2ecb91fb6cdb

Fix wallclock timebase extraction in XenLinux.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Jul 19 09:26:18 2005 +0000 (2005-07-19)
parents bf68b5fcbc9b
children 581902ddd16f
files linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Tue Jul 19 08:52:32 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Tue Jul 19 09:26:18 2005 +0000
     1.3 @@ -227,9 +227,9 @@ static unsigned long get_usec_offset(str
     1.4  static void update_wallclock(void)
     1.5  {
     1.6  	shared_info_t *s = HYPERVISOR_shared_info;
     1.7 -	long wtm_nsec;
     1.8 -	time_t wtm_sec, sec;
     1.9 -	s64 nsec;
    1.10 +	long wtm_nsec, xtime_nsec;
    1.11 +	time_t wtm_sec, xtime_sec;
    1.12 +	u64 tmp, usec;
    1.13  
    1.14  	shadow_tv.tv_sec  = s->wc_sec;
    1.15  	shadow_tv.tv_usec = s->wc_usec;
    1.16 @@ -240,20 +240,22 @@ static void update_wallclock(void)
    1.17  	if ((time_status & STA_UNSYNC) != 0)
    1.18  		return;
    1.19  
    1.20 -	/* Adjust shadow for jiffies that haven't updated xtime yet. */
    1.21 -	shadow_tv.tv_usec -= 
    1.22 -		(jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
    1.23 -	HANDLE_USEC_UNDERFLOW(shadow_tv);
    1.24 +	/* Adjust wall-clock time base based on wall_jiffies ticks. */
    1.25 +	usec = processed_system_time;
    1.26 +	do_div(usec, 1000);
    1.27 +	usec += (u64)shadow_tv.tv_sec * 1000000ULL;
    1.28 +	usec += (u64)shadow_tv.tv_usec;
    1.29 +	usec -= (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ);
    1.30  
    1.31 -	/* Update our unsynchronised xtime appropriately. */
    1.32 -	sec = shadow_tv.tv_sec;
    1.33 -	nsec = shadow_tv.tv_usec * NSEC_PER_USEC;
    1.34 +	/* Split wallclock base into seconds and nanoseconds. */
    1.35 +	tmp = usec;
    1.36 +	xtime_nsec = do_div(tmp, 1000000) * 1000ULL;
    1.37 +	xtime_sec  = (time_t)tmp;
    1.38  
    1.39 -	__normalize_time(&sec, &nsec);
    1.40 -	wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
    1.41 -	wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
    1.42 +	wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - xtime_sec);
    1.43 +	wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - xtime_nsec);
    1.44  
    1.45 -	set_normalized_timespec(&xtime, sec, nsec);
    1.46 +	set_normalized_timespec(&xtime, xtime_sec, xtime_nsec);
    1.47  	set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
    1.48  }
    1.49