KVM: avoid unnecessary synchronize_rcu
authorChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 19 Aug 2014 14:45:56 +0000 (16:45 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 21 Aug 2014 11:50:22 +0000 (13:50 +0200)
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>
virt/kvm/kvm_main.c

index 33712fb26eb11caa0f14bbf3b21a9e459c18252a..39b16035386f91db489c919174f24e0951a0a816 100644 (file)
@@ -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();