ia64/xen-unstable

changeset 9031:5541ea99106a

Periodically sytnchronize Xen's wallclock time with NTP-synchronized time in domain0.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Feb 26 16:38:59 2006 +0100 (2006-02-26)
parents af6a564ea81c
children ab982f583b73
files linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Sun Feb 26 10:55:21 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Sun Feb 26 16:38:59 2006 +0100
     1.3 @@ -487,14 +487,45 @@ int do_settimeofday(struct timespec *tv)
     1.4  
     1.5  EXPORT_SYMBOL(do_settimeofday);
     1.6  
     1.7 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
     1.8 +static void sync_xen_wallclock(unsigned long dummy);
     1.9 +static DEFINE_TIMER(sync_xen_wallclock_timer, sync_xen_wallclock, 0, 0);
    1.10 +static void sync_xen_wallclock(unsigned long dummy)
    1.11 +{
    1.12 +	time_t sec;
    1.13 +	s64 nsec;
    1.14 +	dom0_op_t op;
    1.15 +
    1.16 +	if (!ntp_synced() || independent_wallclock ||
    1.17 +	    !(xen_start_info->flags & SIF_INITDOMAIN))
    1.18 +		return;
    1.19 +
    1.20 +	write_seqlock_irq(&xtime_lock);
    1.21 +
    1.22 +	sec  = xtime.tv_sec;
    1.23 +	nsec = xtime.tv_nsec + ((jiffies - wall_jiffies) * (u64)NS_PER_TICK);
    1.24 +	__normalize_time(&sec, &nsec);
    1.25 +
    1.26 +	op.cmd = DOM0_SETTIME;
    1.27 +	op.u.settime.secs        = sec;
    1.28 +	op.u.settime.nsecs       = nsec;
    1.29 +	op.u.settime.system_time = processed_system_time;
    1.30 +	HYPERVISOR_dom0_op(&op);
    1.31 +
    1.32 +	update_wallclock();
    1.33 +
    1.34 +	write_sequnlock_irq(&xtime_lock);
    1.35 +
    1.36 +	/* Once per minute. */
    1.37 +	mod_timer(&sync_xen_wallclock_timer, jiffies + 60*HZ);
    1.38 +}
    1.39 +
    1.40  static int set_rtc_mmss(unsigned long nowtime)
    1.41  {
    1.42  	int retval;
    1.43  
    1.44  	WARN_ON(irqs_disabled());
    1.45  
    1.46 -	if (!(xen_start_info->flags & SIF_INITDOMAIN))
    1.47 +	if (independent_wallclock || !(xen_start_info->flags & SIF_INITDOMAIN))
    1.48  		return 0;
    1.49  
    1.50  	/* gets recalled with irq locally disabled */
    1.51 @@ -507,12 +538,6 @@ static int set_rtc_mmss(unsigned long no
    1.52  
    1.53  	return retval;
    1.54  }
    1.55 -#else
    1.56 -static int set_rtc_mmss(unsigned long nowtime)
    1.57 -{
    1.58 -	return 0;
    1.59 -}
    1.60 -#endif
    1.61  
    1.62  /* monotonic_clock(): returns # of nanoseconds passed since time_init()
    1.63   *		Note: This function is required to return accurate
    1.64 @@ -768,6 +793,7 @@ static void sync_cmos_clock(unsigned lon
    1.65  void notify_arch_cmos_timer(void)
    1.66  {
    1.67  	mod_timer(&sync_cmos_timer, jiffies + 1);
    1.68 +	mod_timer(&sync_xen_wallclock_timer, jiffies + 1);
    1.69  }
    1.70  
    1.71  static long clock_cmos_diff, sleep_start;