Received: by 10.223.176.5 with SMTP id f5csp874514wra; Fri, 9 Feb 2018 08:35:14 -0800 (PST) X-Google-Smtp-Source: AH8x2271a3btOoPU2vkuMQUkj0Tx6QPAN3kbcRmVQEqJR/xDOgqtanQjRGgJ6pJtE5ldWM5/NVL7 X-Received: by 10.99.102.1 with SMTP id a1mr2825006pgc.452.1518194114877; Fri, 09 Feb 2018 08:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518194114; cv=none; d=google.com; s=arc-20160816; b=LxmmvmMWcwUARsigXEXHNE3EP100ib9EX9JIy9yTq48s3QZ+kxLWAgOAkZ6ajeZ+YS 7WjxWwu4QWy1QkxDJOWJO3lahFMnTFvCHYbvNeMvshQ0PkLTCJEL3OdDwVjtkPA4fxkl op9dyRUugWcid5T5WKmwAIZ1MuNXajBcFqLTM1rFH+l+1SReErIQ4xnJK2yuDQwbi26B bUPmLqNK5n0/s0tCNsyYpRVfY8IKi23FhgUyVJs9iT3l0n6SVGBSip5jXP2nmVAixl8E 3985BOggRs2w7uuIi2BiBnT9jM57BHOB4E/q78ZKuNEerPGuarASNJ3XT14xZLuTiqIx 4tlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=3dm89Kwgpz6ewZkTx+a7ETUSVwrab/7pc45MlAAPoOM=; b=LxjxexGuyWjp4fqSCcCvtwVOJ6d+3Y6irkbuSzazGGoU4+jeqBLqMQRWGmpabRxSmx Jm1jXzeOcGbW8vFHIQw0668ffLTOCQiNkW6wJr7B9AQoqHCWKA4WJPuPEjiH2co1sI8o o5eyK32n+gvQAefITMQWJqCWkWs11Yt7aj8A1Pk33Mn7ZWSuhdzAVRiSbgBPE1nMVVGJ PMvDRlKxAYNEz/96Ni6ntLvai1AHShvMoSyJwcSU1R4dIi52NrYbvw9VV4k0bLPiFUmm DmR+Upf4V+XK6K/xBtKyGkqwnSyVGx9KvL74irpN2drYHGHzXwE+K4X7/mEtH5/ujMF2 6QRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44-v6si1772891plb.40.2018.02.09.08.35.00; Fri, 09 Feb 2018 08:35:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752192AbeBIQeU (ORCPT + 99 others); Fri, 9 Feb 2018 11:34:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40918 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbeBIQeT (ORCPT ); Fri, 9 Feb 2018 11:34:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28EA28B104; Fri, 9 Feb 2018 16:34:19 +0000 (UTC) Received: from localhost (ovpn-116-12.gru2.redhat.com [10.97.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id B12615D965; Fri, 9 Feb 2018 16:34:18 +0000 (UTC) Date: Fri, 9 Feb 2018 14:34:17 -0200 From: Eduardo Habkost To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v2 1/2] KVM: x86: Add dedicated vCPU hint KVM_HINTS_DEDICATED Message-ID: <20180209163417.GM13981@localhost.localdomain> References: <1518187673-70832-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1518187673-70832-1-git-send-email-wanpengli@tencent.com> X-Fnord: you can see the fnord User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 09 Feb 2018 16:34:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 09, 2018 at 06:47:52AM -0800, Wanpeng Li wrote: > From: Wanpeng Li > > Waiman Long mentioned that: > > 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 performance hint to allow hypervisor admin to choose > the qspinlock to be used when a dedicated pCPU is available. > > PV_DEDICATED = 1, PV_UNHALT = anything: default is qspinlock > PV_DEDICATED = 0, PV_UNHALT = 1: default is Hybrid PV queued/unfair lock > PV_DEDICATED = 0, PV_UNHALT = 0: default is tas > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Eduardo Habkost > Signed-off-by: Wanpeng Li > --- > v1 -> v2: > * update to KVM_HINTS_DEDICATED > > Documentation/virtual/kvm/cpuid.txt | 6 ++++++ > arch/x86/include/uapi/asm/kvm_para.h | 2 ++ > arch/x86/kernel/kvm.c | 6 ++++++ > 3 files changed, 14 insertions(+) > > diff --git a/Documentation/virtual/kvm/cpuid.txt b/Documentation/virtual/kvm/cpuid.txt > index 87a7506..d54cc79 100644 > --- a/Documentation/virtual/kvm/cpuid.txt > +++ b/Documentation/virtual/kvm/cpuid.txt > @@ -66,3 +66,9 @@ KVM_FEATURE_CLOCKSOURCE_STABLE_BIT || 24 || host will warn if no guest-side > || || per-cpu warps are expected in > || || kvmclock. > ------------------------------------------------------------------------------ > +KVM_HINTS_DEDICATED || 0 || guest checks this feature bit > + || || to determine if they run on > + || || dedicated vCPUs, allowing opti- > + || || mizations such as usage of > + || || qspinlocks. I assume you don't mean CPUID[0x40000001].EAX[bit 0] here, because it is already used for KVM_FEATURE_CLOCKSOURCE. I guess you will want a separate table for CPUID[0x40000001].EDX bits? > +------------------------------------------------------------------------------ > diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h > index 6cfa9c8..d65b16b 100644 > --- a/arch/x86/include/uapi/asm/kvm_para.h > +++ b/arch/x86/include/uapi/asm/kvm_para.h > @@ -28,6 +28,8 @@ > #define KVM_FEATURE_PV_TLB_FLUSH 9 > #define KVM_FEATURE_ASYNC_PF_VMEXIT 10 > > +#define KVM_HINTS_DEDICATED 0 > + > /* The last 8 bits are used to indicate how to interpret the flags field > * in pvclock structure. If no bits are set, all flags are ignored. > */ > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 971babe..7f4c92d 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -724,6 +724,12 @@ void __init kvm_spinlock_init(void) > { > if (!kvm_para_available()) > return; > + > + if (kvm_para_has_feature(KVM_HINTS_DEDICATED)) { This is checking CPUID{0x40000001].EAX[bit 0] (KVM_FEATURE_CLOCKSOURCE), isn't it? > + static_branch_disable(&virt_spin_lock_key); > + return; > + } > + > /* Does host kernel support KVM_FEATURE_PV_UNHALT? */ > if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) > return; > -- > 2.7.4 > -- Eduardo