From: Christian Borntraeger Date: Tue, 19 Aug 2014 14:45:56 +0000 (+0200) Subject: KVM: avoid unnecessary synchronize_rcu X-Git-Tag: firefly_0821_release~3680^2~36^2~16^2^2~48 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7fdbe25673a0bcd4c38968ec2cd048a21f1fbb93;p=firefly-linux-kernel-4.4.55.git 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 Signed-off-by: Paolo Bonzini (cherry picked from commit 7103f60de8bed21a0ad5d15d2ad5b7a333dda201) Signed-off-by: Christoffer Dall --- diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 50f947301fa7..aa5057e7a1b9 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();