From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Borntraeger Subject: Re: [PATCH/RFC] KVM: track pid for VCPU only on KVM_RUN ioctl Date: Tue, 19 Aug 2014 10:38:11 +0200 Message-ID: <53F30CF3.5030606@de.ibm.com> References: <1407249854-2953-1-git-send-email-borntraeger@de.ibm.com> <53E38193.8060206@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Cc: KVM , Gleb Natapov , Rik van Riel , Raghavendra K T , Michael Mueller To: Paolo Bonzini Return-path: Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:55191 "EHLO e06smtp15.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbaHSIiV (ORCPT ); Tue, 19 Aug 2014 04:38:21 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 19 Aug 2014 09:38:19 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5BCF1219004D for ; Tue, 19 Aug 2014 09:37:58 +0100 (BST) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s7J8cFNP28180652 for ; Tue, 19 Aug 2014 08:38:15 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s7J8cFhT013678 for ; Tue, 19 Aug 2014 04:38:15 -0400 In-Reply-To: <53E38193.8060206@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/08/14 15:39, Paolo Bonzini wrote: > Il 05/08/2014 16:44, Christian Borntraeger ha scritto: >> We currently track the pid of the task that runs the VCPU in >> vcpu_load. Since we call vcpu_load for all kind of ioctls on a >> CPU, this causes hickups due to synchronize_rcu if one CPU is >> modified by another CPU or the main thread (e.g. initialization, >> reset). We track the pid only for the purpose of yielding, so >> let's update the pid only in the KVM_RUN ioctl. >> >> In addition, don't do a synchronize_rcu on startup (pid == 0). > > Speaking of QEMU, most ioctls should run from the VCPU anyway. Which > ioctls do you see called from elsewhere? What speedup can you see if > you just do the "no synchronize_rcu on pid == 0" part? I think on x86 "no synchronize_rcu on pid == 0" is the only thing that is necessary. > > The patch may be okay, but I'm worried that it might be hiding a bug in > QEMU. On s390 we call "KVM_S390_INITIAL_RESET" from several reset functions, e.g. during CPU creation. This is the first hickup and the pid now points to the main thread. The 2nd hickup comes when the guest activates additional CPUs via SIGP (ipi). Here the first ioctl in the vpcu thread will get the pid back to the vcpu thread. > > Paolo > >> This speeds up guest boot time on s390 noticably for some configs, e.g. >> HZ=100, no full state tracking, 64 guest cpus 32 host cpus. >