summaryrefslogtreecommitdiff
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
authorChristian Borntraeger <borntraeger@de.ibm.com>2014-08-19 18:45:56 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-08-21 15:50:22 +0400
commit7103f60de8bed21a0ad5d15d2ad5b7a333dda201 (patch)
tree3f78e7d4a4e03ec6c81616239bad7a2dde205cf0 /virt/kvm/kvm_main.c
parente0ad0b477c36fde6b0923670647495d07bf42f94 (diff)
downloadlinux-7103f60de8bed21a0ad5d15d2ad5b7a333dda201.tar.xz
KVM: avoid unnecessary synchronize_rcu
We dont have to wait for a grace period if there is no oldpid that we are going to free. putpid also checks for NULL, so this patch only fences synchronize_rcu. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 33712fb26eb1..39b16035386f 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -129,7 +129,8 @@ int vcpu_load(struct kvm_vcpu *vcpu)
struct pid *oldpid = vcpu->pid;
struct pid *newpid = get_task_pid(current, PIDTYPE_PID);
rcu_assign_pointer(vcpu->pid, newpid);
- synchronize_rcu();
+ if (oldpid)
+ synchronize_rcu();
put_pid(oldpid);
}
cpu = get_cpu();