0a7476
From 7d495864b89cd3a65aac555f42de044c592ad21b Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <7d495864b89cd3a65aac555f42de044c592ad21b@dist-git>
0a7476
From: Jiri Denemark <jdenemar@redhat.com>
0a7476
Date: Tue, 4 Jun 2019 13:04:32 +0200
0a7476
Subject: [PATCH] cpu_x86: Probe TSC frequency and scaling support
0a7476
MIME-Version: 1.0
0a7476
Content-Type: text/plain; charset=UTF-8
0a7476
Content-Transfer-Encoding: 8bit
0a7476
0a7476
When the host CPU supports invariant TSC the host CPU definition created
0a7476
by virCPUx86GetHost will contain (unless probing fails for some reason)
0a7476
addition TSC related data.
0a7476
0a7476
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
(cherry picked from commit ceb04d15e671b4fea1d674ee43c91410da9fe57d)
0a7476
0a7476
https://bugzilla.redhat.com/show_bug.cgi?id=1641702
0a7476
0a7476
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
Message-Id: <a738a180a4b3771d57ed46449aa305f4e914a98d.1559646067.git.jdenemar@redhat.com>
0a7476
Reviewed-by: Ján Tomko <jtomko@redhat.com>
0a7476
---
0a7476
 src/cpu/cpu_x86.c | 9 +++++++++
0a7476
 1 file changed, 9 insertions(+)
0a7476
0a7476
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
0a7476
index bd10862f57..e06e452aee 100644
0a7476
--- a/src/cpu/cpu_x86.c
0a7476
+++ b/src/cpu/cpu_x86.c
0a7476
@@ -2587,6 +2587,15 @@ virCPUx86GetHost(virCPUDefPtr cpu,
0a7476
     ret = x86DecodeCPUData(cpu, cpuData, models);
0a7476
     cpu->microcodeVersion = virHostCPUGetMicrocodeVersion();
0a7476
 
0a7476
+    /* Probing for TSC frequency makes sense only if the CPU supports
0a7476
+     * invariant TSC (Linux calls this constant_tsc in /proc/cpuinfo). */
0a7476
+    if (virCPUx86DataCheckFeature(cpuData, "invtsc") == 1) {
0a7476
+        VIR_DEBUG("Checking invariant TSC frequency");
0a7476
+        cpu->tsc = virHostCPUGetTscInfo();
0a7476
+    } else {
0a7476
+        VIR_DEBUG("Host CPU does not support invariant TSC");
0a7476
+    }
0a7476
+
0a7476
  cleanup:
0a7476
     virCPUx86DataFree(cpuData);
0a7476
     return ret;
0a7476
-- 
0a7476
2.21.0
0a7476