From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM: VMX: optimize APIC EOI Date: Tue, 15 Jun 2010 07:33:11 +0300 Message-ID: <4C170287.4040002@redhat.com> References: <20100614223004.GA9594@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , kvm To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:5658 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193Ab0FOEdQ (ORCPT ); Tue, 15 Jun 2010 00:33:16 -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 o5F4XFcG004334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 15 Jun 2010 00:33:15 -0400 In-Reply-To: <20100614223004.GA9594@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 06/15/2010 01:30 AM, Marcelo Tosatti wrote: > Use information provided in exit_qualification to shortcut EOI path. > > Reduces EOI latency from 4k to 2k cycles on Nehalem. > > This already came up once - IIRC from Eddie Dong. > > static int handle_apic_access(struct kvm_vcpu *vcpu) > { > + unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION); > + int access_type, offset; > + > + access_type = (exit_qualification>> 12)& 0xf; > + offset = exit_qualification& 0xfff; > + if (access_type == 1&& offset == APIC_EOI) { > + kvm_lapic_set_eoi(vcpu); > + skip_emulated_instruction(vcpu); > + return 1; > + } > + > return emulate_instruction(vcpu, 0, 0, 0) == EMULATE_DONE; > } > > This fails if the instruction is STOS, MOVS, or a RMW instruction as it doesn't update registers and flags. We could try to do tricks to detect this, but we already have x2apic for Linux and the corresponding Hyper-V extension, which improve a lot of other stuff, at least for newer guests. \ -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.