[PATCH 04/10] x86: tsc_adjust: use report

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 x86/tsc_adjust.c | 44 +++++++++++++-------------------------------
 1 file changed, 13 insertions(+), 31 deletions(-)

diff --git a/x86/tsc_adjust.c b/x86/tsc_adjust.c
index 0e9679235eafe..725e4ff75b4ba 100644
--- a/x86/tsc_adjust.c
+++ b/x86/tsc_adjust.c
@@ -7,35 +7,22 @@ int main()
 {
 	u64 t1, t2, t3, t4, t5;
 	u64 est_delta_time;
-	bool pass = true;
 
 	if (cpuid(7).b & (1 << 1)) { // IA32_TSC_ADJUST Feature is enabled?
-		if ( rdmsr(IA32_TSC_ADJUST) != 0x0) {
-			printf("failure: IA32_TSC_ADJUST msr was incorrectly"
-				" initialized\n");
-			pass = false;
-		}
+		report("IA32_TSC_ADJUST msr initialization",
+				rdmsr(IA32_TSC_ADJUST) == 0x0);
 		t3 = 100000000000ull;
 		t1 = rdtsc();
 		wrmsr(IA32_TSC_ADJUST, t3);
 		t2 = rdtsc();
-		if (rdmsr(IA32_TSC_ADJUST) != t3) {
-			printf("failure: IA32_TSC_ADJUST msr read / write"
-				" incorrect\n");
-			pass = false;
-		}
-		if (t2 - t1 < t3) {
-			printf("failure: TSC did not adjust for IA32_TSC_ADJUST"
-				" value\n");
-			pass = false;
-		}
+		report("IA32_TSC_ADJUST msr read / write",
+				rdmsr(IA32_TSC_ADJUST) == t3);
+		report("TSC adjustment for IA32_TSC_ADJUST value",
+				(t2 - t1) >= t3);
 		t3 = 0x0;
 		wrmsr(IA32_TSC_ADJUST, t3);
-		if (rdmsr(IA32_TSC_ADJUST) != t3) {
-			printf("failure: IA32_TSC_ADJUST msr read / write"
-				" incorrect\n");
-			pass = false;
-		}
+		report("IA32_TSC_ADJUST msr read / write",
+				rdmsr(IA32_TSC_ADJUST) == t3);
 		t4 = 100000000000ull;
 		t1 = rdtsc();
 		wrtsc(t4);
@@ -44,17 +31,12 @@ int main()
 		// est of time between reading tsc and writing tsc,
 		// (based on IA32_TSC_ADJUST msr value) should be small
 		est_delta_time = t4 - t5 - t1;
-		if (est_delta_time > 2 * (t2 - t4)) {
-			// arbitray 2x latency (wrtsc->rdtsc) threshold
-			printf("failure: IA32_TSC_ADJUST msr incorrectly"
-				" adjusted on tsc write\n");
-			pass = false;
-		}
-		if (pass) printf("success: IA32_TSC_ADJUST enabled and"
-				" working correctly\n");
+		// arbitray 2x latency (wrtsc->rdtsc) threshold
+		report("IA32_TSC_ADJUST msr adjustment on tsc write",
+				est_delta_time <= (2 * (t2 - t4)));
 	}
 	else {
-		printf("success: IA32_TSC_ADJUST feature not enabled\n");
+		report("IA32_TSC_ADJUST feature not enabled", true);
 	}
-	return pass?0:1;
+	return report_summary();
 }
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux