qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set
@ 2017-01-08 17:32 Eduardo Habkost
  2017-01-08 17:32 ` [Qemu-devel] [PATCH v3 1/2] kvm: Simplify invtsc check Eduardo Habkost
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eduardo Habkost @ 2017-01-08 17:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marcelo Tosatti, Paolo Bonzini, kvm, Haozhong Zhang,
	Daniel P. Berrange, Michael S. Tsirkin, Igor Mammedov,
	libvir-list, Jiri Denemark

This series makes QEMU accept migration if tsc-frequency is
explicitly set on configuration. As management software is
required to keep device configuration the same on migration
source or destination, explicit tsc-frequency will ensure that
either:

* The destination host has a matching TSC frequency; or
* The destination host has TSC scaling available.

Changelog
=========

v2 -> v3:
* Fix build failure ((missing closing braces)

v1 -> v2:
* v1 series subject was:
  * [PATCH 0/4] Allow migration with invtsc if there's no
    frequency mismatch
* Removed patches 3/4 and 4/4, that allowed migration
  if no explicit tsc-frequency was set. Implementing the check on
  post_load or post_init is not enough to make migration abort,
  so we will need a more complex solution to implement that
  feature.

Plans for future work
=====================

1) Querying host TSC frequency/scaling capability
-------------------------------------------------

I plan to include TSC frequency/scaling information on
query-cpu-model-expansion model="host" in a future series. Then
management software will be able to automatically configure TSC
frequency when invtsc is enabled, instead of requiring the user
to configure it explicitly. While we don't implement that, invtsc
migration will be possible only if the user configures TSC
frequency manually.

2) invtsc migration with no explicit TSC frequency
--------------------------------------------------

A future series can implement migration when TSC frequency is not
specified explicitly. It will be a bit more complex because it
requires either letting the destination abort the migration, or
sending TSC frequency/scaling information from destination to
source.

---
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Haozhong Zhang <haozhong.zhang@intel.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: libvir-list@redhat.com
Cc: Jiri Denemark <jdenemar@redhat.com>

Eduardo Habkost (2):
  kvm: Simplify invtsc check
  kvm: Allow invtsc migration if tsc-khz is set explicitly

 target/i386/kvm.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

-- 
2.11.0.259.g40922b1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v3 1/2] kvm: Simplify invtsc check
  2017-01-08 17:32 [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set Eduardo Habkost
@ 2017-01-08 17:32 ` Eduardo Habkost
  2017-01-08 17:32 ` [Qemu-devel] [PATCH v3 2/2] kvm: Allow invtsc migration if tsc-khz is set explicitly Eduardo Habkost
  2017-01-18 12:11 ` [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Eduardo Habkost @ 2017-01-08 17:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, Paolo Bonzini, kvm, Haozhong Zhang

Instead of searching the table we have just built, we can check
the env->features field directly.

Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 10a9cd8f7f..a26290fdc1 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -962,8 +962,8 @@ int kvm_arch_init_vcpu(CPUState *cs)
         has_msr_mcg_ext_ctl = has_msr_feature_control = true;
     }
 
