Re: [PATCH][KVM] Add support for Pause Filtering to AMD SVM

From: Bert Wesarg
Date: Tue May 05 2009 - 12:05:58 EST


On Tue, May 5, 2009 at 16:09, Mark Langsdorf <mark.langsdorf@xxxxxxx> wrote:
> commit 6f15c833f56267baf5abdd0fbc90a81489573053
> Author: Mark Langsdorf <mlangsdo@xxxxxxxxxxxxxxx>
> Date: Â Mon May 4 15:02:38 2009 -0500
>
> Â Â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.
>
> Â Â-Mark Langsdorf
> Â ÂOperating System Research Center
> Â ÂAMD
>
> Â ÂSigned-off-by: Mark Langsdorf <mark.langsdorf@xxxxxxx>
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index ef43a18..14dab13 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -575,6 +576,12 @@ static void init_vmcb(struct vcpu_svm *svm)
>
> Â Â Â Âsvm->nested_vmcb = 0;
> Â Â Â Âsvm->vcpu.arch.hflags = HF_GIF_MASK;
> +
> + Â Â Â if (svm_has(SVM_FEATURE_PAUSE_FILTER)) {
> + Â Â Â Â Â Â Â control->pause_filter_count = 5000;
The commit message says something about 3000.

> + Â Â Â Â Â Â Â control->intercept |= (1ULL << INTERCEPT_PAUSE);
> + Â Â Â }
> +
> Â}
>
> Âstatic int svm_vcpu_reset(struct kvm_vcpu *vcpu)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/