public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: KVM <kvm@vger.kernel.org>
Subject: Re: [PATCH/RFC] KVM: do early exit in kvm_check_request
Date: Fri, 9 Sep 2016 18:35:49 +0200	[thread overview]
Message-ID: <94de9256-838c-73e6-d6de-2338a552d5df@redhat.com> (raw)
In-Reply-To: <1473415834-98576-1-git-send-email-borntraeger@de.ibm.com>



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@de.ibm.com>
> ---
>  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

  reply	other threads:[~2016-09-09 16:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 10:10 [PATCH/RFC] KVM: do early exit in kvm_check_request Christian Borntraeger
2016-09-09 16:35 ` Paolo Bonzini [this message]
2016-09-09 18:10   ` Christian Borntraeger
2016-09-09 18:30   ` Nadav Amit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94de9256-838c-73e6-d6de-2338a552d5df@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox