lkml.org 
[lkml]   [2011]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC -v4 PATCH 3/3] kvm: use yield_to instead of sleep in kvm_vcpu_on_spin
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



\
 
 \ /
  Last update: 2011-01-13 14:19    [W:0.073 / U:0.200 seconds]
©2003-2011 Jasper Spaans