[libvirt] [PATCH 4/5] cpu_x86: Probe TSC frequency and scaling support

Jiri Denemark posted 5 patches 6 years, 6 months ago
There is a newer version of this series
[libvirt] [PATCH 4/5] cpu_x86: Probe TSC frequency and scaling support
Posted by Jiri Denemark 6 years, 6 months ago
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 | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index cb03123787..689b6cdaf5 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -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;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/5] cpu_x86: Probe TSC frequency and scaling support
Posted by Ján Tomko 6 years, 6 months ago
On Fri, May 31, 2019 at 02:00:10PM +0200, Jiri Denemark wrote:
>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 | 9 +++++++++
> 1 file changed, 9 insertions(+)

This breaks the tests for me:
 1) QEMU ARGV-2-XML machine-core-on                                   ... Got unexpected warning from qemuParseCommandLineString:
2019-06-03 07:19:24.832+0000: 15141: info : libvirt version: 5.4.0
2019-06-03 07:19:24.832+0000: 15141: info : hostname: icr
2019-06-03 07:19:24.832+0000: 15141: error : virHostCPUGetTscInfo:1349 : Unable to open /dev/kvm: Permission denied
FAILED

Jano

>
>diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
>index cb03123787..689b6cdaf5 100644
>--- a/src/cpu/cpu_x86.c
>+++ b/src/cpu/cpu_x86.c
>@@ -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;
>-- 
>2.21.0
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/5] cpu_x86: Probe TSC frequency and scaling support
Posted by Jiri Denemark 6 years, 6 months ago
On Mon, Jun 03, 2019 at 09:24:14 +0200, Ján Tomko wrote:
> On Fri, May 31, 2019 at 02:00:10PM +0200, Jiri Denemark wrote:
> >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 | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> 
> This breaks the tests for me:
>  1) QEMU ARGV-2-XML machine-core-on                                   ... Got unexpected warning from qemuParseCommandLineString:
> 2019-06-03 07:19:24.832+0000: 15141: info : libvirt version: 5.4.0
> 2019-06-03 07:19:24.832+0000: 15141: info : hostname: icr
> 2019-06-03 07:19:24.832+0000: 15141: error : virHostCPUGetTscInfo:1349 : Unable to open /dev/kvm: Permission denied
> FAILED

Interesting. This shows an existing issue in qemuargv2xmltest which
would probe the host CPU directly. I'll fix this in v2.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list