]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu_x86: Probe TSC frequency and scaling support
authorJiri Denemark <jdenemar@redhat.com>
Thu, 30 May 2019 19:47:38 +0000 (21:47 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 3 Jun 2019 16:07:16 +0000 (18:07 +0200)
When the host CPU supports invariant TSC the host CPU definition created
by virCPUx86GetHost will contain (unless probing fails for some reason)
addition TSC related data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/cpu/cpu_x86.c

index cb03123787e6d513370fe5a2d9a1f6392b0612fb..689b6cdaf56c91d650191433606ae1aefef6c43b 100644 (file)
@@ -2762,6 +2762,15 @@ virCPUx86GetHost(virCPUDefPtr cpu,
     ret = x86DecodeCPUData(cpu, cpuData, models);
     cpu->microcodeVersion = virHostCPUGetMicrocodeVersion();
 
+    /* Probing for TSC frequency makes sense only if the CPU supports
+     * invariant TSC (Linux calls this constant_tsc in /proc/cpuinfo). */
+    if (virCPUx86DataCheckFeature(cpuData, "invtsc") == 1) {
+        VIR_DEBUG("Checking invariant TSC frequency");
+        cpu->tsc = virHostCPUGetTscInfo();
+    } else {
+        VIR_DEBUG("Host CPU does not support invariant TSC");
+    }
+
  cleanup:
     virCPUx86DataFree(cpuData);
     return ret;