From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] KVM: emulator: do not needlesly sync registers from emulator ctxt to vcpu Date: Wed, 30 Mar 2011 15:26:18 +0200 Message-ID: <20110330132618.GY7766@redhat.com> References: <20110329120838.GQ7766@redhat.com> <4D93083D.6000806@redhat.com> <20110330104727.GS7766@redhat.com> <4D930B0D.4090809@redhat.com> <20110330112243.GV7766@redhat.com> <20110330114333.GW7766@redhat.com> <4D931F73.90704@redhat.com> <20110330124828.GX7766@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47917 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755847Ab1C3N0U (ORCPT ); Wed, 30 Mar 2011 09:26:20 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2UDQJQn028017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 30 Mar 2011 09:26:20 -0400 Content-Disposition: inline In-Reply-To: <20110330124828.GX7766@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Mar 30, 2011 at 02:48:28PM +0200, Gleb Natapov wrote: > On Wed, Mar 30, 2011 at 02:17:55PM +0200, Avi Kivity wrote: > > On 03/30/2011 01:43 PM, Gleb Natapov wrote: > > >After reboot perf started to work. I ran modified emulator.flat unit > > >test. It was modified to run test_cmps() in an endless loop. > > > > > >Without patch: > > >1.71% qemu-system-x86 [kvm] [k] x86_emulate_instruction > > >1.51% qemu-system-x86 [kvm] [k] x86_emulate_instruction > > >1.68% qemu-system-x86 [kvm] [k] x86_emulate_instruction > > > > > >With patch: > > >0.84% qemu-system-x86 [kvm] [k] x86_emulate_instruction > > >0.96% qemu-system-x86 [kvm] [k] x86_emulate_instruction > > >0.89% qemu-system-x86 [kvm] [k] x86_emulate_instruction > > > > > > > The cause might be kvm_rip_write() using vmwrite. Can you use perf > > to see where the hits are in x86_emulate_instruction? > > > > If that's the case, we may be able to do local optimizations to > > kvm_rip_write(), kvm_set_rflags(), and toggle_interruptiblity() > > instead of this global change. > > > I can leave copying there and eliminate only kvm_rip_write and see > perf data. > 1.75% qemu-system-x86 [kvm] [k] x86_emulate_instruction 1.60% qemu-system-x86 [kvm] [k] x86_emulate_instruction 1.42% qemu-system-x86 [kvm] [k] x86_emulate_instruction This is with copy in place, but those are under if (writeback): toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility); kvm_set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); kvm_make_request(KVM_REQ_EVENT, vcpu); vcpu->arch.emulate_regs_need_sync_to_vcpu = false; kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); -- Gleb.