Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp888713pxb; Thu, 25 Feb 2021 18:52:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2Wmpz/zqNr4ZPjgooiCvmK/pgz+Q979+bGlmRZKyYYvcOd5+W2aebrVby2XQgXsBMwqjY X-Received: by 2002:a17:907:76d6:: with SMTP id kf22mr813398ejc.495.1614307975822; Thu, 25 Feb 2021 18:52:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614307975; cv=none; d=google.com; s=arc-20160816; b=v5maDEP+eUW3uUZ288m9gd4t3rNAp7kR2AVSgJl4Hs6cjna9jdaD640y86gAEJxL4M pVY4i15D1t5/v8eAlG5JyaJuooNVvdi59w042mLMQclJ4abZD0OoDcursKu+/FjBqPH3 dakVT/Oiz9QL1S7IPSgA7F3PGEt9a6+iX/D7nWbjQ+T4odVRBUJliWDzQ3Jlo8TqC4zE CGWpMriyQqLkGaMzNF3sL8NzeCpuyJ2EPXvLiw95t1TxUb+FWMQ3zy/9pdyANGQSP3Ie qhK42yUp11cksqff5HC8o4Is5CJXM3fSPUJvAQc2iDUfS9LRb5E+FZIuoGYz+oE5Jt2L m9lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=uBzIy+VSWU4oYFCwP8ehZGmAfvYaVraU+VY2A1G7sw8=; b=0s1+L0bJlH/k3d0RI8tBQ3TG9ofYUbG/yIRg1C/FBY/+XUroAZ0EuGrP+cAiQxnOBW HC/6hoMNCyQtAeEra90J7+LRWBgUa45B8gGES/2IUHDzEEIuh/NCBcSpXdS7VMxq737x nd+11y6PajZDNqPwqpf0z3zodZIEnHUJg8MNgSLoiAnw/a1Qua4JfBcfZCifmpzXUiDT HWcARwi7ymrdX+p5j1NR5MkhjEMdswxXG/E9zeLlPL6a90MuVFQVDlYEUfodNaZcRO/m s+qJCHnV/LT0ED5FcVuqKKhW+YYD2I0W27KC/XRBwFrahxeT5c2XOBLyFK3Gy3NEjg0W TJ9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a70si5076831edf.383.2021.02.25.18.52.33; Thu, 25 Feb 2021 18:52:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbhBZCuE (ORCPT + 99 others); Thu, 25 Feb 2021 21:50:04 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:2589 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbhBZCuB (ORCPT ); Thu, 25 Feb 2021 21:50:01 -0500 Received: from dggeme710-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4DmvDw2zpfzWDpK; Fri, 26 Feb 2021 10:46:40 +0800 (CST) Received: from [10.174.187.128] (10.174.187.128) by dggeme710-chm.china.huawei.com (10.1.199.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Fri, 26 Feb 2021 10:49:16 +0800 Subject: Re: [RFC PATCH v2 2/7] KVM: selftests: Use flag CLOCK_MONOTONIC_RAW for timing To: Andrew Jones CC: , , , Paolo Bonzini , Ben Gardon , Sean Christopherson , Vitaly Kuznetsov , Arnaldo Carvalho de Melo , Ingo Molnar , Peter Xu , Marc Zyngier , , References: <20210225055940.18748-1-wangyanan55@huawei.com> <20210225055940.18748-3-wangyanan55@huawei.com> <20210225185430.fgafepkqo42u2yci@kamzik.brq.redhat.com> From: "wangyanan (Y)" Message-ID: Date: Fri, 26 Feb 2021 10:49:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20210225185430.fgafepkqo42u2yci@kamzik.brq.redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.187.128] X-ClientProxiedBy: dggeme702-chm.china.huawei.com (10.1.199.98) To dggeme710-chm.china.huawei.com (10.1.199.106) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/26 2:54, Andrew Jones wrote: > 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 Oh, sorry for my rashness. I will include it in v3. Thanks, Yanan >> Signed-off-by: Yanan Wang >> --- >> 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, ©); >> 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 >> > .