From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Borntraeger Subject: Re: [PATCH RFC 1/2] KVM: don't check for PF_VCPU when yielding Date: Wed, 26 Nov 2014 08:51:46 +0100 Message-ID: <54758692.5000906@de.ibm.com> References: <1416931449-24585-1-git-send-email-dahi@linux.vnet.ibm.com> <1416931449-24585-2-git-send-email-dahi@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: pbonzini@redhat.com, gleb@kernel.org, jfrei@linux.vnet.ibm.com, cornelia.huck@de.ibm.com To: David Hildenbrand , kvm@vger.kernel.org Return-path: Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:45852 "EHLO e06smtp17.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbaKZHvw (ORCPT ); Wed, 26 Nov 2014 02:51:52 -0500 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Nov 2014 07:51:50 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id DE6BE1B0806B for ; Wed, 26 Nov 2014 07:52:02 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sAQ7pmtD50856016 for ; Wed, 26 Nov 2014 07:51:48 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sAQ7plJE013057 for ; Wed, 26 Nov 2014 00:51:47 -0700 In-Reply-To: <1416931449-24585-2-git-send-email-dahi@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: Am 25.11.2014 um 17:04 schrieb David Hildenbrand: > 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. This change is a trade-off. PRO: This patch would improve the case of preemption on s390. This is probably a corner case as most distros have preemption off anyway. CON: The downside is that kvm_vcpu_yield_to is called also from kvm_vcpu_on_spin. Here we want to avoid the scheduler overhead for a wrong decision. So I think this patch is probably not what we want in most cases. > > 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); >