From: Joe Perches on 5 May 2010 21:00 On Wed, 2010-05-05 at 19:23 +0000, Haiyang Zhang wrote: > From: Haiyang Zhang <haiyangz(a)microsoft.com> > > Subject: Add Time Sync feature to hv_utils module. > The Time Sync feature synchronizes guest time to host UTC time after reboot, > and restore from saved/paused state. > +static void adj_guesttime(winfiletime_t hosttime, u8 flags) > +{ > + s64 host_tns; > + struct timespec host_ts; > + static s32 scnt = 50; Why a maximum of 50 samples? > + host_tns = (hosttime - WLTIMEDELTA) * 100; > + host_ts = ns_to_timespec(host_tns); > + > + if ((flags & ICTIMESYNCFLAG_SYNC) != 0) { > + do_settimeofday(&host_ts); > + return; > + } > + > + if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && > + scnt > 0) { > + scnt--; > + do_settimeofday(&host_ts); > + } It might be better to do something like this so the ns_to_timespec isn't performe when unnecessary. static void settimeofday(winfiletime_t hosttime) { s64 host_tns = (hosttime - WLTIMEDELTA) * 100; struct timespec host_ts = ns_to_timespec(host_tns); do_settimeofday(&host_ts); } static void adj_guesttime(winfiletime_t hosttime, u8 flags) { static s32 scnt = 50; if ((flags & ICTIMESYNCFLAG_SYNC) != 0) { settimeofday(hosttime); return; } if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) { scnt--; settimeofday(hosttime); } } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Haiyang Zhang on 5 May 2010 21:50 > Why a maximum of 50 samples? After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time message after the timesync channel is opened. Since the hv_utils module is loaded after hv_vmbus, the first message is usually missed. The other thing is, systime is automatically set to emulated hardware clock which may not be UTC time or the same time zone. So, to override these effects, we use the first 50 time samples for initial system time setting. > It might be better to do something like this > so the ns_to_timespec isn't performe when unnecessary. Thanks for the optimization, I will put it into the code. - Haiyang-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Joe Perches on 5 May 2010 22:00 On Thu, 2010-05-06 at 01:42 +0000, Haiyang Zhang wrote: > > Why a maximum of 50 samples? > After reboot the flag ICTIMESYNCFLAG_SYNC is included in the > first time message after the timesync channel is opened. Since the > hv_utils module is loaded after hv_vmbus, the first message is usually > missed. The other thing is, systime is automatically set to emulated > hardware clock which may not be UTC time or the same time > zone. So, to override these effects, we use the first 50 time samples > for initial system time setting. I suggest putting that in a commit message or a code comment. cheers, Joe -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|
Pages: 1 Prev: mm: generic adaptive large memory allocation APIs Next: Dear erasmusmc.nl User |