diff -aru ../xen-2.0.7-orig/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/time.c linux-2.6.11-xen-sparse/arch/xen/i386/kernel/time.c --- ../xen-2.0.7-orig/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/time.c 2005-08-03 16:57:57.000000000 -0700 +++ linux-2.6.11-xen-sparse/arch/xen/i386/kernel/time.c 2005-09-22 18:19:36.000000000 -0700 @@ -96,6 +96,11 @@ static struct timeval shadow_tv; extern u64 processed_system_time; +/* DG: local copy of the tdf, only for guests */ +#ifndef CONFIG_XEN_PRIVILEGED_GUEST +u32 time_dilation_factor; +#endif + /* * We use this to ensure that gettimeofday() is monotonically increasing. We * only break this guarantee if the wall clock jumps backwards "a long way". @@ -165,6 +170,9 @@ shadow_tv.tv_usec = s->wc_usec; shadow_tsc_stamp = (u32)s->tsc_timestamp; shadow_system_time = s->system_time; +#ifndef CONFIG_XEN_PRIVILEGED_GUEST + time_dilation_factor = s->time_dilation_factor; +#endif rmb(); } while (shadow_time_version != s->time_version1); @@ -381,6 +389,21 @@ s64 delta, nsec; long sec_diff, wtm_nsec; + /* TDF: new variables */ + u32 sync_time, warp_time; + +#ifndef CONFIG_XEN_PRIVILEGED_GUEST + /* if we have a TDF > 1, then do aggressive time syncing + * basically on every timer interrupt */ + if(time_dilation_factor > 1) + sync_time = 0; + + /* if we have a TDF > 1, then we need to scale the warp time + * appropriately */ + if(time_dilation_factor > 1) + warp_time /= time_dilation_factor; +#endif + do { __get_time_values_from_xen(); @@ -388,6 +411,16 @@ ((s64)cur_timer->get_offset() * (s64)NSEC_PER_USEC) - processed_system_time); +#ifndef CONFIG_XEN_PRIVILEGED_GUEST + /* ideally, this should never happen */ + if(delta < 0) + { + /* we some how ran ahead, re-sync */ + shadow_system_time = processed_system_time; + /* reassign delta, always +ve */ + delta = (cur_timer->get_offset() * NSEC_PER_USEC); + } +#endif } while (!TIME_VALUES_UP_TO_DATE); @@ -418,7 +451,7 @@ */ if (!INDEPENDENT_WALLCLOCK() && ((time_status & STA_UNSYNC) != 0) && - (xtime.tv_sec > (last_update_from_xen + 60))) { + (xtime.tv_sec > (last_update_from_xen + sync_time))) { /* Adjust shadow for jiffies that haven't updated xtime yet. */ shadow_tv.tv_usec -= (jiffies - wall_jiffies) * (USEC_PER_SEC / HZ); @@ -432,7 +465,7 @@ if (unlikely(abs(sec_diff) > 1) || unlikely(((sec_diff * USEC_PER_SEC) + (xtime.tv_nsec / NSEC_PER_USEC) - - shadow_tv.tv_usec) > 500000)) { + shadow_tv.tv_usec) > warp_time)) { #ifdef CONFIG_XEN_PRIVILEGED_GUEST last_rtc_update = last_update_to_xen = 0; #endif @@ -672,6 +705,7 @@ { unsigned int cpu = smp_processor_id(); unsigned long j; + u64 alarm = 0; /* s390 does this /before/ checking rcu_pending(). We copy them. */ cpu_set(cpu, nohz_cpu_mask); @@ -684,7 +718,14 @@ j = next_timer_interrupt(); } - BUG_ON(HYPERVISOR_set_timer_op(__jiffies_to_st(j)) != 0); +#ifdef CONFIG_XEN_PRIVILEGED_GUEST + alarm = __jiffies_to_st(j); +#else + alarm = time_dilation_factor * __jiffies_to_st(j); +#endif + + /*BUG_ON(HYPERVISOR_set_timer_op(__jiffies_to_st(j)) != 0);*/ + BUG_ON(HYPERVISOR_set_timer_op(alarm) != 0); } void start_hz_timer(void) diff -aru ../xen-2.0.7-orig/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/param.h linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/param.h --- ../xen-2.0.7-orig/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/param.h 2005-08-03 16:57:57.000000000 -0700 +++ linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/param.h 2005-09-22 18:19:53.000000000 -0700 @@ -2,7 +2,8 @@ #define _ASMi386_PARAM_H #ifdef __KERNEL__ -# define HZ 100 /* Internal kernel timer frequency */ +/* DG: Xen originally used HZ = 100 for the guests */ +# define HZ 1000 /* Internal kernel timer frequency */ # define USER_HZ 100 /* .. some user interfaces are in "ticks" */ # define CLOCKS_PER_SEC (USER_HZ) /* like times() */ #endif