linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'wangyanan (Y)'" <wangyanan55@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	Andrew Jones <drjones@redhat.com>,
	Ben Gardon <bgardon@google.com>,
	Sean Christopherson <seanjc@google.com>,
	Peter Xu <peterx@redhat.com>,
	"wanghaibin.wang@huawei.com" <wanghaibin.wang@huawei.com>,
	"yuzenghui@huawei.com" <yuzenghui@huawei.com>,
	kvm <kvm@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v6 03/10] KVM: selftests: Use flag CLOCK_MONOTONIC_RAW for timing
Date: Mon, 19 Apr 2021 08:22:21 +0000	[thread overview]
Message-ID: <8f36c1973c8147858000dd2a28d046ce@AcuMS.aculab.com> (raw)
In-Reply-To: <82def592-e36c-25c3-c8c5-84c9be83e926@huawei.com>

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@redhat.com>
> >> Signed-off-by: Yanan Wang<wangyanan55@huawei.com>
> >> Reviewed-by: Ben Gardon<bgardon@google.com>
> >> Reviewed-by: Andrew Jones<drjones@redhat.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.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2021-04-19  8:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  8:08 [PATCH v6 00/10] KVM: selftests: some improvement and a new test for kvm page table Yanan Wang
2021-03-30  8:08 ` [PATCH v6 01/10] tools/headers: sync headers of asm-generic/hugetlb_encode.h Yanan Wang
2021-03-30  8:08 ` [PATCH v6 02/10] mm/hugetlb: Add a macro to get HUGETLB page sizes for mmap Yanan Wang
2021-03-30  8:08 ` [PATCH v6 03/10] KVM: selftests: Use flag CLOCK_MONOTONIC_RAW for timing Yanan Wang
2021-04-17 13:23   ` Paolo Bonzini
2021-04-19  6:40     ` wangyanan (Y)
2021-04-19  8:22       ` David Laight [this message]
2021-04-19  9:33         ` wangyanan (Y)
2021-03-30  8:08 ` [PATCH v6 04/10] KVM: selftests: Print the errno besides error-string in TEST_ASSERT Yanan Wang
2021-03-30  8:08 ` [PATCH v6 05/10] KVM: selftests: Make a generic helper to get vm guest mode strings Yanan Wang
2021-03-30  8:08 ` [PATCH v6 06/10] KVM: selftests: Add a helper to get system configured THP page size Yanan Wang
2021-03-30  8:08 ` [PATCH v6 07/10] KVM: selftests: Add a helper to get system default hugetlb " Yanan Wang
2021-03-30  8:08 ` [PATCH v6 08/10] KVM: selftests: List all hugetlb src types specified with page sizes Yanan Wang
2021-03-30  8:08 ` [PATCH v6 09/10] KVM: selftests: Adapt vm_userspace_mem_region_add to new helpers Yanan Wang
2021-03-30  8:08 ` [PATCH v6 10/10] KVM: selftests: Add a test for kvm page table code Yanan Wang
2021-04-06  3:05 ` [PATCH v6 00/10] KVM: selftests: some improvement and a new test for kvm page table wangyanan (Y)
2021-04-17 13:22   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f36c1973c8147858000dd2a28d046ce@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=bgardon@google.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=wangyanan55@huawei.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).