Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3124178pxp; Mon, 14 Mar 2022 11:19:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvVUz+v/qgC7/ukRHomoZzXxi3seyrAkzjENbyJ+UFdOpIk1VeV2gGZ3q8BtE2xXAOZoh0 X-Received: by 2002:a17:907:da1:b0:6db:8e8e:a04 with SMTP id go33-20020a1709070da100b006db8e8e0a04mr16352795ejc.285.1647281983543; Mon, 14 Mar 2022 11:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647281983; cv=none; d=google.com; s=arc-20160816; b=0vzJmFGHYA59B7LhSkOZVyrq5G4z3ia9dbhbIiAe2Oi3ifkgcdpeILEm8wtBEDf09i sU3OMjreBlt/YRIzXMulomNsDVVFSzvI4gRfbLrwU6pCehKLnIDVD+2JL+PC3EVwFcmm lbK3m4lPPbsWSdG/pb1LUtYzxy1kzCb5pEJUwy9WVaLvubfKf6uZYFQ/hEtDqPRblR8z 7GTt+Fqi7new78Cb8F/oPiMTsBGZFaiidpqIax+QJiVYwyPgt3GKozpuc4ay6QFiL7kh URStu4Qi7lKo66RL2qaC4F4aODKn+9nOBZTpKAoCAnejsML6lCGnBIcM0zfjEKyHiAEz Ta1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ucqQWDHE7ZobaR52stvWP9HDn30EfaNXp4OD50OQi5Q=; b=Y84KlP7xJHJzFJE4SAuPUtsiu5ITipVHfzajT2SwnFhLCrKaQhHh6EuDAnrbExH1/N VAnzS4064IJS4UGcwa1lubZjyYv7ih+hmoDXTvqDRW6yeyqS91iNYG9qRX1XYFm1EoWq kcm3UHWI3qVhnF0jYR8WFAWPhpgFRPd60HtlmTl6GxGrp340/yJMklIVrOp5wBkPVrlz pwfckouPu6znEmiBCWXrFqpBGNKMP0QLDPMs61FLmmo1elZLGSu+RU/zPHtyPs1TnzNx x9XtDPcHUDDzPXscYf/NveuPNcmkXpYpnxKq/8dnTGyRtPesKsTOml27cHMe68aDjrgx ifAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fBBH+dOY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020aa7cb87000000b00412d5ff5f19si9289084edt.436.2022.03.14.11.19.17; Mon, 14 Mar 2022 11:19:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fBBH+dOY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242213AbiCNMSv (ORCPT + 99 others); Mon, 14 Mar 2022 08:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242385AbiCNMJz (ORCPT ); Mon, 14 Mar 2022 08:09:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD1A39F; Mon, 14 Mar 2022 05:07:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 95BCEB80CDE; Mon, 14 Mar 2022 12:07:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FDA2C340E9; Mon, 14 Mar 2022 12:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259664; bh=Y9KlIpkBRHEF52Fy9TTBs0ebsuplB+fl+zs/LguYyZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBBH+dOYRTDM9SX2ZZMvjDZ2aT31Ld1rz324LH/usCNnLmFXgJrZO1qhQYIPpvrCr AxOM7bY0X9rchjGL88pFk9tibh4Vdri1BvvWE3NrNr1DPL0LlxPukPuWmjg1uJXnh/ i0dp4jIj99mL7vD6iUc3mBHs9ahqnhkbPyr5bpaI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wanpeng Li , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.15 061/110] x86/kvm: Dont use pv tlb/ipi/sched_yield if on 1 vCPU Date: Mon, 14 Mar 2022 12:54:03 +0100 Message-Id: <20220314112744.738007397@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112743.029192918@linuxfoundation.org> References: <20220314112743.029192918@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li [ Upstream commit ec756e40e271866f951d77c5e923d8deb6002b15 ] Inspired by commit 3553ae5690a (x86/kvm: Don't use pvqspinlock code if only 1 vCPU), on a VM with only 1 vCPU, there is no need to enable pv tlb/ipi/sched_yield and we can save the memory for __pv_cpu_mask. Signed-off-by: Wanpeng Li Message-Id: <1645171838-2855-1-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kernel/kvm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index b656456c3a94..811c7aaf23aa 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -457,19 +457,22 @@ static bool pv_tlb_flush_supported(void) { return (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && !kvm_para_has_hint(KVM_HINTS_REALTIME) && - kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)); + kvm_para_has_feature(KVM_FEATURE_STEAL_TIME) && + (num_possible_cpus() != 1)); } static bool pv_ipi_supported(void) { - return kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI); + return (kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI) && + (num_possible_cpus() != 1)); } static bool pv_sched_yield_supported(void) { return (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) && !kvm_para_has_hint(KVM_HINTS_REALTIME) && - kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)); + kvm_para_has_feature(KVM_FEATURE_STEAL_TIME) && + (num_possible_cpus() != 1)); } #define KVM_IPI_CLUSTER_SIZE (2 * BITS_PER_LONG) -- 2.34.1