From: Avi Kivity <avi@redhat.com>
To: Chris Wright <chrisw@sous-sol.org>
Cc: Rik van Riel <riel@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@elte.hu>,
Anthony Liguori <aliguori@linux.vnet.ibm.com>
Subject: Re: [RFC PATCH 3/3] kvm: use yield_to instead of sleep in kvm_vcpu_on_spin
Date: Sun, 05 Dec 2010 14:58:14 +0200 [thread overview]
Message-ID: <4CFB8C66.9090508@redhat.com> (raw)
In-Reply-To: <20101203022418.GW10050@sequoia.sous-sol.org>
On 12/03/2010 04:24 AM, Chris Wright wrote:
> * Rik van Riel (riel@redhat.com) wrote:
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -1880,18 +1880,53 @@ void kvm_resched(struct kvm_vcpu *vcpu)
> > }
> > EXPORT_SYMBOL_GPL(kvm_resched);
> >
> > -void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu)
> > +void kvm_vcpu_on_spin(struct kvm_vcpu *me)
> > {
> > - ktime_t expires;
> > - DEFINE_WAIT(wait);
> > + struct kvm *kvm = me->kvm;
> > + struct kvm_vcpu *vcpu;
> > + int last_boosted_vcpu = me->kvm->last_boosted_vcpu;
>
> s/me->//
>
> > + int first_round = 1;
> > + int i;
> >
> > - prepare_to_wait(&vcpu->wq,&wait, TASK_INTERRUPTIBLE);
> > + me->spinning = 1;
> > +
> > + /*
> > + * We boost the priority of a VCPU that is runnable but not
> > + * currently running, because it got preempted by something
> > + * else and called schedule in __vcpu_run. Hopefully that
> > + * VCPU is holding the lock that we need and will release it.
> > + * We approximate round-robin by starting at the last boosted VCPU.
> > + */
> > + again:
> > + kvm_for_each_vcpu(i, vcpu, kvm) {
> > + struct task_struct *task = vcpu->task;
> > + if (first_round&& i< last_boosted_vcpu) {
> > + i = last_boosted_vcpu;
> > + continue;
> > + } else if (!first_round&& i> last_boosted_vcpu)
> > + break;
> > + if (vcpu == me)
> > + continue;
> > + if (vcpu->spinning)
> > + continue;
> > + if (!task)
> > + continue;
> > + if (waitqueue_active(&vcpu->wq))
> > + continue;
> > + if (task->flags& PF_VCPU)
> > + continue;
>
> I wonder if you set vcpu->task in sched_out and then NULL it in sched_in
> if you'd get what you want you could simplify the checks. Basically
> that would be only the preempted runnable vcpus.
They may be sleeping due to some other reason (HLT, major page fault).
Better check is that the task is runnable but not running. Can we get
this information from a task?
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2010-12-05 12:58 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-02 19:41 [RFC PATCH 0/3] directed yield for Pause Loop Exiting Rik van Riel
2010-12-02 19:43 ` [RFC PATCH 1/3] kvm: keep track of which task is running a KVM vcpu Rik van Riel
2010-12-03 1:18 ` Chris Wright
2010-12-03 14:50 ` Rik van Riel
2010-12-03 15:55 ` Chris Wright
2010-12-05 12:40 ` Avi Kivity
2010-12-03 12:17 ` Srivatsa Vaddagiri
2010-12-03 14:16 ` Rik van Riel
2010-12-05 12:59 ` Avi Kivity
2010-12-02 19:44 ` [RFC PATCH 2/3] sched: add yield_to function Rik van Riel
2010-12-03 0:50 ` Chris Wright
2010-12-03 18:27 ` Rik van Riel
2010-12-03 19:30 ` Chris Wright
2010-12-03 21:30 ` Peter Zijlstra
2010-12-03 5:54 ` Mike Galbraith
2010-12-03 13:46 ` Srivatsa Vaddagiri
2010-12-03 14:45 ` Mike Galbraith
2010-12-03 14:48 ` Rik van Riel
2010-12-03 15:09 ` Mike Galbraith
2010-12-03 15:35 ` Rik van Riel
2010-12-03 16:20 ` Srivatsa Vaddagiri
2010-12-03 17:09 ` Rik van Riel
2010-12-03 17:29 ` Srivatsa Vaddagiri
2010-12-03 17:33 ` Rik van Riel
2010-12-03 17:45 ` Srivatsa Vaddagiri
2010-12-03 20:05 ` Mike Galbraith
2010-12-03 21:26 ` Peter Zijlstra
2010-12-03 13:23 ` Peter Zijlstra
2010-12-03 13:30 ` Srivatsa Vaddagiri
2010-12-03 14:03 ` Peter Zijlstra
2010-12-03 14:06 ` Srivatsa Vaddagiri
2010-12-03 14:10 ` Srivatsa Vaddagiri
2010-12-03 21:23 ` Peter Zijlstra
2010-12-04 13:02 ` Rik van Riel
2010-12-10 4:34 ` Rik van Riel
2010-12-10 8:39 ` Srivatsa Vaddagiri
2010-12-10 14:55 ` Rik van Riel
2010-12-08 17:55 ` Rik van Riel
2010-12-08 20:00 ` Peter Zijlstra
2010-12-08 20:04 ` Peter Zijlstra
2010-12-08 22:59 ` Rik van Riel
2010-12-02 19:45 ` [RFC PATCH 3/3] kvm: use yield_to instead of sleep in kvm_vcpu_on_spin Rik van Riel
2010-12-03 2:24 ` Chris Wright
2010-12-05 12:58 ` Avi Kivity [this message]
2010-12-05 12:56 ` Avi Kivity
2010-12-08 22:38 ` Rik van Riel
2010-12-09 10:28 ` Avi Kivity
2010-12-09 17:07 ` Rik van Riel
2010-12-11 7:27 ` Avi Kivity
2010-12-02 22:41 ` [RFC PATCH 0/3] directed yield for Pause Loop Exiting Chris Wright
2010-12-05 13:02 ` Avi Kivity
2010-12-10 5:03 ` Balbir Singh
2010-12-10 14:54 ` Rik van Riel
2010-12-11 7:31 ` Avi Kivity
2010-12-11 13:57 ` Balbir Singh
2010-12-13 11:57 ` Avi Kivity
2010-12-13 12:39 ` Balbir Singh
2010-12-13 12:42 ` Avi Kivity
2010-12-13 17:02 ` Rik van Riel
2010-12-14 9:25 ` Balbir Singh
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=4CFB8C66.9090508@redhat.com \
--to=avi@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=aliguori@linux.vnet.ibm.com \
--cc=chrisw@sous-sol.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=riel@redhat.com \
--cc=vatsa@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).