All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Yanan Wang <wangyanan55@huawei.com>
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Ben Gardon <bgardon@google.com>,
	Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Ingo Molnar <mingo@kernel.org>, Peter Xu <peterx@redhat.com>,
	Marc Zyngier <maz@kernel.org>,
	wanghaibin.wang@huawei.com, yuzenghui@huawei.com
Subject: Re: [RFC PATCH v2 2/7] KVM: selftests: Use flag CLOCK_MONOTONIC_RAW for timing
Date: Thu, 25 Feb 2021 19:54:30 +0100	[thread overview]
Message-ID: <20210225185430.fgafepkqo42u2yci@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20210225055940.18748-3-wangyanan55@huawei.com>

On Thu, Feb 25, 2021 at 01:59:35PM +0800, 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.

IIRC, this should include

Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>

> 
> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
> ---
>  tools/testing/selftests/kvm/demand_paging_test.c  |  8 ++++----
>  tools/testing/selftests/kvm/dirty_log_perf_test.c | 14 +++++++-------
>  tools/testing/selftests/kvm/lib/test_util.c       |  2 +-
>  tools/testing/selftests/kvm/steal_time.c          |  4 ++--
>  4 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
> index 5f7a229c3af1..efbf0c1e9130 100644
> --- a/tools/testing/selftests/kvm/demand_paging_test.c
> +++ b/tools/testing/selftests/kvm/demand_paging_test.c
> @@ -53,7 +53,7 @@ static void *vcpu_worker(void *data)
>  	vcpu_args_set(vm, vcpu_id, 1, vcpu_id);
>  	run = vcpu_state(vm, vcpu_id);
>  
> -	clock_gettime(CLOCK_MONOTONIC, &start);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  
>  	/* Let the guest access its memory */
>  	ret = _vcpu_run(vm, vcpu_id);
> @@ -86,7 +86,7 @@ static int handle_uffd_page_request(int uffd, uint64_t addr)
>  	copy.len = perf_test_args.host_page_size;
>  	copy.mode = 0;
>  
> -	clock_gettime(CLOCK_MONOTONIC, &start);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  
>  	r = ioctl(uffd, UFFDIO_COPY, &copy);
>  	if (r == -1) {
> @@ -123,7 +123,7 @@ static void *uffd_handler_thread_fn(void *arg)
>  	struct timespec start;
>  	struct timespec ts_diff;
>  
> -	clock_gettime(CLOCK_MONOTONIC, &start);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  	while (!quit_uffd_thread) {
>  		struct uffd_msg msg;
>  		struct pollfd pollfd[2];
> @@ -336,7 +336,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>  
>  	pr_info("Finished creating vCPUs and starting uffd threads\n");
>  
> -	clock_gettime(CLOCK_MONOTONIC, &start);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  
>  	for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) {
>  		pthread_create(&vcpu_threads[vcpu_id], NULL, vcpu_worker,
> diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c
> index 04a2641261be..6cff4ccf9525 100644
> --- a/tools/testing/selftests/kvm/dirty_log_perf_test.c
> +++ b/tools/testing/selftests/kvm/dirty_log_perf_test.c
> @@ -50,7 +50,7 @@ static void *vcpu_worker(void *data)
>  	while (!READ_ONCE(host_quit)) {
>  		int current_iteration = READ_ONCE(iteration);
>  
> -		clock_gettime(CLOCK_MONOTONIC, &start);
> +		clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  		ret = _vcpu_run(vm, vcpu_id);
>  		ts_diff = timespec_elapsed(start);
>  
> @@ -141,7 +141,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>  	iteration = 0;
>  	host_quit = false;
>  
> -	clock_gettime(CLOCK_MONOTONIC, &start);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  	for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) {
>  		vcpu_last_completed_iteration[vcpu_id] = -1;
>  
> @@ -162,7 +162,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>  		ts_diff.tv_sec, ts_diff.tv_nsec);
>  
>  	/* Enable dirty logging */
> -	clock_gettime(CLOCK_MONOTONIC, &start);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  	vm_mem_region_set_flags(vm, PERF_TEST_MEM_SLOT_INDEX,
>  				KVM_MEM_LOG_DIRTY_PAGES);
>  	ts_diff = timespec_elapsed(start);
> @@ -174,7 +174,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>  		 * Incrementing the iteration number will start the vCPUs
>  		 * dirtying memory again.
>  		 */
> -		clock_gettime(CLOCK_MONOTONIC, &start);
> +		clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  		iteration++;
>  
>  		pr_debug("Starting iteration %d\n", iteration);
> @@ -189,7 +189,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>  		pr_info("Iteration %d dirty memory time: %ld.%.9lds\n",
>  			iteration, ts_diff.tv_sec, ts_diff.tv_nsec);
>  
> -		clock_gettime(CLOCK_MONOTONIC, &start);
> +		clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  		kvm_vm_get_dirty_log(vm, PERF_TEST_MEM_SLOT_INDEX, bmap);
>  
>  		ts_diff = timespec_elapsed(start);
> @@ -199,7 +199,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>  			iteration, ts_diff.tv_sec, ts_diff.tv_nsec);
>  
>  		if (dirty_log_manual_caps) {
> -			clock_gettime(CLOCK_MONOTONIC, &start);
> +			clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  			kvm_vm_clear_dirty_log(vm, PERF_TEST_MEM_SLOT_INDEX, bmap, 0,
>  					       host_num_pages);
>  
> @@ -212,7 +212,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
>  	}
>  
>  	/* Disable dirty logging */
> -	clock_gettime(CLOCK_MONOTONIC, &start);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &start);
>  	vm_mem_region_set_flags(vm, PERF_TEST_MEM_SLOT_INDEX, 0);
>  	ts_diff = timespec_elapsed(start);
>  	pr_info("Disabling dirty logging time: %ld.%.9lds\n",
> diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c
> index 906c955384e2..c7c0627c6842 100644
> --- a/tools/testing/selftests/kvm/lib/test_util.c
> +++ b/tools/testing/selftests/kvm/lib/test_util.c
> @@ -89,7 +89,7 @@ struct timespec timespec_elapsed(struct timespec start)
>  {
>  	struct timespec end;
>  
> -	clock_gettime(CLOCK_MONOTONIC, &end);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &end);
>  	return timespec_sub(end, start);
>  }
>  
> diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
> index fcc840088c91..5bc582d3f2a2 100644
> --- a/tools/testing/selftests/kvm/steal_time.c
> +++ b/tools/testing/selftests/kvm/steal_time.c
> @@ -237,11 +237,11 @@ static void *do_steal_time(void *arg)
>  {
>  	struct timespec ts, stop;
>  
> -	clock_gettime(CLOCK_MONOTONIC, &ts);
> +	clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
>  	stop = timespec_add_ns(ts, MIN_RUN_DELAY_NS);
>  
>  	while (1) {
> -		clock_gettime(CLOCK_MONOTONIC, &ts);
> +		clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
>  		if (timespec_to_ns(timespec_sub(ts, stop)) >= 0)
>  			break;
>  	}
> -- 
> 2.19.1
> 


  reply	other threads:[~2021-02-25 18:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25  5:59 [RFC PATCH v2 0/7] Some improvement and a new test for kvm page table Yanan Wang
2021-02-25  5:59 ` [RFC PATCH v2 1/7] tools include: sync head files of mmap flag encodings about hugetlb Yanan Wang
2021-02-25  5:59 ` [RFC PATCH v2 2/7] KVM: selftests: Use flag CLOCK_MONOTONIC_RAW for timing Yanan Wang
2021-02-25 18:54   ` Andrew Jones [this message]
2021-02-26  2:49     ` wangyanan (Y)
2021-02-25  5:59 ` [RFC PATCH v2 3/7] KVM: selftests: Make a generic helper to get vm guest mode strings Yanan Wang
2021-02-25 18:55   ` Andrew Jones
2021-02-26  5:56   ` wangyanan (Y)
2021-02-25  5:59 ` [RFC PATCH v2 4/7] KVM: selftests: Add a helper to get system configured THP page size Yanan Wang
2021-02-25 23:27   ` Ben Gardon
2021-02-25  5:59 ` [RFC PATCH v2 5/7] KVM: selftests: List all hugetlb src types specified with page sizes Yanan Wang
2021-02-25 23:42   ` Ben Gardon
2021-02-26  5:45     ` wangyanan (Y)
2021-02-25  5:59 ` [RFC PATCH v2 6/7] KVM: selftests: Adapt vm_userspace_mem_region_add to new helpers Yanan Wang
2021-02-25 23:44   ` Ben Gardon
2021-02-26  5:48     ` wangyanan (Y)
2021-02-25  5:59 ` [RFC PATCH v2 7/7] KVM: selftests: Add a test for kvm page table code Yanan Wang
2021-02-25 23:45 ` [RFC PATCH v2 0/7] Some improvement and a new test for kvm page table Ben Gardon

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=20210225185430.fgafepkqo42u2yci@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=acme@redhat.com \
    --cc=bgardon@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mingo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.