Skip to contentSkip to conversation

KVM: selftests: Fix nsec to sec conversion in demand_paging_test.

PATCH In review Anish Moorthy 2 participants 2 messages Feb 23, 2023 – Mar 24, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 KVM: selftests: Fix nsec to sec conversion in demand_paging_test.

demand_paging_test uses 1E8 as the denominator to convert nanoseconds to seconds, which is wrong. Use NSEC_PER_SEC instead to fix the issue and make the conversion obvious.

---

v3:
- Add version number to patch
- Correct "KVM: selftests" tag in shortlog

v2: https://lore.kernel.org/all/[email protected]/
- Change to Oliver's log message

v1: https://lore.kernel.org/all/[email protected]/

 tools/testing/selftests/kvm/demand_paging_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/demand_paging_test.c +1 -1
index b0e1fc4de9e29..2439c4043fed6 100644
@@ -194,7 +194,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
 		ts_diff.tv_sec, ts_diff.tv_nsec);
 	pr_info("Overall demand paging rate: %f pgs/sec\n",
 		memstress_args.vcpu_args[0].pages * nr_vcpus /
-		((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / 100000000.0));
+		((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / NSEC_PER_SEC));
 
 	memstress_destroy_vm(vm);
 
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#1 lore raw
Quoted 5 lines · Anish Moorthy

demand_paging_test uses 1E8 as the denominator to convert nanoseconds to seconds, which is wrong. Use NSEC_PER_SEC instead to fix the issue and make the conversion obvious.

Applied to kvm-x86 selftests, thanks!

[1/1] KVM: selftests: Fix nsec to sec conversion in demand_paging_test.
https://github.com/kvm-x86/linux/commit/f6baabdcadd1

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes