From: Avi Kivity <avi@redhat.com>
To: Rik van Riel <riel@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Mike Galbraith <efault@gmx.de>,
Chris Wright <chrisw@sous-sol.org>
Subject: Re: [RFC -v4 PATCH 3/3] kvm: use yield_to instead of sleep in kvm_vcpu_on_spin
Date: Thu, 13 Jan 2011 15:16:52 +0200 [thread overview]
Message-ID: <4D2EFB44.2060906@redhat.com> (raw)
In-Reply-To: <20110113002745.51190252@annuminas.surriel.com>
On 01/13/2011 07:27 AM, Rik van Riel wrote:
> Instead of sleeping in kvm_vcpu_on_spin, which can cause gigantic
> slowdowns of certain workloads, we instead use yield_to to hand
> the rest of our timeslice to another vcpu in the same KVM guest.
>
>
> + for (pass = 0; pass< 2&& !yielded; pass++) {
> + kvm_for_each_vcpu(i, vcpu, kvm) {
> + struct task_struct *task = vcpu->task;
> + if (!pass&& i< last_boosted_vcpu) {
> + i = last_boosted_vcpu;
> + continue;
> + } else if (pass&& i> last_boosted_vcpu)
> + break;
> + if (vcpu == me)
> + continue;
> + if (!task)
> + continue;
> + if (waitqueue_active(&vcpu->wq))
> + continue;
Suppose the vcpu exits at this point, and its task terminates.
> + if (task->flags& PF_VCPU)
> + continue;
Here you dereference freed memory.
> + kvm->last_boosted_vcpu = i;
> + yielded = 1;
> + yield_to(task, 1);
And here you do unimaginable things to that freed memory.
I think the first patch needs some reference counting... I'd move it to
the outermost KVM_RUN loop to reduce the performance impact.
> + break;
> + }
> + }
> }
> EXPORT_SYMBOL_GPL(kvm_vcpu_on_spin);
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-01-13 13:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-13 5:21 [RFC -v4 PATCH 0/3] directed yield for Pause Loop Exiting Rik van Riel
2011-01-13 5:22 ` [RFC -v4 PATCH 1/3] kvm: keep track of which task is running a KVM vcpu Rik van Riel
2011-01-13 5:26 ` [RFC -v4 PATCH 2/3] sched: Add yield_to(task, preempt) functionality Rik van Riel
2011-01-13 5:27 ` [RFC -v4 PATCH 3/3] kvm: use yield_to instead of sleep in kvm_vcpu_on_spin Rik van Riel
2011-01-13 13:16 ` Avi Kivity [this message]
2011-01-13 15:06 ` Rik van Riel
2011-01-13 15:23 ` Avi Kivity
2011-01-14 0:10 ` Rik van Riel
2011-01-13 13:12 ` [RFC -v4 PATCH 0/3] directed yield for Pause Loop Exiting Avi Kivity
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=4D2EFB44.2060906@redhat.com \
--to=avi@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=chrisw@sous-sol.org \
--cc=efault@gmx.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.