Skip to contentSkip to conversation

selftests/kvm: Fix bug in how demand_paging_test calculates paging rate

PATCH In review Anish Moorthy 3 participants 5 messages Feb 16, 2023

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

PATCH 1/1 selftests/kvm: Fix bug in how demand_paging_test calculates paging rate

The current denominator is 1E8, not 1E9 as it should be.

---
 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
Reviewed-by on v1 1/1
#1 lore raw

The shortlog doesn't give any hint as to what the bug actually is. Maybe:

KVM: selftests: Fix nsec to sec conversion in demand_paging_test

Quoted 1 line · Anish Moorthy

The current denominator is 1E8, not 1E9 as it should be.

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.

Quoted 2 lines

Bikeshedding aside:

Quoted 20 lines
---
 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
Signature · 2 lines
Thanks,
Oliver
reviewer Reviewed-by
#2 lore raw
Quoted 4 lines · Oliver Upton

The shortlog doesn't give any hint as to what the bug actually is. Maybe:

KVM: selftests: Fix nsec to sec conversion in demand_paging_test

+1

Quoted 7 lines · Anish Moorthy
Quoted 1 line

The current denominator is 1E8, not 1E9 as it should be.

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.

Quoted 6 lines
Quoted 2 lines

Bikeshedding aside:

With Oliver's shortlog (I'm indifferent on the changelog),

#3 lore raw

PATCH 1/1 selftests/kvm: 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.

---
 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
#4 lore raw

Re: [PATCH] selftests/kvm: Fix nsec to sec conversion in demand_paging_test.

"KVM: selftests:" please.

And when sending a new version, bump the version number, i.e. the subject should read "[PATCH v2] ..."

Quoted 9 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.

---