[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] x86 svm: Add support for Pause Filtering to AMD SVM
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1243420033 -3600 # Node ID 87c411a7c1df29002b087ea3b751983594e05078 # Parent 494c2ebf9d19e907e547d1980fb253466a04e6c8 x86 svm: Add support for Pause Filtering to AMD SVM New AMD processors will support the Pause Filter Feature. This feature creates a new field in the VMCB called Pause Filter Count. If Pause Filter Count is greater than 0 and ntercepting PAUSEs is enabled, the processor will increment an internal counter when a PAUSE instruction occurs instead of intercepting. When the internal counter reaches the Pause Filter Count value, a PAUSE intercept will occur. This feature can be used to detect contended spinlocks, especially when the lock holding VCPU is not scheduled. Rescheduling another VCPU prevents the VCPU seeking the lock from wasting its quantum by spinning idly. Experimental results show that most spinlocks are held for less than 1000 PAUSE cycles or more than a few thousand. Default the Pause Filter Counter to 3000 to detect the contended spinlocks. Processor support for this feature is indicated by a CPUID bit. On a 24 core system running 4 guests each with 16 VCPUs, this patch improved overall performance of each guest's 32 job kernbench by approximately 1%. Further performance improvement may be possible with a more sophisticated yield algorithm. Signed-off-by: Mark Langsdorf <mark.langsdorf@xxxxxxx> --- xen/arch/x86/hvm/svm/svm.c | 8 ++++++++ xen/arch/x86/hvm/svm/vmcb.c | 6 ++++++ xen/include/asm-x86/hvm/svm/svm.h | 2 ++ xen/include/asm-x86/hvm/svm/vmcb.h | 4 +++- 4 files changed, 19 insertions(+), 1 deletion(-) diff -r 494c2ebf9d19 -r 87c411a7c1df xen/arch/x86/hvm/svm/svm.c --- a/xen/arch/x86/hvm/svm/svm.c Wed May 27 11:21:59 2009 +0100 +++ b/xen/arch/x86/hvm/svm/svm.c Wed May 27 11:27:13 2009 +0100 @@ -1508,6 +1508,14 @@ asmlinkage void svm_vmexit_handler(struc vmcb->interrupt_shadow = 1; break; + case VMEXIT_PAUSE: + /* + * The guest is running a contended spinlock and we've detected it. + * Do something useful, like reschedule the guest + */ + do_sched_op_compat(SCHEDOP_yield, 0); + break; + default: exit_and_crash: gdprintk(XENLOG_ERR, "unexpected VMEXIT: exit reason = 0x%x, " diff -r 494c2ebf9d19 -r 87c411a7c1df xen/arch/x86/hvm/svm/vmcb.c --- a/xen/arch/x86/hvm/svm/vmcb.c Wed May 27 11:21:59 2009 +0100 +++ b/xen/arch/x86/hvm/svm/vmcb.c Wed May 27 11:27:13 2009 +0100 @@ -245,6 +245,12 @@ static int construct_vmcb(struct vcpu *v else { vmcb->exception_intercepts |= (1U << TRAP_page_fault); + } + + if ( cpu_has_pause_filter ) + { + vmcb->pause_filter_count = 3000; + vmcb->general1_intercepts |= GENERAL1_INTERCEPT_PAUSE; } return 0; diff -r 494c2ebf9d19 -r 87c411a7c1df xen/include/asm-x86/hvm/svm/svm.h --- a/xen/include/asm-x86/hvm/svm/svm.h Wed May 27 11:21:59 2009 +0100 +++ b/xen/include/asm-x86/hvm/svm/svm.h Wed May 27 11:27:13 2009 +0100 @@ -67,10 +67,12 @@ extern u32 svm_feature_flags; #define SVM_FEATURE_LBRV 1 #define SVM_FEATURE_SVML 2 #define SVM_FEATURE_NRIPS 3 +#define SVM_FEATURE_PAUSEF 10 #define cpu_has_svm_npt test_bit(SVM_FEATURE_NPT, &svm_feature_flags) #define cpu_has_svm_lbrv test_bit(SVM_FEATURE_LBRV, &svm_feature_flags) #define cpu_has_svm_svml test_bit(SVM_FEATURE_SVML, &svm_feature_flags) #define cpu_has_svm_nrips test_bit(SVM_FEATURE_NRIPS, &svm_feature_flags) +#define cpu_has_pause_filter test_bit(SVM_FEATURE_PAUSEF, &svm_feature_flags) #endif /* __ASM_X86_HVM_SVM_H__ */ diff -r 494c2ebf9d19 -r 87c411a7c1df xen/include/asm-x86/hvm/svm/vmcb.h --- a/xen/include/asm-x86/hvm/svm/vmcb.h Wed May 27 11:21:59 2009 +0100 +++ b/xen/include/asm-x86/hvm/svm/vmcb.h Wed May 27 11:27:13 2009 +0100 @@ -375,7 +375,9 @@ struct vmcb_struct { u64 res03; /* offset 0x20 */ u64 res04; /* offset 0x28 */ u64 res05; /* offset 0x30 */ - u64 res06; /* offset 0x38 */ + u32 res06; /* offset 0x38 */ + u16 res06a; /* offset 0x3C */ + u16 pause_filter_count; /* offset 0x3E */ u64 iopm_base_pa; /* offset 0x40 */ u64 msrpm_base_pa; /* offset 0x48 */ u64 tsc_offset; /* offset 0x50 */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |