From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hildenbrand Subject: [PATCH RFC 1/2] KVM: don't check for PF_VCPU when yielding Date: Tue, 25 Nov 2014 17:04:08 +0100 Message-ID: <1416931449-24585-2-git-send-email-dahi@linux.vnet.ibm.com> References: <1416931449-24585-1-git-send-email-dahi@linux.vnet.ibm.com> Cc: pbonzini@redhat.com, gleb@kernel.org, jfrei@linux.vnet.ibm.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com, dahi@linux.vnet.ibm.com To: kvm@vger.kernel.org Return-path: Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:50180 "EHLO e06smtp16.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751285AbaKYQES (ORCPT ); Tue, 25 Nov 2014 11:04:18 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Nov 2014 16:04:16 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7A97D219005C for ; Tue, 25 Nov 2014 16:03:47 +0000 (GMT) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sAPG4Eo017432888 for ; Tue, 25 Nov 2014 16:04:14 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sAPG4CYa028611 for ; Tue, 25 Nov 2014 09:04:14 -0700 In-Reply-To: <1416931449-24585-1-git-send-email-dahi@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: As some architectures (e.g. s390) can't disable preemption while entering/leaving the guest, they won't receive the yield in all situations. kvm_enter_guest() has to be called with preemption_disabled and will set PF_VCPU. After that point e.g. s390 reenables preemption and starts to execute the guest. The thread might therefore be scheduled out between kvm_enter_guest() and kvm_exit_guest(), resulting in PF_VCPU being set but not being run. Please note that preemption has to stay enabled in order to correctly process page faults on s390. Current code takes PF_VCPU as a hint that the VCPU thread is running and therefore needs no yield. yield_to() checks whether the target thread is running, so let's use the inbuilt functionality to make it independent of PF_VCPU and preemption. Signed-off-by: David Hildenbrand --- virt/kvm/kvm_main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5b45330..184f52e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1782,10 +1782,6 @@ int kvm_vcpu_yield_to(struct kvm_vcpu *target) rcu_read_unlock(); if (!task) return ret; - if (task->flags & PF_VCPU) { - put_task_struct(task); - return ret; - } ret = yield_to(task, 1); put_task_struct(task); -- 1.8.5.5