We find mostly apci access is eoi write. This patch accelerate guest EOI
emulation utilizing HW VM Exit information.
Without this patch, xentrace shows the apci access average tsc costs is ~7.8k in
our case and it down to ~3k with it. We also save 3% cpu in our case.
Here is the data
CPU%
cycles per APIC access VMEXIT
Times per second
CPU% for APIC Access VMEXIT handle
default
94.46%
7805
75424
5.52%
w/ VEOI
91.14%
3179
76474
2.28%
Default - w/ VEOI
3.33%
3.24%
diff -r 8af26fef898c xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Fri Jul 24 12:08:54 2009 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c Tue Jul 28 15:07:07 2009 +0800
@@ -2270,6 +2270,25 @@
}
}
+static int vmx_handle_eoi_write(void)
+{
+ struct vcpu *curr = current;
+ unsigned long exit_qualification;
+ unsigned long offset;
+ struct vlapic *vlapic = vcpu_vlapic(curr);
+
+ exit_qualification = __vmread(EXIT_QUALIFICATION);
+ offset = exit_qualification & 0xfff;
+
+ if ( ((exit_qualification >> 12) & 0xf) == 1 && offset ==
APIC_EOI )
+ {
+ /* EOI write */
+ vlapic_EOI_set(vlapic);
+ return 1;
+ }
+ return 0;
+}
+
asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
{
unsigned int exit_reason, idtv_info;
@@ -2571,9 +2590,15 @@
case EXIT_REASON_TPR_BELOW_THRESHOLD:
break;
-
+ case EXIT_REASON_APIC_ACCESS:
+ if ( vmx_handle_eoi_write() )
+ {
+ /* For EOI wirte, skip emulate it */
+ inst_len = __get_instruction_length();
+ __update_guest_eip(inst_len);
+ break;
+ }
case EXIT_REASON_IO_INSTRUCTION:
- case EXIT_REASON_APIC_ACCESS:
if ( !handle_mmio() )
vmx_inject_hw_exception(TRAP_gp_fault, 0);
break;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel