public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH RFC] KVM: busy-spin detector
Date: Wed, 16 Jun 2010 11:22:22 +0300	[thread overview]
Message-ID: <4C1889BE.9000600@redhat.com> (raw)
In-Reply-To: <20100611022551.GA16223@amt.cnet>

On 06/11/2010 05:25 AM, Marcelo Tosatti wrote:
> The following patch implements a simple busy-spin detector. It considers
> a vcpu as busy-spinning if there are two consecutive exits due to
> external interrupt on the same RIP, and sleeps for 100us in that case.
>
> It is very likely that if the vcpu is making progress it will either
> exit for other reasons or change RIP.
>
> The percentage numbers below represent improvement in kernel build
> time in comparison with mainline (RHEL 5.4 guest).
>
> make -j16, 8 cpu host:
> smp 16: 3%
> smp 18: 10%
> smp 32: 14%
>
> smp 4, make -j4, pinned to 2 cpus:
> 4%
>
> smp 8, make -j8, pinned to 2 cpus:
> 5%
>
>    

The big problem here is not in the patch itself, but in 
kvm_vcpu_on_spin().  An un-overcommitted guest will trigger this on long 
spinlocks and go to sleep, and if the lock is released while we're still 
sleeping, we lose performance.

> @@ -4654,6 +4665,8 @@ static int vcpu_enter_guest(struct kvm_v
>   	kvm_lapic_sync_from_vapic(vcpu);
>
>   	r = kvm_x86_ops->handle_exit(vcpu);
> +	if (r == 1)
> +		vcpu->arch.last_rip = ~(0UL);
>   out:
>   	return r;
>   }
>    

!= 2, no?

It's a little ugly to overload the return code like that.  Perhaps:

+    vcpu->arch.save_last_rip = vcpu->arch.last_rip
+    vcpu->arch.last_rip = ~0UL;
      r = kvm_x86_ops->handle_exit(vcpu);

And kvm_detect_spin() can restore last_rip.

-- 
error compiling committee.c: too many arguments to function


      parent reply	other threads:[~2010-06-16  8:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-11  2:25 [PATCH RFC] KVM: busy-spin detector Marcelo Tosatti
2010-06-11 14:06 ` Balbir Singh
2010-06-11 15:03   ` Huang, Zhiteng
2010-06-11 17:38     ` Balbir Singh
2010-06-11 17:46   ` Marcelo Tosatti
2010-06-11 19:18     ` Balbir Singh
2010-06-16  8:22 ` Avi Kivity [this message]

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=4C1889BE.9000600@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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