From 14520c92cbd7619ae097a3087b140c992b5c270b Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Tue, 2 Dec 2014 15:19:13 -0500 Subject: xen/pci: Use APIC directly when APIC virtualization hardware is available When hardware supports APIC/x2APIC virtualization we don't need to use pirqs for MSI handling and instead use APIC since most APIC accesses (MMIO or MSR) will now be processed without VMEXITs. As an example, netperf on the original code produces this profile (collected wih 'xentrace -e 0x0008ffff -T 5'): 342 cpu_change 260 CPUID 34638 HLT 64067 INJ_VIRQ 28374 INTR 82733 INTR_WINDOW 10 NPF 24337 TRAP 370610 vlapic_accept_pic_intr 307528 VMENTRY 307527 VMEXIT 140998 VMMCALL 127 wrap_buffer After applying this patch the same test shows 230 cpu_change 260 CPUID 36542 HLT 174 INJ_VIRQ 27250 INTR 222 INTR_WINDOW 20 NPF 24999 TRAP 381812 vlapic_accept_pic_intr 166480 VMENTRY 166479 VMEXIT 77208 VMMCALL 81 wrap_buffer ApacheBench results (ab -n 10000 -c 200) improve by about 10% Signed-off-by: Boris Ostrovsky Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Andrew Cooper Signed-off-by: David Vrabel --- arch/x86/pci/xen.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'arch/x86/pci/xen.c') diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c index 1370716907e1..37914ef19c0a 100644 --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include static int xen_pcifront_enable_irq(struct pci_dev *dev) @@ -434,6 +436,20 @@ int __init pci_xen_init(void) #ifdef CONFIG_PCI_MSI void __init xen_msi_init(void) { + if (!disable_apic) { + /* + * If hardware supports (x2)APIC virtualization (as indicated + * by hypervisor's leaf 4) then we don't need to use pirqs/ + * event channels for MSI handling and instead use regular + * APIC processing + */ + uint32_t eax = cpuid_eax(xen_cpuid_base() + 4); + + if (((eax & XEN_HVM_CPUID_X2APIC_VIRT) && x2apic_mode) || + ((eax & XEN_HVM_CPUID_APIC_ACCESS_VIRT) && cpu_has_apic)) + return; + } + x86_msi.setup_msi_irqs = xen_hvm_setup_msi_irqs; x86_msi.teardown_msi_irq = xen_teardown_msi_irq; } -- cgit v1.2.3-55-g7522