[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4ab0ec23-51c7-0258-4776-3268120f0c9e@huawei.com>
Date: Mon, 19 Apr 2021 17:33:58 +0800
From: "wangyanan (Y)" <wangyanan55@...wei.com>
To: David Laight <David.Laight@...LAB.COM>,
Paolo Bonzini <pbonzini@...hat.com>
CC: Vitaly Kuznetsov <vkuznets@...hat.com>,
Andrew Jones <drjones@...hat.com>,
Ben Gardon <bgardon@...gle.com>,
Sean Christopherson <seanjc@...gle.com>,
Peter Xu <peterx@...hat.com>,
"wanghaibin.wang@...wei.com" <wanghaibin.wang@...wei.com>,
"yuzenghui@...wei.com" <yuzenghui@...wei.com>,
kvm <kvm@...r.kernel.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v6 03/10] KVM: selftests: Use flag CLOCK_MONOTONIC_RAW for
timing
On 2021/4/19 16:22, David Laight wrote:
> From: wangyanan (Y)
>> Sent: 19 April 2021 07:40
>>
>> Hi Paolo,
>>
>> On 2021/4/17 21:23, Paolo Bonzini wrote:
>>> On 30/03/21 10:08, Yanan Wang wrote:
>>>> In addition to function of CLOCK_MONOTONIC, flag CLOCK_MONOTONIC_RAW can
>>>> also shield possiable impact of NTP, which can provide more robustness.
>>>>
>>>> Suggested-by: Vitaly Kuznetsov<vkuznets@...hat.com>
>>>> Signed-off-by: Yanan Wang<wangyanan55@...wei.com>
>>>> Reviewed-by: Ben Gardon<bgardon@...gle.com>
>>>> Reviewed-by: Andrew Jones<drjones@...hat.com>
>>> I'm not sure about this one, is the effect visible?
>>>
>> In practice, difference between results got with CLOCK_MONOTONIC and
>> CLOCK_MONOTONIC_RAW
>> actually is too little to be visible. But if just in theory,
>> CLOCK_MONOTONIC_RAW can ensure time results
>> of the compared tests are based on the same local oscillator frequency,
>> which is not subject to possible
>> NTP frequency adjustment. Change in this patch seems like a bit of
>> optimization.
> The real annoyance is when NTP is realigning the local clock.
> This typically happens after boot - but can take quite a few
> minutes (don't think it can quite get to an hour).
> (I think something similar is caused by leap seconds.)
>
> During this period CLOCK_MONOTONIC can run at a significantly
> different rate from 'real time'.
> This may not matter for timing self tests, but is significant
> for RTP audio.
>
> The problem there is that you want the NTP corrected time
> during 'normal running' because the small correction (for
> crystal error) is useful.
>
> But the kernel HR timers are only defined for CLOCK_MONOTONIC
> and the userspace requests for CLOCK_MONOTONIC_RAW are likely
> to be real system calls.
>
> What you really want is a clock whose frequency is adjusted
> by NTP but doesn't have the NTP offset adjuctments.
> In reality this ought to be CLOCK_MONOTONIC.
Hi David,
I see now, much thanks for the above explanation. :)
Still have a lot to learn about this part.
Thanks,
Yanan
>
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
Powered by blists - more mailing lists