Commit f9224a52 authored by Ben Gardon's avatar Ben Gardon Committed by Paolo Bonzini

KVM: selftests: Rename timespec_diff_now to timespec_elapsed

In response to some earlier comments from Peter Xu, rename
timespec_diff_now to the much more sensible timespec_elapsed.

No functional change intended.
Reviewed-by: default avatarJacob Xu <jacobhxu@google.com>
Reviewed-by: default avatarMakarand Sonare <makarandsonare@google.com>
Signed-off-by: default avatarBen Gardon <bgardon@google.com>
Message-Id: <20210112214253.463999-2-bgardon@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent c5e2184d
...@@ -64,7 +64,7 @@ static void *vcpu_worker(void *data) ...@@ -64,7 +64,7 @@ static void *vcpu_worker(void *data)
exit_reason_str(run->exit_reason)); exit_reason_str(run->exit_reason));
} }
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
PER_VCPU_DEBUG("vCPU %d execution time: %ld.%.9lds\n", vcpu_id, PER_VCPU_DEBUG("vCPU %d execution time: %ld.%.9lds\n", vcpu_id,
ts_diff.tv_sec, ts_diff.tv_nsec); ts_diff.tv_sec, ts_diff.tv_nsec);
...@@ -95,7 +95,7 @@ static int handle_uffd_page_request(int uffd, uint64_t addr) ...@@ -95,7 +95,7 @@ static int handle_uffd_page_request(int uffd, uint64_t addr)
return r; return r;
} }
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
PER_PAGE_DEBUG("UFFDIO_COPY %d \t%ld ns\n", tid, PER_PAGE_DEBUG("UFFDIO_COPY %d \t%ld ns\n", tid,
timespec_to_ns(ts_diff)); timespec_to_ns(ts_diff));
...@@ -190,7 +190,7 @@ static void *uffd_handler_thread_fn(void *arg) ...@@ -190,7 +190,7 @@ static void *uffd_handler_thread_fn(void *arg)
pages++; pages++;
} }
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
PER_VCPU_DEBUG("userfaulted %ld pages over %ld.%.9lds. (%f/sec)\n", PER_VCPU_DEBUG("userfaulted %ld pages over %ld.%.9lds. (%f/sec)\n",
pages, ts_diff.tv_sec, ts_diff.tv_nsec, pages, ts_diff.tv_sec, ts_diff.tv_nsec,
pages / ((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / 100000000.0)); pages / ((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / 100000000.0));
...@@ -339,7 +339,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) ...@@ -339,7 +339,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
PER_VCPU_DEBUG("Joined thread for vCPU %d\n", vcpu_id); PER_VCPU_DEBUG("Joined thread for vCPU %d\n", vcpu_id);
} }
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
pr_info("All vCPU threads joined\n"); pr_info("All vCPU threads joined\n");
......
...@@ -52,7 +52,7 @@ static void *vcpu_worker(void *data) ...@@ -52,7 +52,7 @@ static void *vcpu_worker(void *data)
clock_gettime(CLOCK_MONOTONIC, &start); clock_gettime(CLOCK_MONOTONIC, &start);
ret = _vcpu_run(vm, vcpu_id); ret = _vcpu_run(vm, vcpu_id);
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret); TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret);
TEST_ASSERT(get_ucall(vm, vcpu_id, NULL) == UCALL_SYNC, TEST_ASSERT(get_ucall(vm, vcpu_id, NULL) == UCALL_SYNC,
...@@ -149,7 +149,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) ...@@ -149,7 +149,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
pr_debug("Waiting for vcpu_last_completed_iteration == %lu\n", pr_debug("Waiting for vcpu_last_completed_iteration == %lu\n",
iteration); iteration);
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
pr_info("Populate memory time: %ld.%.9lds\n", pr_info("Populate memory time: %ld.%.9lds\n",
ts_diff.tv_sec, ts_diff.tv_nsec); ts_diff.tv_sec, ts_diff.tv_nsec);
...@@ -157,7 +157,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) ...@@ -157,7 +157,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
clock_gettime(CLOCK_MONOTONIC, &start); clock_gettime(CLOCK_MONOTONIC, &start);
vm_mem_region_set_flags(vm, PERF_TEST_MEM_SLOT_INDEX, vm_mem_region_set_flags(vm, PERF_TEST_MEM_SLOT_INDEX,
KVM_MEM_LOG_DIRTY_PAGES); KVM_MEM_LOG_DIRTY_PAGES);
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
pr_info("Enabling dirty logging time: %ld.%.9lds\n\n", pr_info("Enabling dirty logging time: %ld.%.9lds\n\n",
ts_diff.tv_sec, ts_diff.tv_nsec); ts_diff.tv_sec, ts_diff.tv_nsec);
...@@ -176,7 +176,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) ...@@ -176,7 +176,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
vcpu_id, iteration); vcpu_id, iteration);
} }
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
vcpu_dirty_total = timespec_add(vcpu_dirty_total, ts_diff); vcpu_dirty_total = timespec_add(vcpu_dirty_total, ts_diff);
pr_info("Iteration %lu dirty memory time: %ld.%.9lds\n", pr_info("Iteration %lu dirty memory time: %ld.%.9lds\n",
iteration, ts_diff.tv_sec, ts_diff.tv_nsec); iteration, ts_diff.tv_sec, ts_diff.tv_nsec);
...@@ -184,7 +184,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) ...@@ -184,7 +184,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
clock_gettime(CLOCK_MONOTONIC, &start); clock_gettime(CLOCK_MONOTONIC, &start);
kvm_vm_get_dirty_log(vm, PERF_TEST_MEM_SLOT_INDEX, bmap); kvm_vm_get_dirty_log(vm, PERF_TEST_MEM_SLOT_INDEX, bmap);
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
get_dirty_log_total = timespec_add(get_dirty_log_total, get_dirty_log_total = timespec_add(get_dirty_log_total,
ts_diff); ts_diff);
pr_info("Iteration %lu get dirty log time: %ld.%.9lds\n", pr_info("Iteration %lu get dirty log time: %ld.%.9lds\n",
...@@ -195,7 +195,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) ...@@ -195,7 +195,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
kvm_vm_clear_dirty_log(vm, PERF_TEST_MEM_SLOT_INDEX, bmap, 0, kvm_vm_clear_dirty_log(vm, PERF_TEST_MEM_SLOT_INDEX, bmap, 0,
host_num_pages); host_num_pages);
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
clear_dirty_log_total = timespec_add(clear_dirty_log_total, clear_dirty_log_total = timespec_add(clear_dirty_log_total,
ts_diff); ts_diff);
pr_info("Iteration %lu clear dirty log time: %ld.%.9lds\n", pr_info("Iteration %lu clear dirty log time: %ld.%.9lds\n",
...@@ -211,7 +211,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) ...@@ -211,7 +211,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
/* Disable dirty logging */ /* Disable dirty logging */
clock_gettime(CLOCK_MONOTONIC, &start); clock_gettime(CLOCK_MONOTONIC, &start);
vm_mem_region_set_flags(vm, PERF_TEST_MEM_SLOT_INDEX, 0); vm_mem_region_set_flags(vm, PERF_TEST_MEM_SLOT_INDEX, 0);
ts_diff = timespec_diff_now(start); ts_diff = timespec_elapsed(start);
pr_info("Disabling dirty logging time: %ld.%.9lds\n", pr_info("Disabling dirty logging time: %ld.%.9lds\n",
ts_diff.tv_sec, ts_diff.tv_nsec); ts_diff.tv_sec, ts_diff.tv_nsec);
......
...@@ -64,7 +64,7 @@ int64_t timespec_to_ns(struct timespec ts); ...@@ -64,7 +64,7 @@ int64_t timespec_to_ns(struct timespec ts);
struct timespec timespec_add_ns(struct timespec ts, int64_t ns); struct timespec timespec_add_ns(struct timespec ts, int64_t ns);
struct timespec timespec_add(struct timespec ts1, struct timespec ts2); struct timespec timespec_add(struct timespec ts1, struct timespec ts2);
struct timespec timespec_sub(struct timespec ts1, struct timespec ts2); struct timespec timespec_sub(struct timespec ts1, struct timespec ts2);
struct timespec timespec_diff_now(struct timespec start); struct timespec timespec_elapsed(struct timespec start);
struct timespec timespec_div(struct timespec ts, int divisor); struct timespec timespec_div(struct timespec ts, int divisor);
#endif /* SELFTEST_KVM_TEST_UTIL_H */ #endif /* SELFTEST_KVM_TEST_UTIL_H */
...@@ -84,7 +84,7 @@ struct timespec timespec_sub(struct timespec ts1, struct timespec ts2) ...@@ -84,7 +84,7 @@ struct timespec timespec_sub(struct timespec ts1, struct timespec ts2)
return timespec_add_ns((struct timespec){0}, ns1 - ns2); return timespec_add_ns((struct timespec){0}, ns1 - ns2);
} }
struct timespec timespec_diff_now(struct timespec start) struct timespec timespec_elapsed(struct timespec start)
{ {
struct timespec end; struct timespec end;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment