Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752373AbdGaOYC (ORCPT ); Mon, 31 Jul 2017 10:24:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48526 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752071AbdGaOYA (ORCPT ); Mon, 31 Jul 2017 10:24:00 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8BB18C0587F5 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [RFC] KVM: optimize the kvm_vcpu_on_spin To: Marc Zyngier , "Longpeng(Mike)" , rkrcmar@redhat.com Cc: agraf@suse.com, borntraeger@de.ibm.com, cohuck@redhat.com, christoffer.dall@linaro.org, james.hogan@imgtec.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, weidong.huang@huawei.com, arei.gonglei@huawei.com, wangxinxin.wang@huawei.com, longpeng.mike@gmail.com References: <1501309377-195256-1-git-send-email-longpeng2@huawei.com> <85acc922-2b76-3e52-1f77-c200949b0532@arm.com> From: Paolo Bonzini Message-ID: Date: Mon, 31 Jul 2017 16:23:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <85acc922-2b76-3e52-1f77-c200949b0532@arm.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 31 Jul 2017 14:24:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 729 Lines: 16 On 31/07/2017 15:42, Marc Zyngier wrote: >> If the vcpu(me) exit due to request a usermode spinlock, then >> the spinlock-holder may be preempted in usermode or kernmode. >> But if the vcpu(me) is in kernmode, then the holder must be >> preempted in kernmode, so we should choose a vcpu in kernmode >> as the most eligible candidate. > > That seems to preclude any form of locking between userspace and kernel > (which probably wouldn't be Linux). Are you sure that this form of > construct is not used anywhere? I have the feeling this patch could > break this scenario... It's just a heuristic; it would only be broken if you overcommit, and it would be just as broken as if KVM didn't implement directed yield at all. Paolo