From patchwork Sat Feb 11 14:06:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 13137085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08B75C636CC for ; Sat, 11 Feb 2023 14:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbjBKOGq (ORCPT ); Sat, 11 Feb 2023 09:06:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjBKOGp (ORCPT ); Sat, 11 Feb 2023 09:06:45 -0500 Received: from njjs-sys-mailin01.njjs.baidu.com (mx316.baidu.com [180.101.52.236]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3EFA025B91 for ; Sat, 11 Feb 2023 06:06:42 -0800 (PST) Received: from localhost (bjhw-sys-rpm015653cc5.bjhw.baidu.com [10.227.53.39]) by njjs-sys-mailin01.njjs.baidu.com (Postfix) with ESMTP id B26417F00043; Sat, 11 Feb 2023 22:06:39 +0800 (CST) From: lirongqing@baidu.com To: pbonzini@redhat.com, wanpengli@tencent.com, vkuznets@redhat.com, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH] x86/kvm: Don't use PVspinlock when mwait is advertised Date: Sat, 11 Feb 2023 22:06:39 +0800 Message-Id: <1676124399-16542-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Li RongQing MWAIT is advertised in host is not overcommitted scenario, however, pvspinlock should be enabled in host overcommitted scenario. Let's add the MWAIT checking when enabling pvspinlock Signed-off-by: Li RongQing --- arch/x86/kernel/kvm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 1cceac5..dfa1451 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -1087,6 +1087,11 @@ void __init kvm_spinlock_init(void) goto out; } + if (boot_cpu_has(X86_FEATURE_MWAIT)) { + pr_info("PV spinlocks disabled with mwait\n"); + goto out; + } + if (num_possible_cpus() == 1) { pr_info("PV spinlocks disabled, single CPU\n"); goto out;