From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org,
Gleb Natapov <gleb@redhat.com>
Subject: Re: [PATCH v4 07/10] qemu-kvm: Cleanup/fix TSC and PV clock writeback
Date: Thu, 25 Feb 2010 16:56:54 +0100 [thread overview]
Message-ID: <4B869DC6.1080403@siemens.com> (raw)
In-Reply-To: <ac600f145451efb7233e5ab293be2e0f49c904f6.1267021065.git.jan.kiszka@siemens.com>
Drop kvm_load_tsc in favor of level-dependent writeback in
kvm_arch_load_regs. KVM's PV clock MSRs fall in the same category and
should therefore only be written back on full sync.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Changes in v4:
- only write TSC MSRs of SMP guests if they are non-zero, ie. after
migration (behavior of original code)
qemu-kvm-x86.c | 27 +++++++++++++--------------
qemu-kvm.h | 4 ----
target-i386/machine.c | 5 -----
3 files changed, 13 insertions(+), 23 deletions(-)
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 840c1c9..285c05a 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -965,8 +965,19 @@ void kvm_arch_load_regs(CPUState *env, int level)
set_msr_entry(&msrs[n++], MSR_LSTAR , env->lstar);
}
#endif
- set_msr_entry(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr);
- set_msr_entry(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
+ if (level == KVM_PUT_FULL_STATE) {
+ /*
+ * KVM is yet unable to synchronize TSC values of multiple VCPUs on
+ * writeback. Until this is fixed, we only write the offset to SMP
+ * guests after migration, desynchronizing the VCPUs, but avoiding
+ * huge jump-backs that would occur without any writeback at all.
+ */
+ if (smp_cpus == 1 || env->tsc != 0) {
+ set_msr_entry(&msrs[n++], MSR_IA32_TSC, env->tsc);
+ }
+ set_msr_entry(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr);
+ set_msr_entry(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
+ }
rc = kvm_set_msrs(env, msrs, n);
if (rc == -1)
@@ -986,18 +997,6 @@ void kvm_arch_load_regs(CPUState *env, int level)
kvm_guest_debug_workarounds(env);
}
-void kvm_load_tsc(CPUState *env)
-{
- int rc;
- struct kvm_msr_entry msr;
-
- set_msr_entry(&msr, MSR_IA32_TSC, env->tsc);
-
- rc = kvm_set_msrs(env, &msr, 1);
- if (rc == -1)
- perror("kvm_set_tsc FAILED.\n");
-}
-
void kvm_arch_save_regs(CPUState *env)
{
struct kvm_regs regs;
diff --git a/qemu-kvm.h b/qemu-kvm.h
index c6ff652..827cac5 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -958,7 +958,6 @@ int handle_tpr_access(void *opaque, CPUState *env, uint64_t rip,
#ifdef TARGET_I386
#define qemu_kvm_has_pit_state2() kvm_has_pit_state2(kvm_context)
#endif
-void kvm_load_tsc(CPUState *env);
#else
#define kvm_nested 0
#define qemu_kvm_has_gsi_routing() (0)
@@ -966,9 +965,6 @@ void kvm_load_tsc(CPUState *env);
#define qemu_kvm_has_pit_state2() (0)
#endif
#define qemu_kvm_cpu_stop(env) do {} while(0)
-static inline void kvm_load_tsc(CPUState *env)
-{
-}
#endif
void kvm_mutex_unlock(void);
diff --git a/target-i386/machine.c b/target-i386/machine.c
index bcc315b..b547e2a 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -354,11 +354,6 @@ static int cpu_post_load(void *opaque, int version_id)
hw_breakpoint_insert(env, i);
tlb_flush(env, 1);
-
- if (kvm_enabled()) {
- kvm_load_tsc(env);
- }
-
return 0;
}
next prev parent reply other threads:[~2010-02-25 15:57 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-24 14:17 [PATCH v3 00/10] qemu-kvm: Hook cleanups and yet more use of upstream code Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 01/10] qemu-kvm: Add KVM_CAP_X86_ROBUST_SINGLESTEP-awareness Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 02/10] qemu-kvm: Rework VCPU state writeback API Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 03/10] x86: Extend validity of cpu_is_bsp Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 04/10] qemu-kvm: Clean up mpstate synchronization Jan Kiszka
2010-02-24 22:44 ` Marcelo Tosatti
2010-02-25 0:02 ` Jan Kiszka
2010-02-25 11:56 ` Jan Kiszka
2010-02-25 17:20 ` [PATCH v4 " Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 05/10] KVM: x86: Restrict writeback of VCPU state Jan Kiszka
2010-02-24 22:59 ` Marcelo Tosatti
2010-02-24 23:51 ` Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 06/10] qemu-kvm: Use VCPU event state for reset and vmsave/load Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 07/10] qemu-kvm: Cleanup/fix TSC and PV clock writeback Jan Kiszka
2010-02-24 23:17 ` Marcelo Tosatti
2010-02-24 23:45 ` Jan Kiszka
2010-02-24 23:49 ` Marcelo Tosatti
2010-02-24 23:58 ` Jan Kiszka
2010-02-25 3:58 ` Marcelo Tosatti
2010-02-25 8:48 ` Jan Kiszka
2010-02-25 15:07 ` Marcelo Tosatti
2010-02-25 15:17 ` Jan Kiszka
2010-02-25 15:48 ` Marcelo Tosatti
2010-02-25 15:56 ` Jan Kiszka [this message]
2010-02-24 14:17 ` [PATCH v3 08/10] qemu-kvm: Clean up KVM's APIC hooks Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 09/10] qemu-kvm: Move kvm_set_boot_cpu_id Jan Kiszka
2010-02-24 14:17 ` [PATCH v3 10/10] qemu-kvm: Bring qemu_init_vcpu back home Jan Kiszka
2010-02-24 23:26 ` [PATCH v3 00/10] qemu-kvm: Hook cleanups and yet more use of upstream code Marcelo Tosatti
2010-02-24 23:55 ` Jan Kiszka
-- strict thread matches above, loose matches on Subject: below --
2010-03-01 17:17 [PATCH v4 " Jan Kiszka
2010-03-01 17:17 ` [PATCH v4 07/10] qemu-kvm: Cleanup/fix TSC and PV clock writeback Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B869DC6.1080403@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox