From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hildenbrand Subject: Re: [PATCH RFC 1/2] KVM: don't check for PF_VCPU when yielding Date: Wed, 3 Dec 2014 14:04:26 +0100 Message-ID: <20141203140426.000047aa@thinkpad-w530> References: <1416931449-24585-1-git-send-email-dahi@linux.vnet.ibm.com> <1416931449-24585-2-git-send-email-dahi@linux.vnet.ibm.com> <547F09D0.7020404@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, gleb@kernel.org, jfrei@linux.vnet.ibm.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com To: Paolo Bonzini Return-path: Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:59550 "EHLO e06smtp12.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752414AbaLCNEh (ORCPT ); Wed, 3 Dec 2014 08:04:37 -0500 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 3 Dec 2014 13:04:34 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 154542190041 for ; Wed, 3 Dec 2014 13:04:03 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sB3D4Vah59375804 for ; Wed, 3 Dec 2014 13:04:31 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sB3D4S84031251 for ; Wed, 3 Dec 2014 06:04:30 -0700 In-Reply-To: <547F09D0.7020404@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: > Applied with a rewritten commit message: > > KVM: don't check for PF_VCPU when yielding > > kvm_enter_guest() has to be called with preemption disabled and will > set PF_VCPU. Current code takes PF_VCPU as a hint that the VCPU thread > is running and therefore needs no yield. > > However, the check on PF_VCPU is wrong on s390, where preemption > has to stay enabled on s390 in order to correctly process page faults. > Thus, s390 reenables preemption and starts to execute the guest. > The thread might be scheduled out between kvm_enter_guest() and > kvm_exit_guest(), resulting in PF_VCPU being set but not being run. > When this happens, the opportunity for directed yield is missed. > > However, this check is done already in kvm_vcpu_on_spin before calling > kvm_vcpu_yield_loop: > > if (!ACCESS_ONCE(vcpu->preempted)) > continue; > > so the check on PF_VCPU is superfluous in general, and this patch > removes it. > > Signed-off-by: David Hildenbrand > Signed-off-by: Paolo Bonzini > Perfect, thanks! David