2014-10-15 07:32:58

by Thomas Shao

[permalink] [raw]
Subject: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()

Export do_adjtimex function for hyper-v Time Synchronization component

Signed-off-by: Thomas Shao <[email protected]>
---
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


2014-10-20 18:28:10

by Thomas Gleixner

[permalink] [raw]
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....

> Export do_adjtimex function for hyper-v Time Synchronization component
>
> Signed-off-by: Thomas Shao <[email protected]>
> ---
> 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
>
>

2014-10-20 18:40:51

by Thomas Gleixner

[permalink] [raw]
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.

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

2014-10-21 02:38:06

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()


> -----Original Message-----
> From: Thomas Gleixner [mailto:[email protected]]
> Sent: Tuesday, October 21, 2014 2:28 AM
> To: Thomas Shao
> Cc: [email protected]; LKML; [email protected];
> [email protected]; [email protected]; [email protected]; 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 <[email protected]>
> > ---
> > 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
> >
> >

2014-10-21 03:19:18

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()


> -----Original Message-----
> From: [email protected] [mailto:linux-kernel-
> [email protected]] On Behalf Of Thomas Gleixner
> Sent: Tuesday, October 21, 2014 2:41 AM
> To: Thomas Shao
> Cc: [email protected]; LKML; [email protected];
> [email protected]; [email protected]; [email protected]; 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 [email protected] More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2014-10-21 03:24:27

by John Stultz

[permalink] [raw]
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 <[email protected]> wrote:
>
>> -----Original Message-----
>> From: [email protected] [mailto:linux-kernel-
>> [email protected]] On Behalf Of Thomas Gleixner
>> Sent: Tuesday, October 21, 2014 2:41 AM
>> To: Thomas Shao
>> Cc: [email protected]; LKML; [email protected];
>> [email protected]; [email protected]; [email protected]; 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

2014-10-21 04:02:23

by Jeff Epler

[permalink] [raw]
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.

2014-10-21 04:09:45

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()



> -----Original Message-----
> From: John Stultz [mailto:[email protected]]
> Sent: Tuesday, October 21, 2014 11:24 AM
> To: Thomas Shao
> Cc: Thomas Gleixner; [email protected]; LKML;
> [email protected]; [email protected]; [email protected];
> [email protected]; 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 <[email protected]>
> wrote:
> >
> >> -----Original Message-----
> >> From: [email protected] [mailto:linux-kernel-
> >> [email protected]] On Behalf Of Thomas Gleixner
> >> Sent: Tuesday, October 21, 2014 2:41 AM
> >> To: Thomas Shao
> >> Cc: [email protected]; LKML; [email protected];
> >> [email protected]; [email protected]; [email protected]; 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?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2014-10-21 04:56:33

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()


> -----Original Message-----
> From: Jeff Epler [mailto:[email protected]]
> Sent: Tuesday, October 21, 2014 12:02 PM
> To: Thomas Shao
> Cc: Thomas Gleixner; [email protected]; LKML;
> [email protected]; [email protected]; [email protected];
> [email protected]; 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.

2014-10-21 08:14:07

by Richard Cochran

[permalink] [raw]
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'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

2014-10-21 08:19:12

by Thomas Gleixner

[permalink] [raw]
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.

Thanks,

tglx

2014-10-21 08:21:07

by Richard Cochran

[permalink] [raw]
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.

Thanks,
Richard

2014-10-21 08:23:48

by Thomas Gleixner

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()

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

2014-10-21 08:26:06

by Thomas Gleixner

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()

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

2014-10-21 09:02:48

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()


> -----Original Message-----
> From: [email protected] [mailto:linux-kernel-
> [email protected]] On Behalf Of Thomas Gleixner
> Sent: Tuesday, October 21, 2014 4:19 PM
> To: Thomas Shao
> Cc: [email protected]; LKML; [email protected];
> [email protected]; [email protected]; [email protected]; 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 [email protected] More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2014-10-21 09:17:18

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()


> -----Original Message-----
> From: Richard Cochran [mailto:[email protected]]
> Sent: Tuesday, October 21, 2014 4:14 PM
> To: Thomas Shao
> Cc: Thomas Gleixner; [email protected]; LKML;
> [email protected]; [email protected]; [email protected];
> [email protected]; 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

2014-10-21 10:12:33

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()


> -----Original Message-----
> From: [email protected] [mailto:linux-kernel-
> [email protected]] On Behalf Of Richard Cochran
> Sent: Tuesday, October 21, 2014 4:21 PM
> To: Jeff Epler
> Cc: Thomas Shao; Thomas Gleixner; [email protected]; LKML;
> [email protected]; [email protected]; [email protected];
> [email protected]; 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 [email protected] More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2014-10-22 11:01:45

by Mike Surcouf

[permalink] [raw]
Subject: 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.

2014-10-22 12:42:18

by Thomas Gleixner

[permalink] [raw]
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?

Thanks,

tglx

2014-10-22 13:54:33

by Thomas Shao

[permalink] [raw]
Subject: RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()


> -----Original Message-----
> From: [email protected] [mailto:linux-kernel-
> [email protected]] On Behalf Of Thomas Gleixner
> Sent: Wednesday, October 22, 2014 8:42 PM
> To: Mike Surcouf
> Cc: Thomas Shao; Richard Cochran; Jeff Epler; [email protected];
> LKML; [email protected]; [email protected]; [email protected];
> [email protected]; 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 [email protected] More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2014-10-22 14:20:31

by Mike Surcouf

[permalink] [raw]
Subject: 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