Re: Time keeps on slipping... on Hyper-V
> We still recommend user to configure NTP in the guest VM. With the new time > sync feature in this patch, > you could have one more option to enable the guest-host sync, if the NTP > didn't work in the environment. > For example the guest VM didn't have network connection. Microsoft used to use host time-samples in their older drivers but this was dropped (when I don't know). Now we must use NTP to correct hyperv_clocksource which suffers from the usual problems associated with virtual environment cpu loading. Host time-samples in conjunction with an effective clock stability algorithm with slews rather than steps should be the default. NTP is a workaround and should not be the primary solution. I have seen a lots of posts for RHEL CENTOS Linux that have a FAST.hyper_clocksource confirmed by myself on CENTOS 6.5 and 7.0 (also confirmed by Olaf on SLES). If this patch steps the clock once in a while without any form of slewing then it has the potential to break things as files and logs travel BACK in time. Apologies Thomas could you send me the patch via email as lkml.org does not have it in the archives. Regards Mike -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Drivers: hv: util: Implement Time Synchronization using host time sample
> +/* helper function to call adjtimex command in user mode */ > +static void run_adjtimex_cmd(s64 tickvalue) > +{ > + char *argv[4], *envp[3]; > + char str_tickvalue[20]; > + > + sprintf(str_tickvalue, "%lld", tickvalue); > + > + argv[0] = "/sbin/adjtimex"; > + argv[1] = "-t"; > + argv[2] = str_tickvalue; > + argv[3] = NULL; > + > + envp[0] = "HOME=/"; > + envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; > + envp[2] = NULL; > + > + call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); > +} What happens when adjtimex is not present? Is there no kernel space function for that? Does this patch affect "not setting correct time on restore" or "not setting correct time on live migration" bug? Thanks Mike -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Drivers: hv: util: Implement Time Synchronization using host time sample
>> What happens when adjtimex is not present? >> Is there no kernel space function for that? >> Does this patch affect "not setting correct time on restore" or "not setting >> correct time on live migration" bug? >> > > If adjtimex is not present, then the slew time part didn't take effect. > There is a kernel space do_adjtmex, but it's only for sys call and not > exposed to module. So I didn't use it in my patch. > With this patch, it will step the clock if the time drift is larger than 1 > seconds, so it can solve > the issue your mentioned. And on the other hand, "setting correct time on > restore" is already fixed > in other patch, which is already in upstream. > AFAIK CENTOS and RHEL stopped providing adjtimex for a while now (since V5?). Even went as far as removing references from there man page for hwclock. in V6 On CENTOS 6.5 yum provides */adjtimex Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: centosc6.centos.org * extras: centosb5.centos.org * updates: centosb6.centos.org No Matches found So the end user will have to go searching the internet rpmfind or something to install an unofficial package on an enterprise product. So by default you will be stepping time on CENTOS/RHEL 6 and above: with the result of an unstable clock. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Drivers: hv: util: Implement Time Synchronization using host time sample
In CENTOS and RHEL 6 and upwards the official way would be to use /usr/sbin/tickadj which is provided by ntp/chrony package This dependency on user space packages that may or may not be installed is going to cause a lot of confusion in an already confused space. Are we sure theres no other way? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
I get that NTP can be installed locally. This is how I regulate time on my guests. I agree the admin argument probably doesn't stand up. The problem is hyperv_clocksource (pluggable time source used by hyperv guests) is systematically fast in my environment. by around -250 PPM. I get away with NTP (just). However others have had to use tickadj to get hyperv_clocksource close enough for NTP to work i.e. inside +/-500 PPM. (This IS outside normal admin tasks) So if we are going to use NTP as the solution for hyperv guests (which is a valid one) the systematic drift of hyperv_clocksource in different environments will need to be addressed. Maybe this patch could be modified to tune the tick count on boot before NTP starts and then leave it alone so NTP can take over. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
> Mike, can you share me your kernel version and which Linux distro do you use? 2.6.32-504.el6.x86_64 AKA RHEL 6.6 Happened on centos 7 and 6.5 too. #cat /var/lib/ntp/drift -248.869 About 20 secs a day (constant) Its not a new problem I had this in other distros and other kernels. I would say its environmental but not just my environment. Confirmed with Olaf on SUSEvariants back in 2012 but never came to anything see enc email - > > KY, can your team have a look at this? > > Vijay, have we done time stability test in the recent past. We should > look at replicating this issue on Distros of interest. Olaf, on sles11 > sp2, were you running NTP and how much was the drift. sles11sp2: uptime 23:45 hours, its 38 seconds ahead 12.2: uptime 1 day, 5:17 hours, its 47 seconds ahead ntpd is not running in both guests. > Also, what was the host in this test. The host is an uptodate w2k8 r2. Olaf --- Thanks Mike -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] hyperv: Implement Time Synchronization using host time sample
What is your expected value for TICK_USEC? I cant make the arithmetic work. You double the check time if you are close but you never reduce the check time if you are not. Adjusting the tick count is a coarse adjustment of the clock. You will end up chasing the host time but never stabilizing it. Regarding the comment we have NTP for this I agree that would be better than this implementation and I think Thomas agrees (as he said NTP is the preferred option) In order for this to be a good source of time for RTP and other time sensitive stuff . you will have to have to re-implement parts of NTP such as adjusting the clock frequency decreasing the check period when error becomes too great etc. etc.. I still think there is a requirement for this if it is done more comprehensively. For example depending on CPU loading some Hyperv guests can give a drift of greater than 500ppm which NTP cant cope with. On Tue, Oct 14, 2014 at 1:50 PM, Thomas Shao wrote: > >> -Original Message- >> From: Dan Carpenter [mailto:dan.carpen...@oracle.com] >> Sent: Tuesday, October 14, 2014 7:19 PM >> To: Thomas Shao >> Cc: t...@linutronix.de; gre...@linuxfoundation.org; linux- >> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de; >> a...@canonical.com; jasow...@redhat.com; KY Srinivasan >> Subject: Re: [PATCH 2/2] hyperv: Implement Time Synchronization using host >> time sample >> >> I had a couple small style nits. >> >> On Tue, Oct 14, 2014 at 04:11:18AM -0700, Thomas Shao wrote: >> > diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index >> > 3b9c9ef..1d8390c 100644 >> > --- a/drivers/hv/hv_util.c >> > +++ b/drivers/hv/hv_util.c >> > @@ -51,11 +51,30 @@ >> > #define HB_WS2008_MAJOR1 >> > #define HB_WS2008_VERSION (HB_WS2008_MAJOR << 16 | >> HB_MINOR) >> > >> > +#define TIMESAMPLE_INTERVAL 50L /* 5s in nanosecond */ >> >> If you wanted you could say: >> >> #define TIMESAMPLE_INTERVAL (5 * NSEC_PER_SEC) >> >> > + >> > +/*host sends time sample for every 5s.So the max polling interval >> > +*is 128*5 = 640s. >> > +*/ >> >> The comment still has problems throughout. Read >> Documentation/CodingStyle. >> > > I will correct the style of the comment. > >> > +#define TIME_ADJ_MAX_INTERVAL 128 /*Max polling interval */ >> > + >> > static int sd_srv_version; >> > static int ts_srv_version; >> > static int hb_srv_version; >> > static int util_fw_version; >> > >> > +/*host sends time sample for every 5s.So the initial polling interval >> > +*is 5s. >> > +*/ >> > +static s32 adj_interval = 1; >> >> Prefer mundane types instead there is a reason. This should be int because >> it's not specified in a hardware spec. I know you are being consistent with >> the surrounding code, but the surrounding code is bad so don't emulate it. >> > I agree with you. Maybe it's a good idea to correct the surrounding code in > another patch. > >> > + >> > +/*The host_time_sync module parameter is used to control the time >> > + sync between host and guest. >> > +*/ >> > +static bool host_time_sync; >> > +module_param(host_time_sync, bool, (S_IRUGO | S_IWUSR)); >> > +MODULE_PARM_DESC(host_time_sync, "If the guest sync time with >> host"); >> >> Maybe say: "Synchronize time with the host"? > > Sounds good. > >> >> > + >> > static void shutdown_onchannelcallback(void *context); static struct >> > hv_util_service util_shutdown = { >> > .util_cb = shutdown_onchannelcallback, @@ -163,15 +182,61 @@ >> static >> > void shutdown_onchannelcallback(void *context) >> > /* >> > * Set guest time to host UTC time. >> > */ >> > -static inline void do_adj_guesttime(u64 hosttime) >> > +static inline void do_adj_guesttime(u64 hosttime, bool forceSync) >> >> I'm surprise checkpatch.pl does't complain about this CamelCase. > > I've run the scripts/checkpatch.pl, it didn't complain anything. I'll change > to forcesync. > >> >> regards, >> dan carpenter > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] hyperv: Implement Time Synchronization using host time sample
Even with networking I think there are other senarios where this would be useful such as no access to an NTP server due to firewall rules or no internal NTP or simply an admin without much knowledge of NTP. HyperV host very likely has good time from AD and it would be good if the Linux VM just synced its time from the host after a vanilla install (just like windows VMs). That would require no configuration and probably save a ton of support traffic. However this patch requires a module parameter which really negates the zero configuration argument. Also please don't make this the default until the timesync component is more comprehensive and provides a stable time of similar quality to NTP. VMware has put a lot of effort into host -> guest timesync so I think there is a case for some form of host based time sync on HyperV. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] hyperv: Implement Time Synchronization using host time sample
>The value for TICK_USEC is defined as ((100UL + USER_HZ/2) / USER_HZ). > In my box, it's 1. OK got it thanks . Checked the algorithm OK by me. Of course you can only adjust clock by a tick (smallest resolution) so you could be flapping between 2 values so as you say NTP is preferred. However it may be good enough for some scenarios. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/