From 7d495864b89cd3a65aac555f42de044c592ad21b Mon Sep 17 00:00:00 2001 Message-Id: <7d495864b89cd3a65aac555f42de044c592ad21b@dist-git> From: Jiri Denemark Date: Tue, 4 Jun 2019 13:04:32 +0200 Subject: [PATCH] cpu_x86: Probe TSC frequency and scaling support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit ceb04d15e671b4fea1d674ee43c91410da9fe57d) https://bugzilla.redhat.com/show_bug.cgi?id=1641702 Signed-off-by: Jiri Denemark Message-Id: Reviewed-by: Ján Tomko --- src/cpu/cpu_x86.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index bd10862f57..e06e452aee 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2587,6 +2587,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; -- 2.21.0