linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
@ 2014-10-15  8:39 Thomas Shao
  2014-10-20 18:28 ` Thomas Gleixner
  0 siblings, 1 reply; 21+ messages in thread
From: Thomas Shao @ 2014-10-15  8:39 UTC (permalink / raw)
  To: tglx, gregkh, linux-kernel, devel, olaf, apw, jasowang, kys; +Cc: Thomas Shao

Export do_adjtimex function for hyper-v Time Synchronization component

Signed-off-by: Thomas Shao <huishao@microsoft.com>
---
 kernel/time/timekeeping.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index ec1791f..205a4b3 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1786,6 +1786,7 @@ int do_adjtimex(struct timex *txc)
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(do_adjtimex);
 
 #ifdef CONFIG_NTP_PPS
 /**
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-15  8:39 [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex() Thomas Shao
@ 2014-10-20 18:28 ` Thomas Gleixner
  2014-10-20 18:40   ` Thomas Gleixner
  2014-10-21  2:37   ` Thomas Shao
  0 siblings, 2 replies; 21+ messages in thread
From: Thomas Gleixner @ 2014-10-20 18:28 UTC (permalink / raw)
  To: Thomas Shao; +Cc: gregkh, LKML, devel, olaf, apw, jasowang, kys, John Stultz

On Wed, 15 Oct 2014, Thomas Shao wrote:

And again you forgot to cc John Stultz on this....