-    c = cpuid_find_entry(&cpuid_data.cpuid, 0x80000007, 0);
-    if (c && (c->edx & 1<<8) && invtsc_mig_blocker == NULL) {
+    if ((env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC) &&
+        invtsc_mig_blocker == NULL) {
         /* for migration */
         error_setg(&invtsc_mig_blocker,
                    "State blocked by non-migratable CPU device"
-- 
2.11.0.259.g40922b1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v3 2/2] kvm: Allow invtsc migration if tsc-khz is set explicitly
  2017-01-08 17:32 [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set Eduardo Habkost
  2017-01-08 17:32 ` [Qemu-devel] [PATCH v3 1/2] kvm: Simplify invtsc check Eduardo Habkost
@ 2017-01-08 17:32 ` Eduardo Habkost
  2017-01-18 12:11 ` [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Eduardo Habkost @ 2017-01-08 17:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, Paolo Bonzini, kvm, Haozhong Zhang

We can safely allow a VM to be migrated with invtsc enabled if
tsc-khz is set explicitly, because:
* QEMU already refuses to start if it can't set the TSC frequency
  to the configured value.
* Management software is already required to keep device
  configuration (including CPU configuration) the same on
  migration source and destination.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
* Reworded commit message

Changes v2 -> v3:
* Fixed build failure
---
 target/i386/kvm.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index a26290fdc1..abb5a41983 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -962,15 +962,17 @@ int kvm_arch_init_vcpu(CPUState *cs)
         has_msr_mcg_ext_ctl = has_msr_feature_control = true;
     }
 
-    if ((env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC) &&
-        invtsc_mig_blocker == NULL) {
-        /* for migration */
-        error_setg(&invtsc_mig_blocker,
-                   "State blocked by non-migratable CPU device"
-                   " (invtsc flag)");
-        migrate_add_blocker(invtsc_mig_blocker);
-        /* for savevm */
-        vmstate_x86_cpu.unmigratable = 1;
+    if (!env->user_tsc_khz) {
+        if ((env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC) &&
+            invtsc_mig_blocker == NULL) {
+            /* for migration */
+            error_setg(&invtsc_mig_blocker,
+                       "State blocked by non-migratable CPU device"
+                       " (invtsc flag)");
+            migrate_add_blocker(invtsc_mig_blocker);
+            /* for savevm */
+            vmstate_x86_cpu.unmigratable = 1;
+        }
     }
 
     cpuid_data.cpuid.padding = 0;
-- 
2.11.0.259.g40922b1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set
  2017-01-08 17:32 [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set Eduardo Habkost
  2017-01-08 17:32 ` [Qemu-devel] [PATCH v3 1/2] kvm: Simplify invtsc check Eduardo Habkost
  2017-01-08 17:32 ` [Qemu-devel] [PATCH v3 2/2] kvm: Allow invtsc migration if tsc-khz is set explicitly Eduardo Habkost
@ 2017-01-18 12:11 ` Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2017-01-18 12:11 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Paolo Bonzini, kvm, Haozhong Zhang,
	Daniel P. Berrange, Michael S. Tsirkin, Igor Mammedov,
	libvir-list, Jiri Denemark

On Sun, Jan 08, 2017 at 03:32:32PM -0200, Eduardo Habkost wrote:
> This series makes QEMU accept migration if tsc-frequency is
> explicitly set on configuration. As management software is
> required to keep device configuration the same on migration
> source or destination, explicit tsc-frequency will ensure that
> either:
> 
> * The destination host has a matching TSC frequency; or
> * The destination host has TSC scaling available.
> 
> Changelog
> =========
> 
> v2 -> v3:
> * Fix build failure ((missing closing braces)
> 
> v1 -> v2:
> * v1 series subject was:
>   * [PATCH 0/4] Allow migration with invtsc if there's no
>     frequency mismatch
> * Removed patches 3/4 and 4/4, that allowed migration
>   if no explicit tsc-frequency was set. Implementing the check on
>   post_load or post_init is not enough to make migration abort,
>   so we will need a more complex solution to implement that
>   feature.
> 
> Plans for future work
> =====================
> 
> 1) Querying host TSC frequency/scaling capability
> -------------------------------------------------
> 
> I plan to include TSC frequency/scaling information on
> query-cpu-model-expansion model="host" in a future series. Then
> management software will be able to automatically configure TSC
> frequency when invtsc is enabled, instead of requiring the user
> to configure it explicitly. While we don't implement that, invtsc
> migration will be possible only if the user configures TSC
> frequency manually.
> 
> 2) invtsc migration with no explicit TSC frequency
> --------------------------------------------------
> 
> A future series can implement migration when TSC frequency is not
> specified explicitly. It will be a bit more complex because it
> requires either letting the destination abort the migration, or
> sending TSC frequency/scaling information from destination to
> source.
> 
> ---
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Cc: "Daniel P. Berrange" <berrange@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Haozhong Zhang <haozhong.zhang@intel.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: libvir-list@redhat.com
> Cc: Jiri Denemark <jdenemar@redhat.com>
> 
> Eduardo Habkost (2):
>   kvm: Simplify invtsc check
>   kvm: Allow invtsc migration if tsc-khz is set explicitly
> 
>  target/i386/kvm.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> -- 
> 2.11.0.259.g40922b1

Looks good to me.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-18 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-08 17:32 [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set Eduardo Habkost
2017-01-08 17:32 ` [Qemu-devel] [PATCH v3 1/2] kvm: Simplify invtsc check Eduardo Habkost
2017-01-08 17:32 ` [Qemu-devel] [PATCH v3 2/2] kvm: Allow invtsc migration if tsc-khz is set explicitly Eduardo Habkost
2017-01-18 12:11 ` [Qemu-devel] [PATCH v3 0/2] Allow migration with invtsc if TSC frequency is explicitly set Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).