render / rpms / libvirt

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