Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356894
b: refs/heads/master
c: c45c528
h: refs/heads/master
v: v3
  • Loading branch information
Raghavendra K T authored and Gleb Natapov committed Jan 29, 2013
1 parent 8973c4d commit e7da892
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7b270f609982f68f2433442bf167f735e7364b06
refs/heads/master: c45c528e899094b9049b3c900e2cf1f00aa0490c
26 changes: 16 additions & 10 deletions trunk/virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,24 +1694,23 @@ bool kvm_vcpu_yield_to(struct kvm_vcpu *target)
{
struct pid *pid;
struct task_struct *task = NULL;
bool ret = false;

rcu_read_lock();
pid = rcu_dereference(target->pid);
if (pid)
task = get_pid_task(target->pid, PIDTYPE_PID);
rcu_read_unlock();
if (!task)
return false;
return ret;
if (task->flags & PF_VCPU) {
put_task_struct(task);
return false;
}
if (yield_to(task, 1)) {
put_task_struct(task);
return true;
return ret;
}
ret = yield_to(task, 1);
put_task_struct(task);
return false;

return ret;
}
EXPORT_SYMBOL_GPL(kvm_vcpu_yield_to);

Expand Down Expand Up @@ -1752,12 +1751,14 @@ bool kvm_vcpu_eligible_for_directed_yield(struct kvm_vcpu *vcpu)
return eligible;
}
#endif

void kvm_vcpu_on_spin(struct kvm_vcpu *me)
{
struct kvm *kvm = me->kvm;
struct kvm_vcpu *vcpu;
int last_boosted_vcpu = me->kvm->last_boosted_vcpu;
int yielded = 0;
int try = 3;
int pass;
int i;

Expand All @@ -1769,7 +1770,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
* VCPU is holding the lock that we need and will release it.
* We approximate round-robin by starting at the last boosted VCPU.
*/
for (pass = 0; pass < 2 && !yielded; pass++) {
for (pass = 0; pass < 2 && !yielded && try; pass++) {
kvm_for_each_vcpu(i, vcpu, kvm) {
if (!pass && i <= last_boosted_vcpu) {
i = last_boosted_vcpu;
Expand All @@ -1782,10 +1783,15 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me)
continue;
if (!kvm_vcpu_eligible_for_directed_yield(vcpu))
continue;
if (kvm_vcpu_yield_to(vcpu)) {

yielded = kvm_vcpu_yield_to(vcpu);
if (yielded > 0) {
kvm->last_boosted_vcpu = i;
yielded = 1;
break;
} else if (yielded < 0) {
try--;
if (!try)
break;
}
}
}
Expand Down

0 comments on commit e7da892

Please sign in to comment.