From patchwork Tue Oct 13 12:17:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 53398 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9DCLMEd015811 for ; Tue, 13 Oct 2009 12:21:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759487AbZJMMRt (ORCPT ); Tue, 13 Oct 2009 08:17:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757041AbZJMMRt (ORCPT ); Tue, 13 Oct 2009 08:17:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50082 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759381AbZJMMRs (ORCPT ); Tue, 13 Oct 2009 08:17:48 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9DCHMvZ031160 for ; Tue, 13 Oct 2009 08:17:22 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9DCHLMV017492; Tue, 13 Oct 2009 08:17:22 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 8359318D414; Tue, 13 Oct 2009 14:17:20 +0200 (IST) From: Gleb Natapov To: mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH 2/2] Don't sync mpstate to/from kernel when unneeded. Date: Tue, 13 Oct 2009 14:17:20 +0200 Message-Id: <1255436240-994-2-git-send-email-gleb@redhat.com> In-Reply-To: <1255436240-994-1-git-send-email-gleb@redhat.com> References: <1255436240-994-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/hw/apic.c b/hw/apic.c index 2952675..7244449 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -512,6 +512,7 @@ void apic_init_reset(CPUState *env) if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) { env->mp_state = env->halted ? KVM_MP_STATE_UNINITIALIZED : KVM_MP_STATE_RUNNABLE; + kvm_load_mpstate(env); } #endif } diff --git a/monitor.c b/monitor.c index 7f0f5a9..dd8f2ca 100644 --- a/monitor.c +++ b/monitor.c @@ -350,6 +350,7 @@ static CPUState *mon_get_cpu(void) mon_set_cpu(0); } cpu_synchronize_state(cur_mon->mon_cpu); + kvm_save_mpstate(cur_mon->mon_cpu); return cur_mon->mon_cpu; } @@ -377,6 +378,7 @@ static void do_info_cpus(Monitor *mon) for(env = first_cpu; env != NULL; env = env->next_cpu) { cpu_synchronize_state(env); + kvm_save_mpstate(env); monitor_printf(mon, "%c CPU #%d:", (env == mon->mon_cpu) ? '*' : ' ', env->cpu_index); diff --git a/qemu-kvm.c b/qemu-kvm.c index 3765818..2a1e0ff 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1609,11 +1609,6 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data) void kvm_arch_get_registers(CPUState *env) { kvm_arch_save_regs(env); - kvm_arch_save_mpstate(env); -#ifdef KVM_CAP_MP_STATE - if (kvm_irqchip_in_kernel(kvm_context)) - env->halted = (env->mp_state == KVM_MP_STATE_HALTED); -#endif } static void do_kvm_cpu_synchronize_state(void *_env) @@ -1707,6 +1702,10 @@ static void kvm_do_save_mpstate(void *_env) CPUState *env = _env; kvm_arch_save_mpstate(env); +#ifdef KVM_CAP_MP_STATE + if (kvm_irqchip_in_kernel(kvm_context)) + env->halted = (env->mp_state == KVM_MP_STATE_HALTED); +#endif } void kvm_save_mpstate(CPUState *env) diff --git a/qemu-kvm.h b/qemu-kvm.h index d6748c7..e2a87b8 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -1186,7 +1186,6 @@ void kvm_arch_get_registers(CPUState *env); static inline void kvm_arch_put_registers(CPUState *env) { kvm_load_registers(env); - kvm_load_mpstate(env); } void kvm_cpu_synchronize_state(CPUState *env); diff --git a/target-i386/machine.c b/target-i386/machine.c index e640dad..16d9c57 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -324,6 +324,7 @@ static void cpu_pre_save(void *opaque) int i, bit; cpu_synchronize_state(env); + kvm_save_mpstate(env); /* FPU */ env->fpus_vmstate = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; @@ -385,6 +386,8 @@ static int cpu_post_load(void *opaque, int version_id) } tlb_flush(env, 1); + kvm_load_mpstate(env); + return 0; }