Re: [PATCH/RFC] KVM: do early exit in kvm_check_request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 09/09/2016 12:10, Christian Borntraeger wrote:
> By checking vcpu->requests we can do an early exit and allow gcc
> to optimize multiple kvm_check_request into one block for the
> common case (no requests).
> 
> Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
> ---
>  include/linux/kvm_host.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 1c9c973..b15b460 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1115,6 +1115,8 @@ static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu)
>  
>  static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu)
>  {
> +	if (likely(!vcpu->requests))
> +		return false;
>  	if (test_bit(req, &vcpu->requests)) {
>  		clear_bit(req, &vcpu->requests);

I'm not sure -- due to asm in test_bit and to -fno-strict-aliasing, I'm
afraid that each kvm_check_request will have its own zero check.
kvm_check_request should be rare, but it does show up in microbenchmarks
so perhaps it's best to keep those two lines of code duplicated across
the architectures.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux