From: "Jan Beulich" Subject: Re: heavy P2M lock contention on guest HPET counter reads Date: Wed, 30 Jul 2014 15:22:43 +0100 Message-ID: <53D91BD30200007800027B61@mail.emea.novell.com> References: <53D8E0540200007800027966@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XCUmE-0000GW-Ud for xen-devel@lists.xenproject.org; Wed, 30 Jul 2014 14:22:47 +0000 In-Reply-To: <53D8E0540200007800027966@mail.emea.novell.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andres Lagar-Cavilla , Tim Deegan Cc: xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 30.07.14 at 12:08, wrote: > with 40+ vCPU Win2012R2 guests we're observing apparent guest live > locks. The 'd' debug key reveals more than half of the vCPU-s doing an > inlined HPET main counter read from KeQueryPerformanceCounter(), > resulting in all of them racing for the lock at the beginning of > __get_gfn_type_access(). Assuming it is really necessary to always > take the write lock (rather than just the read one) here, would it perhaps > be reasonable to introduce a bypass in hvm_hap_nested_page_fault() > for the HPET page similar to the LAPIC one? Like this (for 4.4, if it matters, and with no tester feedback yet), raising the question whether we shouldn't just do this for all internal MMIO handlers. --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1523,11 +1523,16 @@ int hvm_hap_nested_page_fault(paddr_t gp } } - /* For the benefit of 32-bit WinXP (& older Windows) on AMD CPUs, - * a fast path for LAPIC accesses, skipping the p2m lookup. */ + /* + * For the benefit of 32-bit WinXP (& older Windows) on AMD CPUs, + * a fast path for LAPIC accesses, skipping the p2m lookup. + * Similarly for newer Windows (like Server 2012) a fast path for + * HPET accesses. + */ if ( !nestedhvm_vcpu_in_guestmode(v) && is_hvm_vcpu(v) - && gfn == PFN_DOWN(vlapic_base_address(vcpu_vlapic(v))) ) + && (gfn == PFN_DOWN(vlapic_base_address(vcpu_vlapic(v))) + || hpet_mmio_handler.check_handler(v, gpa)) ) { if ( !handle_mmio() ) hvm_inject_hw_exception(TRAP_gp_fault, 0);