Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: Convert iterations to int in dirty_log_perf_test

In order to add an iteration -1 to indicate that the memory population
phase has not yet completed, convert the interations counters to ints.

No functional change intended.

Reviewed-by: Jacob Xu <jacobhxu@google.com>

Signed-off-by: Ben Gardon <bgardon@google.com>
Message-Id: <20210112214253.463999-4-bgardon@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Ben Gardon and committed by
Paolo Bonzini
2d501238 89dc5294

+13 -13
+13 -13
tools/testing/selftests/kvm/dirty_log_perf_test.c
··· 28 28 /* Host variables */ 29 29 static u64 dirty_log_manual_caps; 30 30 static bool host_quit; 31 - static uint64_t iteration; 32 - static uint64_t vcpu_last_completed_iteration[KVM_MAX_VCPUS]; 31 + static int iteration; 32 + static int vcpu_last_completed_iteration[KVM_MAX_VCPUS]; 33 33 34 34 static void *vcpu_worker(void *data) 35 35 { ··· 48 48 run = vcpu_state(vm, vcpu_id); 49 49 50 50 while (!READ_ONCE(host_quit)) { 51 - uint64_t current_iteration = READ_ONCE(iteration); 51 + int current_iteration = READ_ONCE(iteration); 52 52 53 53 clock_gettime(CLOCK_MONOTONIC, &start); 54 54 ret = _vcpu_run(vm, vcpu_id); ··· 61 61 62 62 pr_debug("Got sync event from vCPU %d\n", vcpu_id); 63 63 vcpu_last_completed_iteration[vcpu_id] = current_iteration; 64 - pr_debug("vCPU %d updated last completed iteration to %lu\n", 64 + pr_debug("vCPU %d updated last completed iteration to %d\n", 65 65 vcpu_id, vcpu_last_completed_iteration[vcpu_id]); 66 66 67 67 if (current_iteration) { 68 68 pages_count += vcpu_args->pages; 69 69 total = timespec_add(total, ts_diff); 70 - pr_debug("vCPU %d iteration %lu dirty memory time: %ld.%.9lds\n", 70 + pr_debug("vCPU %d iteration %d dirty memory time: %ld.%.9lds\n", 71 71 vcpu_id, current_iteration, ts_diff.tv_sec, 72 72 ts_diff.tv_nsec); 73 73 } else { 74 - pr_debug("vCPU %d iteration %lu populate memory time: %ld.%.9lds\n", 74 + pr_debug("vCPU %d iteration %d populate memory time: %ld.%.9lds\n", 75 75 vcpu_id, current_iteration, ts_diff.tv_sec, 76 76 ts_diff.tv_nsec); 77 77 } ··· 81 81 } 82 82 83 83 avg = timespec_div(total, vcpu_last_completed_iteration[vcpu_id]); 84 - pr_debug("\nvCPU %d dirtied 0x%lx pages over %lu iterations in %ld.%.9lds. (Avg %ld.%.9lds/iteration)\n", 84 + pr_debug("\nvCPU %d dirtied 0x%lx pages over %d iterations in %ld.%.9lds. (Avg %ld.%.9lds/iteration)\n", 85 85 vcpu_id, pages_count, vcpu_last_completed_iteration[vcpu_id], 86 86 total.tv_sec, total.tv_nsec, avg.tv_sec, avg.tv_nsec); 87 87 ··· 144 144 } 145 145 146 146 /* Allow the vCPU to populate memory */ 147 - pr_debug("Starting iteration %lu - Populating\n", iteration); 147 + pr_debug("Starting iteration %d - Populating\n", iteration); 148 148 while (READ_ONCE(vcpu_last_completed_iteration[vcpu_id]) != iteration) 149 149 ; 150 150 ··· 168 168 clock_gettime(CLOCK_MONOTONIC, &start); 169 169 iteration++; 170 170 171 - pr_debug("Starting iteration %lu\n", iteration); 171 + pr_debug("Starting iteration %d\n", iteration); 172 172 for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) { 173 173 while (READ_ONCE(vcpu_last_completed_iteration[vcpu_id]) 174 174 != iteration) ··· 177 177 178 178 ts_diff = timespec_elapsed(start); 179 179 vcpu_dirty_total = timespec_add(vcpu_dirty_total, ts_diff); 180 - pr_info("Iteration %lu dirty memory time: %ld.%.9lds\n", 180 + pr_info("Iteration %d dirty memory time: %ld.%.9lds\n", 181 181 iteration, ts_diff.tv_sec, ts_diff.tv_nsec); 182 182 183 183 clock_gettime(CLOCK_MONOTONIC, &start); ··· 186 186 ts_diff = timespec_elapsed(start); 187 187 get_dirty_log_total = timespec_add(get_dirty_log_total, 188 188 ts_diff); 189 - pr_info("Iteration %lu get dirty log time: %ld.%.9lds\n", 189 + pr_info("Iteration %d get dirty log time: %ld.%.9lds\n", 190 190 iteration, ts_diff.tv_sec, ts_diff.tv_nsec); 191 191 192 192 if (dirty_log_manual_caps) { ··· 197 197 ts_diff = timespec_elapsed(start); 198 198 clear_dirty_log_total = timespec_add(clear_dirty_log_total, 199 199 ts_diff); 200 - pr_info("Iteration %lu clear dirty log time: %ld.%.9lds\n", 200 + pr_info("Iteration %d clear dirty log time: %ld.%.9lds\n", 201 201 iteration, ts_diff.tv_sec, ts_diff.tv_nsec); 202 202 } 203 203 } ··· 273 273 while ((opt = getopt(argc, argv, "hi:p:m:b:f:v:")) != -1) { 274 274 switch (opt) { 275 275 case 'i': 276 - p.iterations = strtol(optarg, NULL, 10); 276 + p.iterations = atoi(optarg); 277 277 break; 278 278 case 'p': 279 279 p.phys_offset = strtoull(optarg, NULL, 0);