Received: by 10.223.176.5 with SMTP id f5csp404849wra; Thu, 1 Feb 2018 23:13:32 -0800 (PST) X-Google-Smtp-Source: AH8x224jVAHJPT5JERD8jNGIKWB9bzV470GLZczGIlYXyl889eM5X6JlpRlh/5idaV/5D1PVAoVF X-Received: by 10.99.161.26 with SMTP id b26mr22363075pgf.322.1517555612571; Thu, 01 Feb 2018 23:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517555612; cv=none; d=google.com; s=arc-20160816; b=eJWrkUNOBZ9ofJ1o2XXSd1Pq1PXBP02HDOZ4Ts9a0Dmiir0gPI0/mrmyoTdsKbZA+k lYn4ESTLukOMqBuWwPWDwQ9bbzBboaoVy49qo2K4UBLNmfJawhTAMlBlRDKrpT6+hTqE wnJvAdAzwq939cgwl7k06RjqGEsaWTRlPps51FNwWkhU4x96qE0NsJTIZsmPOUhkyclm wl3czfvjtZuoEZRcpXb5tT2WNwW47ezaipPndKSuutXy+goOP6GVb6KbmZiZFlvKkD4m WurUjjw9HVhYrbLpGNE05+B1vWFmil3ggW4W2eVhdeX/2YKqTsdcbI3T5FalZe9NrqWV iE4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Mm1rvJoZTLFkIhv3iczdDApZf+VgKUA7tHj5GpOHT54=; b=oiJ3DzxCEQ/4AKEbf+wF8Rsp9ZkiZf/I1p0tOgwdJRhlIZKwsXYP9P4JJPoLlr9sWr gpk2vMFiK60h4bagC9x43Q0XwdfjfgmSADoRHjfGqESeJQU8asQq4WtLNAFjPyqky7mu IXNqu9uEbXd12G3YKq2pNFQewfBiyNWHj08N1oG76OF0kF5UgFV+gWfepAmote6Ut7Oe P3NGApEUsHtFFstmk1+t3UCTss3JjIMbJEm/XSnlIK8QNna8/0aOrbSssaMdisp9zwFC OUXqExymS8Frp2kOrfCmEp84zpt1T7LKBt+WqEZnqnEdDbzxR7tfrGxsf2+0NP9MCSZ9 Prmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ine/U2l9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 90-v6si1252863pla.214.2018.02.01.23.13.17; Thu, 01 Feb 2018 23:13:32 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ine/U2l9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751742AbeBBHM0 (ORCPT + 99 others); Fri, 2 Feb 2018 02:12:26 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:39901 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751567AbeBBHMG (ORCPT ); Fri, 2 Feb 2018 02:12:06 -0500 Received: by mail-pl0-f68.google.com with SMTP id o13so5508835pli.6; Thu, 01 Feb 2018 23:12:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mm1rvJoZTLFkIhv3iczdDApZf+VgKUA7tHj5GpOHT54=; b=Ine/U2l9vmOyGPq4cJ+/Dz1NjFbxrLazwBAOKvu/KbV5X5hD+ghP6EmNKxTzo4ir+D 9pS9Z/KoaFhig4K3BIm82g2dklQsa3GSh9vWzTD4hWZkveHgaPX6d1BQv6mfW8eYiAso 9hdom0hehjndwCtW7UwWaTFOylf1go+P4kq4WlFuXg7oh0GCQYtULsDxUspmhHttpwm1 JT81sPv2qoX4dLfnQD+jrYW/v6hp1BflR2/7UodRjT1ORKnt/Kt0JAdFUy+/wv851qOZ 24NNWtPVJiFsfpqLK3AY4sN4zZEzrRbO96KCVXWhfySg5NzgUFKXLjucEZkJqxBs7AQn xt0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mm1rvJoZTLFkIhv3iczdDApZf+VgKUA7tHj5GpOHT54=; b=szxh3xD2bnpSqCth62ujgXaLJBV8zOCGuFLAphNO2wj7lsVl//PYP7e6qtJuEHcKAC j1ICs1TtUBQRJSkx4fzjQ4+ubNTCu1/Mq7ylhuiF8cbW1IsLj8L3NHc0tWg/AACxiTbK DBKCr9PP20aI633ORJcHBNCbK6JRLrq3SN1ja81pA6e/iFGiCxxNvaeutNI31J8P1+bU IiV/a1BuSNbtJshas+O0F1pMPKZGpefpyOWl5325huTS/bFA6CQJzEWEBeXRwvlerKdm RvR9TxWFeSWpe+Cr+dftm+IPBf70U0i8yOyC9yDzMGjRfwMXdNPXxmdD+hEgh0oBDWd6 qEYw== X-Gm-Message-State: AKwxytc4q8wbGN7IFGKqtsyGipzFnTHAQnBuiKAQyj13XR117rEtWp1y smu7p9IUjDU4geJ/mGdOgMrWgg== X-Received: by 2002:a17:902:9a97:: with SMTP id w23-v6mr34915239plp.100.1517555525206; Thu, 01 Feb 2018 23:12:05 -0800 (PST) Received: from localhost.localdomain ([203.205.141.123]) by smtp.googlemail.com with ESMTPSA id z5sm2297389pfi.81.2018.02.01.23.12.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Feb 2018 23:12:04 -0800 (PST) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH 1/2] KVM: X86: Add dedicated pCPU hint PV_DEDICATED Date: Thu, 1 Feb 2018 23:11:12 -0800 Message-Id: <1517555473-8313-2-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517555473-8313-1-git-send-email-wanpengli@tencent.com> References: <1517555473-8313-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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ář Signed-off-by: Wanpeng Li --- Documentation/virtual/kvm/cpuid.txt | 6 ++++++ arch/x86/include/uapi/asm/kvm_para.h | 1 + arch/x86/kernel/kvm.c | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/Documentation/virtual/kvm/cpuid.txt b/Documentation/virtual/kvm/cpuid.txt index 87a7506..c0740b1 100644 --- a/Documentation/virtual/kvm/cpuid.txt +++ b/Documentation/virtual/kvm/cpuid.txt @@ -54,6 +54,12 @@ KVM_FEATURE_PV_UNHALT || 7 || guest checks this feature bit || || before enabling paravirtualized || || spinlock support. ------------------------------------------------------------------------------ +KVM_FEATURE_PV_DEDICATED || 8 || guest checks this feature bit + || || to determine if they run on + || || dedicated vCPUs, allowing opti- + || || mizations such as usage of + || || qspinlocks. +------------------------------------------------------------------------------ KVM_FEATURE_PV_TLB_FLUSH || 9 || guest checks this feature bit || || before enabling paravirtualized || || tlb flush. diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h index 6cfa9c8..9a5ef67 100644 --- a/arch/x86/include/uapi/asm/kvm_para.h +++ b/arch/x86/include/uapi/asm/kvm_para.h @@ -25,6 +25,7 @@ #define KVM_FEATURE_STEAL_TIME 5 #define KVM_FEATURE_PV_EOI 6 #define KVM_FEATURE_PV_UNHALT 7 +#define KVM_FEATURE_PV_DEDICATED 8 #define KVM_FEATURE_PV_TLB_FLUSH 9 #define KVM_FEATURE_ASYNC_PF_VMEXIT 10 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index aa2b706..6f0e43f 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -726,6 +726,12 @@ void __init kvm_spinlock_init(void) { if (!kvm_para_available()) return; + + if (kvm_para_has_feature(KVM_FEATURE_PV_DEDICATED)) { + 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