From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754931AbdKAQ27 convert rfc822-to-8bit (ORCPT ); Wed, 1 Nov 2017 12:28:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46524 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752363AbdKAQ25 (ORCPT ); Wed, 1 Nov 2017 12:28:57 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 98C76C0587C5 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=longman@redhat.com Subject: Re: [PATCH] x86/paravirt: Add kernel parameter to choose paravirt lock type To: Juergen Gross , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Jonathan Corbet Cc: x86@kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Alok Kataria , Rusty Russell , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Boris Ostrovsky , Peter Zijlstra References: <1509550367-19255-1-git-send-email-longman@redhat.com> <404a9fab-03ff-174e-4ece-79932a6f302c@suse.com> From: Waiman Long Organization: Red Hat Message-ID: <409ede92-5243-0d9b-7893-b596f3f353aa@redhat.com> Date: Wed, 1 Nov 2017 12:28:54 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <404a9fab-03ff-174e-4ece-79932a6f302c@suse.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 01 Nov 2017 16:28:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/01/2017 11:51 AM, Juergen Gross wrote: > On 01/11/17 16:32, Waiman Long wrote: >> Currently, there are 3 different lock types that can be chosen for >> the x86 architecture: >> >> - qspinlock >> - pvqspinlock >> - unfair lock >> >> One of the above lock types will be chosen at boot time depending on >> a number of different factors. >> >> Ideally, the hypervisors should be able to pick the best performing >> lock type for the current VM configuration. That is not currently >> the case as the performance of each lock type are affected by many >> different factors like the number of vCPUs in the VM, the amount vCPU >> overcommitment, the CPU type and so on. >> >> Generally speaking, unfair lock performs well for VMs with a small >> number of vCPUs. Native qspinlock may perform better than pvqspinlock >> if there is vCPU pinning and there is no vCPU over-commitment. >> >> This patch adds a new kernel parameter to allow administrator to >> choose the paravirt spinlock type to be used. VM administrators can >> experiment with the different lock types and choose one that can best >> suit their need, if they want to. Hypervisor developers can also use >> that to experiment with different lock types so that they can come >> up with a better algorithm to pick the best lock type. >> >> The hypervisor paravirt spinlock code will override this new parameter >> in determining if pvqspinlock should be used. The parameter, however, >> will override Xen's xen_nopvspin in term of disabling unfair lock. > Hmm, I'm not sure we need pvlock_type _and_ xen_nopvspin. What do others > think? I don't think we need xen_nopvspin, but I don't want to remove that without agreement from the community. >> DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key); >> >> void __init native_pv_lock_init(void) >> { >> - if (!static_cpu_has(X86_FEATURE_HYPERVISOR)) >> + if (pv_spinlock_type == locktype_unfair) >> + return; >> + >> + if (!static_cpu_has(X86_FEATURE_HYPERVISOR) || >> + (pv_spinlock_type != locktype_auto)) >> static_branch_disable(&virt_spin_lock_key); > Really? I don't think locktype_paravirt should disable the static key. With paravirt spinlock, it doesn't matter if the static key is disabled or not. Without CONFIG_PARAVIRT_SPINLOCKS, however, it does degenerate into the native qspinlock. So you are right, I should check for paravirt type as well. Cheers, Longman