From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Borntraeger Subject: Re: [PATCH] KVM: avoid unnecessary synchronize_rcu Date: Mon, 25 Aug 2014 10:27:09 +0200 Message-ID: <53FAF35D.3080605@de.ibm.com> References: <1408459556-3098-1-git-send-email-borntraeger@de.ibm.com> <53FAF2D0.3010805@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: KVM , Gleb Natapov , raghavendra.kt@linux.vnet.ibm.com, riel@redhat.com, dahi@linux.vnet.ibm.com To: Paolo Bonzini Return-path: Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:45075 "EHLO e06smtp11.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755111AbaHYI1O (ORCPT ); Mon, 25 Aug 2014 04:27:14 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Aug 2014 09:27:13 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 594A92190023 for ; Mon, 25 Aug 2014 09:26:52 +0100 (BST) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s7P8RAP829687838 for ; Mon, 25 Aug 2014 08:27:10 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s7P8R9tr020747 for ; Mon, 25 Aug 2014 02:27:10 -0600 In-Reply-To: <53FAF2D0.3010805@de.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 25/08/14 10:24, Christian Borntraeger wrote: > On 19/08/14 16:45, Christian Borntraeger wrote: >> 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 >> --- >> virt/kvm/kvm_main.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >> index 33712fb..39b1603 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(); >> > > Ping. > That variant should be enough for us for future QEMUs. David has prepared some patches in QEMU that makes the other problems go away (mostly) which are currently under internal review/test. > Let me know if you want to have the put_pid inside the if as well (or feel free to fix up yourself code and patch description). > > Thanks Just updated kvm/next. Sorry for the noise.