From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752883AbdHGKp5 (ORCPT ); Mon, 7 Aug 2017 06:45:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35174 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752785AbdHGKp4 (ORCPT ); Mon, 7 Aug 2017 06:45:56 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D519461480 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH 2/3] KVM: X86: implement the logic for spinlock optimization To: "Longpeng(Mike)" , rkrcmar@redhat.com Cc: agraf@suse.com, borntraeger@de.ibm.com, cohuck@redhat.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, 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, david@redhat.com References: <1502095466-21312-1-git-send-email-longpeng2@huawei.com> <1502095466-21312-3-git-send-email-longpeng2@huawei.com> From: Paolo Bonzini Message-ID: Date: Mon, 7 Aug 2017 12:45:45 +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: <1502095466-21312-3-git-send-email-longpeng2@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 07 Aug 2017 10:45:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/08/2017 10:44, Longpeng(Mike) wrote: > + > + /* > + * Intel sdm vol3 ch-25.1.3 says: The “PAUSE-loop exiting” > + * VM-execution control is ignored if CPL > 0. So the vcpu > + * is always exiting with CPL=0 if it uses PLE. This is not true (how can it be?). What 25.1.3 says is, the VCPU is always at CPL=0 if you get a PAUSE exit (reason 40) and PAUSE exiting is 0 (it always is for KVM). But here you're looking for a VCPU that didn't get a PAUSE exit, so the CPL can certainly be 3. However, I understand that vmx_get_cpl can be a bit slow here. You can actually read SS's access rights directly in this function and get the DPL from there, that's going to be just a single VMREAD. The only difference is when vmx->rmode.vm86_active=1. However, pause-loop exiting is not working properly anyway if vmx->rmode.vm86_active=1, because CPL=3 according to the processor. Paolo > + * The following block needs less cycles than vmx_get_cpl(). > + */ > + if (cpu_has_secondary_exec_ctrls()) > + secondary_exec_ctrl = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); > + if (secondary_exec_ctrl & SECONDARY_EXEC_PAUSE_LOOP_EXITING) > + return true; > + Paolo