> Export do_adjtimex function for hyper-v Time Synchronization component
> 
> Signed-off-by: Thomas Shao <huishao@microsoft.com>
> ---
>  kernel/time/timekeeping.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> index ec1791f..205a4b3 100644
> --- a/kernel/time/timekeeping.c
> +++ b/kernel/time/timekeeping.c
> @@ -1786,6 +1786,7 @@ int do_adjtimex(struct timex *txc)
>  
>  	return ret;
>  }
> +EXPORT_SYMBOL_GPL(do_adjtimex);
>  
>  #ifdef CONFIG_NTP_PPS
>  /**
> -- 
> 1.7.1
> 
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-20 18:28 ` Thomas Gleixner
@ 2014-10-20 18:40   ` Thomas Gleixner
  2014-10-21  3:18     ` Thomas Shao
  2014-10-21  2:37   ` Thomas Shao
  1 sibling, 1 reply; 21+ messages in thread
From: Thomas Gleixner @ 2014-10-20 18:40 UTC (permalink / raw)
  To: Thomas Shao
  Cc: gregkh, LKML, devel, olaf, apw, jasowang, kys, John Stultz,
	Richard Cochran

On Mon, 20 Oct 2014, Thomas Gleixner wrote:

> On Wed, 15 Oct 2014, Thomas Shao wrote:
> 
> And again you forgot to cc John Stultz on this....
> 
> > Export do_adjtimex function for hyper-v Time Synchronization component

Aside of that, we really want to see the use case for this and how you
addressed the problems which were pointed out by various folks.

I still do not have a consistent argument from you WHY you need to
abuse do_adjtimex() to do that host - guest synchronization in the
first place.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-20 18:28 ` Thomas Gleixner
  2014-10-20 18:40   ` Thomas Gleixner
@ 2014-10-21  2:37   ` Thomas Shao
  1 sibling, 0 replies; 21+ messages in thread
From: Thomas Shao @ 2014-10-21  2:37 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: gregkh, LKML, devel, olaf, apw, jasowang, KY Srinivasan, John Stultz


> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Tuesday, October 21, 2014 2:28 AM
> To: Thomas Shao
> Cc: gregkh@linuxfoundation.org; LKML; devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
> John Stultz
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Wed, 15 Oct 2014, Thomas Shao wrote:
> 
> And again you forgot to cc John Stultz on this....

I'll cc John Stultz in the future. Sorry for that.

> 
> > Export do_adjtimex function for hyper-v Time Synchronization component
> >
> > Signed-off-by: Thomas Shao <huishao@microsoft.com>
> > ---
> >  kernel/time/timekeeping.c |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
> > index ec1791f..205a4b3 100644
> > --- a/kernel/time/timekeeping.c
> > +++ b/kernel/time/timekeeping.c
> > @@ -1786,6 +1786,7 @@ int do_adjtimex(struct timex *txc)
> >
> >  	return ret;
> >  }
> > +EXPORT_SYMBOL_GPL(do_adjtimex);
> >
> >  #ifdef CONFIG_NTP_PPS
> >  /**
> > --
> > 1.7.1
> >
> >

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-20 18:40   ` Thomas Gleixner
@ 2014-10-21  3:18     ` Thomas Shao
  2014-10-21  3:24       ` John Stultz
                         ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Thomas Shao @ 2014-10-21  3:18 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: gregkh, LKML, devel, olaf, apw, jasowang, KY Srinivasan,
	John Stultz, Richard Cochran


> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Thomas Gleixner
> Sent: Tuesday, October 21, 2014 2:41 AM
> To: Thomas Shao
> Cc: gregkh@linuxfoundation.org; LKML; devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
> John Stultz; Richard Cochran
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Mon, 20 Oct 2014, Thomas Gleixner wrote:
> 
> > On Wed, 15 Oct 2014, Thomas Shao wrote:
> >
> > And again you forgot to cc John Stultz on this....
> >
> > > Export do_adjtimex function for hyper-v Time Synchronization
> > > component
> 
> Aside of that, we really want to see the use case for this and how you
> addressed the problems which were pointed out by various folks.
> 

In some situation, the user is not able to enable guest VM to sync with external 
time source, like NTP. But the host is still synced with a trusted time source. 
In this case, host-guest time synchronization is useful. Hyper-v host will send time
sample to guest VM every 5 seconds. We will use these time samples to adjust guest
VM time. 

I've got some feedbacks from Richard and Mike, including reference NTP implementation
and do the adjustment in the host side. I've already referenced some NTP design in
my patch. I would consider my patch as a simplified implementation. I've also considered
the host side implementation. But in host, we can only set time but not gradually slew/adjust
time, which is not acceptable for the time sync solution.We still recommend user to configure
NTP on the guest, which provides better accuracy. But if NTP is not applicable, this could be 
another option. 

> I still do not have a consistent argument from you WHY you need to abuse
> do_adjtimex() to do that host - guest synchronization in the first place.
> 

I need a function to gradually slew guest time. do_adjtimex() provides all the 
functionality. Also I could not find any other exposed func to do this. I'd like to
hear any feedback from you for this.

> Thanks,
> 
> 	tglx
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the
> body of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  3:18     ` Thomas Shao
@ 2014-10-21  3:24       ` John Stultz
  2014-10-21  4:08         ` Thomas Shao
  2014-10-21  4:02       ` Jeff Epler
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 21+ messages in thread
From: John Stultz @ 2014-10-21  3:24 UTC (permalink / raw)
  To: Thomas Shao
  Cc: Thomas Gleixner, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, Richard Cochran

On Mon, Oct 20, 2014 at 8:18 PM, Thomas Shao <huishao@microsoft.com> wrote:
>
>> -----Original Message-----
>> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
>> owner@vger.kernel.org] On Behalf Of Thomas Gleixner
>> Sent: Tuesday, October 21, 2014 2:41 AM
>> To: Thomas Shao
>> Cc: gregkh@linuxfoundation.org; LKML; devel@linuxdriverproject.org;
>> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
>> John Stultz; Richard Cochran
>> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
>> do_adjtimex()
>>
>> On Mon, 20 Oct 2014, Thomas Gleixner wrote:
>>
>> > On Wed, 15 Oct 2014, Thomas Shao wrote:
>> >
>> > And again you forgot to cc John Stultz on this....
>> >
>> > > Export do_adjtimex function for hyper-v Time Synchronization
>> > > component
>>
>> Aside of that, we really want to see the use case for this and how you
>> addressed the problems which were pointed out by various folks.
>>
>
> In some situation, the user is not able to enable guest VM to sync with external
> time source, like NTP. But the host is still synced with a trusted time source.
> In this case, host-guest time synchronization is useful. Hyper-v host will send time
> sample to guest VM every 5 seconds. We will use these time samples to adjust guest
> VM time.
>
> I've got some feedbacks from Richard and Mike, including reference NTP implementation
> and do the adjustment in the host side. I've already referenced some NTP design in
> my patch. I would consider my patch as a simplified implementation. I've also considered
> the host side implementation. But in host, we can only set time but not gradually slew/adjust
> time, which is not acceptable for the time sync solution.We still recommend user to configure
> NTP on the guest, which provides better accuracy. But if NTP is not applicable, this could be
> another option.
>
>> I still do not have a consistent argument from you WHY you need to abuse
>> do_adjtimex() to do that host - guest synchronization in the first place.
>>
>
> I need a function to gradually slew guest time. do_adjtimex() provides all the
> functionality. Also I could not find any other exposed func to do this. I'd like to
> hear any feedback from you for this.

Do you have any protections from both your kernel module trying to
slew time if the guest is also running NTPd? That seems like it could
cause some strange behavior.

thanks
-john

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  3:18     ` Thomas Shao
  2014-10-21  3:24       ` John Stultz
@ 2014-10-21  4:02       ` Jeff Epler
  2014-10-21  4:55         ` Thomas Shao
  2014-10-21  8:20         ` Richard Cochran
  2014-10-21  8:13       ` Richard Cochran
  2014-10-21  8:19       ` Thomas Gleixner
  3 siblings, 2 replies; 21+ messages in thread
From: Jeff Epler @ 2014-10-21  4:02 UTC (permalink / raw)
  To: Thomas Shao
  Cc: Thomas Gleixner, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, John Stultz, Richard Cochran

On Tue, Oct 21, 2014 at 03:18:58AM +0000, Thomas Shao wrote:
> In some situation, the user is not able to enable guest VM to sync with external 
> time source, like NTP. But the host is still synced with a trusted time source. 
> In this case, host-guest time synchronization is useful.

It's interesting to imagine that a virtualization host could present a
time service to the guest *userspace*, even when the guest is not
otherwise exposed to the internet at large.  This could take the form of
an NTP server on a private network, or as an implementation of a time
source directly usable by ntpd in the guest, for instance as an emulated
serial port with synthetic NEMA GPS signal + PPS signal, for instance.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  3:24       ` John Stultz
@ 2014-10-21  4:08         ` Thomas Shao
  2014-10-21  8:23           ` Thomas Gleixner
  0 siblings, 1 reply; 21+ messages in thread
From: Thomas Shao @ 2014-10-21  4:08 UTC (permalink / raw)
  To: John Stultz
  Cc: Thomas Gleixner, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, Richard Cochran

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3864 bytes --]



> -----Original Message-----
> From: John Stultz [mailto:john.stultz@linaro.org]
> Sent: Tuesday, October 21, 2014 11:24 AM
> To: Thomas Shao
> Cc: Thomas Gleixner; gregkh@linuxfoundation.org; LKML;
> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com; KY Srinivasan; Richard Cochran
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Mon, Oct 20, 2014 at 8:18 PM, Thomas Shao <huishao@microsoft.com>
> wrote:
> >
> >> -----Original Message-----
> >> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> >> owner@vger.kernel.org] On Behalf Of Thomas Gleixner
> >> Sent: Tuesday, October 21, 2014 2:41 AM
> >> To: Thomas Shao
> >> Cc: gregkh@linuxfoundation.org; LKML; devel@linuxdriverproject.org;
> >> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY
> >> Srinivasan; John Stultz; Richard Cochran
> >> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> >> do_adjtimex()
> >>
> >> On Mon, 20 Oct 2014, Thomas Gleixner wrote:
> >>
> >> > On Wed, 15 Oct 2014, Thomas Shao wrote:
> >> >
> >> > And again you forgot to cc John Stultz on this....
> >> >
> >> > > Export do_adjtimex function for hyper-v Time Synchronization
> >> > > component
> >>
> >> Aside of that, we really want to see the use case for this and how
> >> you addressed the problems which were pointed out by various folks.
> >>
> >
> > In some situation, the user is not able to enable guest VM to sync
> > with external time source, like NTP. But the host is still synced with a
> trusted time source.
> > In this case, host-guest time synchronization is useful. Hyper-v host
> > will send time sample to guest VM every 5 seconds. We will use these
> > time samples to adjust guest VM time.
> >
> > I've got some feedbacks from Richard and Mike, including reference NTP
> > implementation and do the adjustment in the host side. I've already
> > referenced some NTP design in my patch. I would consider my patch as a
> > simplified implementation. I've also considered the host side
> > implementation. But in host, we can only set time but not gradually
> > slew/adjust time, which is not acceptable for the time sync
> > solution.We still recommend user to configure NTP on the guest, which
> provides better accuracy. But if NTP is not applicable, this could be another
> option.
> >
> >> I still do not have a consistent argument from you WHY you need to
> >> abuse
> >> do_adjtimex() to do that host - guest synchronization in the first place.
> >>
> >
> > I need a function to gradually slew guest time. do_adjtimex() provides
> > all the functionality. Also I could not find any other exposed func to
> > do this. I'd like to hear any feedback from you for this.
> 
> Do you have any protections from both your kernel module trying to slew
> time if the guest is also running NTPd? That seems like it could cause some
> strange behavior.

Thanks John.
I didn't find a way to detect whether NTPd is running in the hyper-v module.  

In http://doc.ntp.org/4.1.0/ntpd.htm, it mentioned: Normally, the time is slewed
 if the offset is less than the step threshold, which is 128 ms by default, and 
stepped if above the threshold.

In my implementation, I use 100ms as the threshold (maybe I should change to 128?).
If the time difference is less than 100ms, I just do nothing. So, if NTPd is running, ideally it 
could keep the time drift less than 128, so the adjustment in my patch will not get 
triggered. 

And moreover, by default, the guest-host time sync is turn off. There is a module parameter
to control it. We'll also document customer that do not turn on this if NTP is configured.

> 
> thanks
> -john
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  4:02       ` Jeff Epler
@ 2014-10-21  4:55         ` Thomas Shao
  2014-10-21  8:25           ` Thomas Gleixner
  2014-10-21  8:20         ` Richard Cochran
  1 sibling, 1 reply; 21+ messages in thread
From: Thomas Shao @ 2014-10-21  4:55 UTC (permalink / raw)
  To: Jeff Epler
  Cc: Thomas Gleixner, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, John Stultz, Richard Cochran


> -----Original Message-----
> From: Jeff Epler [mailto:jepler@unpythonic.net]
> Sent: Tuesday, October 21, 2014 12:02 PM
> To: Thomas Shao
> Cc: Thomas Gleixner; gregkh@linuxfoundation.org; LKML;
> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com; KY Srinivasan; John Stultz; Richard Cochran
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Tue, Oct 21, 2014 at 03:18:58AM +0000, Thomas Shao wrote:
> > In some situation, the user is not able to enable guest VM to sync
> > with external time source, like NTP. But the host is still synced with a
> trusted time source.
> > In this case, host-guest time synchronization is useful.
> 
> It's interesting to imagine that a virtualization host could present a time
> service to the guest *userspace*, even when the guest is not otherwise
> exposed to the internet at large.  This could take the form of an NTP server
> on a private network, or as an implementation of a time source directly
> usable by ntpd in the guest, for instance as an emulated serial port with
> synthetic NEMA GPS signal + PPS signal, for instance.

Yeah. There is already some guidance about how to setup a local NTP server. But it 
requires some additional efforts for IT admins. I don't think we need configure
every host as a time source. Typically we could setup one server shared by the 
private network, and that server needs to be synced with upstream NTP server. 

I'm also thinking if NTPd could expose some interface to allow other application to
directly provide time source for it to consume. In my opinion, emulating the ntp 
source should be very hard and error prone.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  3:18     ` Thomas Shao
  2014-10-21  3:24       ` John Stultz
  2014-10-21  4:02       ` Jeff Epler
@ 2014-10-21  8:13       ` Richard Cochran
  2014-10-21  9:16         ` Thomas Shao
  2014-10-21  8:19       ` Thomas Gleixner
  3 siblings, 1 reply; 21+ messages in thread
From: Richard Cochran @ 2014-10-21  8:13 UTC (permalink / raw)
  To: Thomas Shao
  Cc: Thomas Gleixner, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, John Stultz, Richard Cochran

On Tue, Oct 21, 2014 at 03:18:58AM +0000, Thomas Shao wrote:
> 
> In some situation, the user is not able to enable guest VM to sync with external 
> time source, like NTP. But the host is still synced with a trusted time source. 

But the guest *is* networked, right?

(Otherwise syncing the guest's clock is pointless.)

> I've got some feedbacks from Richard and Mike, including reference NTP implementation
> and do the adjustment in the host side. I've already referenced some NTP design in
> my patch. I would consider my patch as a simplified implementation.

I really don't think we want a half baked servo in some random
driver. Instead, why not present the time difference using a standard
interface?

> I've also considered
> the host side implementation. But in host, we can only set time but not gradually slew/adjust
> time,

Why not implement adjustment in the host?

> which is not acceptable for the time sync solution.We still recommend user to configure
> NTP on the guest, which provides better accuracy. But if NTP is not applicable, this could be 
> another option. 

You did not really answer any of my objections, nor did you consider
the alternative ideas which I offered. Would you care to address
those?

Thanks,
Richard

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  3:18     ` Thomas Shao
                         ` (2 preceding siblings ...)
  2014-10-21  8:13       ` Richard Cochran
@ 2014-10-21  8:19       ` Thomas Gleixner
  2014-10-21  9:02         ` Thomas Shao
  3 siblings, 1 reply; 21+ messages in thread
From: Thomas Gleixner @ 2014-10-21  8:19 UTC (permalink / raw)
  To: Thomas Shao
  Cc: gregkh, LKML, devel, olaf, apw, jasowang, KY Srinivasan,
	John Stultz, Richard Cochran

On Tue, 21 Oct 2014, Thomas Shao wrote:
> > I still do not have a consistent argument from you WHY you need to abuse
> > do_adjtimex() to do that host - guest synchronization in the first place.
> > 
> 
> I need a function to gradually slew guest time. do_adjtimex() provides all the 
> functionality. Also I could not find any other exposed func to do this. I'd like to
> hear any feedback from you for this.

As Richard and others told you already, there are various options:

1) Use NTP on that private network, which does not involve any kernel
   changes at all.

   Your argument, that this is hard for IT-Admins to set up is just
   ridiculous. If an IT-Admin is not able to set that up, then he
   should better stay away from setting up a guest in the first place,
   really.

2) As pointed out already by others PPS/PTP might be a proper solution
   for this.

   All it takes is a pair of timestamps (host/guest) injected into the
   proper subsystem and a controlling daemon on the guest side. That
   would also avoid the problem of running NTPd and your kernel side
   poor mans NTPd at the same time.

   That pseudo NTP thing is just hilarious, really.

   You take the host time stamp in timesync_onchannelcallback() and
   schedule work. From the work queue you correlate the host time
   stamp to the current time of the guest. So you correlate time
   stamps which can be an arbitrary time apart. Brilliant solution
   that, really.

Thanks,

	tglx


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  4:02       ` Jeff Epler
  2014-10-21  4:55         ` Thomas Shao
@ 2014-10-21  8:20         ` Richard Cochran
  2014-10-21 10:11           ` Thomas Shao
  1 sibling, 1 reply; 21+ messages in thread
From: Richard Cochran @ 2014-10-21  8:20 UTC (permalink / raw)
  To: Jeff Epler
  Cc: Thomas Shao, Thomas Gleixner, gregkh, LKML, devel, olaf, apw,
	jasowang, KY Srinivasan, John Stultz, Richard Cochran

On Mon, Oct 20, 2014 at 11:02:13PM -0500, Jeff Epler wrote:
> It's interesting to imagine that a virtualization host could present a
> time service to the guest *userspace*, even when the guest is not
> otherwise exposed to the internet at large.  This could take the form of
> an NTP server on a private network, or as an implementation of a time
> source directly usable by ntpd in the guest, for instance as an emulated
> serial port with synthetic NEMA GPS signal + PPS signal, for instance.

If the idea is to avoid bothering the guest user space, in order to be
convenient, then the host can provide a synthetic PPS, to be used by
the kernel's hardpps logic.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  4:08         ` Thomas Shao
@ 2014-10-21  8:23           ` Thomas Gleixner
  0 siblings, 0 replies; 21+ messages in thread
From: Thomas Gleixner @ 2014-10-21  8:23 UTC (permalink / raw)
  To: Thomas Shao
  Cc: John Stultz, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, Richard Cochran

On Tue, 21 Oct 2014, Thomas Shao wrote:
> I didn't find a way to detect whether NTPd is running in the hyper-v module.  

And you better do not try at all.
 
> In http://doc.ntp.org/4.1.0/ntpd.htm, it mentioned: Normally, the
> time is slewed if the offset is less than the step threshold, which
> is 128 ms by default, and stepped if above the threshold.
>
> In my implementation, I use 100ms as the threshold (maybe I should
> change to 128?).  If the time difference is less than 100ms, I just
> do nothing. So, if NTPd is running, ideally it could keep the time
> drift less than 128, so the adjustment in my patch will not get
> triggered.

Your implementation has nothing to do with NTP at all. It's not even
close to NTP. It's a random hack to inject host time or slew into
timekeeping with the precision of a random number generator.

> And moreover, by default, the guest-host time sync is turn
> off. There is a module parameter to control it. We'll also document
> customer that do not turn on this if NTP is configured.

Pretty well thought out mechanism to ensure that people will get it
wrong in the first place.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  4:55         ` Thomas Shao
@ 2014-10-21  8:25           ` Thomas Gleixner
  0 siblings, 0 replies; 21+ messages in thread
From: Thomas Gleixner @ 2014-10-21  8:25 UTC (permalink / raw)
  To: Thomas Shao
  Cc: Jeff Epler, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, John Stultz, Richard Cochran

On Tue, 21 Oct 2014, Thomas Shao wrote:

> I'm also thinking if NTPd could expose some interface to allow other
> application to directly provide time source for it to consume. In my
> opinion, emulating the ntp source should be very hard and error
> prone.

Well, if done right it would be pretty precise. At least way better
than the random number you feed into do_adjtimex().

Thanks,

	tglx
 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  8:19       ` Thomas Gleixner
@ 2014-10-21  9:02         ` Thomas Shao
  0 siblings, 0 replies; 21+ messages in thread
From: Thomas Shao @ 2014-10-21  9:02 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: gregkh, LKML, devel, olaf, apw, jasowang, KY Srinivasan,
	John Stultz, Richard Cochran


> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Thomas Gleixner
> Sent: Tuesday, October 21, 2014 4:19 PM
> To: Thomas Shao
> Cc: gregkh@linuxfoundation.org; LKML; devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; KY Srinivasan;
> John Stultz; Richard Cochran
> Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Tue, 21 Oct 2014, Thomas Shao wrote:
> > > I still do not have a consistent argument from you WHY you need to
> > > abuse
> > > do_adjtimex() to do that host - guest synchronization in the first place.
> > >
> >
> > I need a function to gradually slew guest time. do_adjtimex() provides
> > all the functionality. Also I could not find any other exposed func to
> > do this. I'd like to hear any feedback from you for this.
> 
> As Richard and others told you already, there are various options:
> 
> 1) Use NTP on that private network, which does not involve any kernel
>    changes at all.
> 
>    Your argument, that this is hard for IT-Admins to set up is just
>    ridiculous. If an IT-Admin is not able to set that up, then he
>    should better stay away from setting up a guest in the first place,
>    really.
> 
> 2) As pointed out already by others PPS/PTP might be a proper solution
>    for this.
> 
>    All it takes is a pair of timestamps (host/guest) injected into the
>    proper subsystem and a controlling daemon on the guest side. That
>    would also avoid the problem of running NTPd and your kernel side
>    poor mans NTPd at the same time.
> 
>    That pseudo NTP thing is just hilarious, really.
> 
>    You take the host time stamp in timesync_onchannelcallback() and
>    schedule work. From the work queue you correlate the host time
>    stamp to the current time of the guest. So you correlate time
>    stamps which can be an arbitrary time apart. Brilliant solution
>    that, really.
> 

OK. I'll investigate these options. Thanks.

> Thanks,
> 
> 	tglx
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the
> body of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  8:13       ` Richard Cochran
@ 2014-10-21  9:16         ` Thomas Shao
  0 siblings, 0 replies; 21+ messages in thread
From: Thomas Shao @ 2014-10-21  9:16 UTC (permalink / raw)
  To: Richard Cochran
  Cc: Thomas Gleixner, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, John Stultz, Richard Cochran


> -----Original Message-----
> From: Richard Cochran [mailto:richardcochran@gmail.com]
> Sent: Tuesday, October 21, 2014 4:14 PM
> To: Thomas Shao
> Cc: Thomas Gleixner; gregkh@linuxfoundation.org; LKML;
> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com; KY Srinivasan; John Stultz; Richard Cochran
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Tue, Oct 21, 2014 at 03:18:58AM +0000, Thomas Shao wrote:
> >
> > In some situation, the user is not able to enable guest VM to sync
> > with external time source, like NTP. But the host is still synced with a
> trusted time source.
> 
> But the guest *is* networked, right?
> 
> (Otherwise syncing the guest's clock is pointless.)
> 

I believe it should be a valid scenario, that NTP is not available in the client,  and we want the guest time sync with host.
Other hypervisor like Xen, VMWare also provide the host-guest time sync feature.

> > I've got some feedbacks from Richard and Mike, including reference NTP
> > implementation and do the adjustment in the host side. I've already
> > referenced some NTP design in my patch. I would consider my patch as a
> simplified implementation.
> 
> I really don't think we want a half baked servo in some random driver.
> Instead, why not present the time difference using a standard interface?

OK. I'll do more investigation. Could you let me know what's the standard interface for presenting time difference you mentioned here? Thanks! 

> 
> > I've also considered
> > the host side implementation. But in host, we can only set time but
> > not gradually slew/adjust time,
> 
> Why not implement adjustment in the host?
> 
> > which is not acceptable for the time sync solution.We still recommend
> > user to configure NTP on the guest, which provides better accuracy.
> > But if NTP is not applicable, this could be another option.
> 
> You did not really answer any of my objections, nor did you consider the
> alternative ideas which I offered. Would you care to address those?

I do not agree the guest VM time adjustment should be handled by the host. In my opinion, the host should not involve in any Guest OS level operation.

> 
> Thanks,
> Richard

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21  8:20         ` Richard Cochran
@ 2014-10-21 10:11           ` Thomas Shao
  2014-10-22 11:01             ` Mike Surcouf
  0 siblings, 1 reply; 21+ messages in thread
From: Thomas Shao @ 2014-10-21 10:11 UTC (permalink / raw)
  To: Richard Cochran, Jeff Epler
  Cc: Thomas Gleixner, gregkh, LKML, devel, olaf, apw, jasowang,
	KY Srinivasan, John Stultz, Richard Cochran


> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Richard Cochran
> Sent: Tuesday, October 21, 2014 4:21 PM
> To: Jeff Epler
> Cc: Thomas Shao; Thomas Gleixner; gregkh@linuxfoundation.org; LKML;
> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com; KY Srinivasan; John Stultz; Richard Cochran
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Mon, Oct 20, 2014 at 11:02:13PM -0500, Jeff Epler wrote:
> > It's interesting to imagine that a virtualization host could present a
> > time service to the guest *userspace*, even when the guest is not
> > otherwise exposed to the internet at large.  This could take the form
> > of an NTP server on a private network, or as an implementation of a
> > time source directly usable by ntpd in the guest, for instance as an
> > emulated serial port with synthetic NEMA GPS signal + PPS signal, for
> instance.
> 
> If the idea is to avoid bothering the guest user space, in order to be
> convenient, then the host can provide a synthetic PPS, to be used by the
> kernel's hardpps logic.
> 

This is something I should consider.  I'll do more investigation for this. Thanks Richard.

> Thanks,
> Richard
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the
> body of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-21 10:11           ` Thomas Shao
@ 2014-10-22 11:01             ` Mike Surcouf
  2014-10-22 12:42               ` Thomas Gleixner
  0 siblings, 1 reply; 21+ messages in thread
From: Mike Surcouf @ 2014-10-22 11:01 UTC (permalink / raw)
  To: Thomas Shao
  Cc: Richard Cochran, Jeff Epler, Thomas Gleixner, gregkh, LKML,
	devel, olaf, apw, jasowang, KY Srinivasan, John Stultz,
	Richard Cochran

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.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-22 11:01             ` Mike Surcouf
@ 2014-10-22 12:42               ` Thomas Gleixner
  2014-10-22 13:51                 ` Thomas Shao
  0 siblings, 1 reply; 21+ messages in thread
From: Thomas Gleixner @ 2014-10-22 12:42 UTC (permalink / raw)
  To: Mike Surcouf
  Cc: Thomas Shao, Richard Cochran, Jeff Epler, gregkh, LKML, devel,
	olaf, apw, jasowang, KY Srinivasan, John Stultz, Richard Cochran

On Wed, 22 Oct 2014, Mike Surcouf wrote:

> 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.

How about fixing hyperv_clocksource in the first place?

Thanks,

	tglx
 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-22 12:42               ` Thomas Gleixner
@ 2014-10-22 13:51                 ` Thomas Shao
  2014-10-22 14:20                   ` Mike Surcouf
  0 siblings, 1 reply; 21+ messages in thread
From: Thomas Shao @ 2014-10-22 13:51 UTC (permalink / raw)
  To: Thomas Gleixner, Mike Surcouf
  Cc: Richard Cochran, Jeff Epler, gregkh, LKML, devel, olaf, apw,
	jasowang, KY Srinivasan, John Stultz, Richard Cochran


> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Thomas Gleixner
> Sent: Wednesday, October 22, 2014 8:42 PM
> To: Mike Surcouf
> Cc: Thomas Shao; Richard Cochran; Jeff Epler; gregkh@linuxfoundation.org;
> LKML; devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com; KY Srinivasan; John Stultz; Richard Cochran
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Wed, 22 Oct 2014, Mike Surcouf wrote:
> 
> > 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.
> 
> How about fixing hyperv_clocksource in the first place?
> 

I've tested the hyperv_clocksource in my environment using upstream kernel. There is some minor time drift (around 1.5 second one day), it should not be that big, and break ntp. 

Mike, can you share me your kernel version and which Linux distro do you use? 

> Thanks,
> 
> 	tglx
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the
> body of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()
  2014-10-22 13:51                 ` Thomas Shao
@ 2014-10-22 14:20                   ` Mike Surcouf
  0 siblings, 0 replies; 21+ messages in thread
From: Mike Surcouf @ 2014-10-22 14:20 UTC (permalink / raw)
  To: Thomas Shao
  Cc: Thomas Gleixner, Richard Cochran, Jeff Epler, gregkh, LKML,
	devel, olaf, apw, jasowang, KY Srinivasan, John Stultz,
	Richard Cochran

> 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

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-10-22 14:20 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-15  8:39 [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex() Thomas Shao
2014-10-20 18:28 ` Thomas Gleixner
2014-10-20 18:40   ` Thomas Gleixner
2014-10-21  3:18     ` Thomas Shao
2014-10-21  3:24       ` John Stultz
2014-10-21  4:08         ` Thomas Shao
2014-10-21  8:23           ` Thomas Gleixner
2014-10-21  4:02       ` Jeff Epler
2014-10-21  4:55         ` Thomas Shao
2014-10-21  8:25           ` Thomas Gleixner
2014-10-21  8:20         ` Richard Cochran
2014-10-21 10:11           ` Thomas Shao
2014-10-22 11:01             ` Mike Surcouf
2014-10-22 12:42               ` Thomas Gleixner
2014-10-22 13:51                 ` Thomas Shao
2014-10-22 14:20                   ` Mike Surcouf
2014-10-21  8:13       ` Richard Cochran
2014-10-21  9:16         ` Thomas Shao
2014-10-21  8:19       ` Thomas Gleixner
2014-10-21  9:02         ` Thomas Shao
2014-10-21  2:37   ` Thomas Shao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).