From: Christian Borntraeger Date: Tue, 19 Aug 2014 14:45:56 +0000 (+0200) Subject: KVM: avoid unnecessary synchronize_rcu X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=7103f60de8bed21a0ad5d15d2ad5b7a333dda201;p=openwrt%2Fstaging%2Fblogic.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 --- 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();