Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3514937pxp; Mon, 14 Mar 2022 23:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzP4fNseTnduKdTnxQ47IY+oaK5UvU4dH+Xwrv3/FX40c1mPvVl0xGQhIi2R9Y5xB0+/D6K X-Received: by 2002:a17:906:5597:b0:6ce:f3cc:14e8 with SMTP id y23-20020a170906559700b006cef3cc14e8mr21472014ejp.426.1647324756975; Mon, 14 Mar 2022 23:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647324756; cv=none; d=google.com; s=arc-20160816; b=qXqWP+9ux1tTWGDUh7c5T+XvT22NBZjZei+Qm7yLV8fD17RTpKwPtcftMKsA5ljxka EF6yqMTJLEHlFIxlrKgjgaodDQ4oatQTX7cBQXTmB+DSJcIsCwilRaxpreWZdID31YH8 3tD+gxbBKud5Uy2Y1Iv2Fn53ovypv0l8C3QMrHjmr+j+ZwQoS08fKJNprZpYj0vF75Xm hjjuXvKJK1Gw+42uHP8GmiFZJmSsUsFOubv1tWHsveIG3Q19wT34SF63futJExVZRs1O hrZQI3R8LbH4VHSHhyGhhHuge4ftUX+bFzuSoUrRBHHHLJ6OSOmj/MSliRCrk7ePGHaq 0wqQ== 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=rE8a4nkCFHhuTHDxsfWvi7Cc0fbH6pwhtWwof0++BVU=; b=RujrvngJiueKRSvt8eGqBAbUojdnBpYRkIqYK1YqQezHCQ+6JPsMVyezlC2rbjuJMq IcVifxOeHDsat4tBE2m72uSNy7MnmEOykhhAuJk7moh3Aho7eNbx9MjJRB3kBvtnTwkB NbC/0zco79/OT+GFssfWXzs2g2QWgFmTrcCwthmc+BLIZyzcOu1skPZK7ZCC5B5sWFGD dzkjigh3i4hbMu1KM8MKhQib2+jhxgUawgCA5SNr3OI8D78GjrTvXxkz0osYTV7WHjc+ ArCyLd8czb9X4HegqgDYsR/2fEDEU/vaJ4uUzxzRfus4ifAJtm1KrbYtNwN8upW0V04X /a8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q6JZWC94; 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 p11-20020a50c94b000000b004162991fe46si10236698edh.418.2022.03.14.23.12.12; Mon, 14 Mar 2022 23:12:36 -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=Q6JZWC94; 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 S245140AbiCNMcq (ORCPT + 99 others); Mon, 14 Mar 2022 08:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243926AbiCNMVY (ORCPT ); Mon, 14 Mar 2022 08:21:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75B2713CE1; Mon, 14 Mar 2022 05:18:27 -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 2AECCB80DF2; Mon, 14 Mar 2022 12:18:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A82EFC340ED; Mon, 14 Mar 2022 12:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647260304; bh=5+Ft8NqKxW8P9GQwxVhJpiNyjBI1KpvTOwGzitr6tus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6JZWC94C6eeUGXfk1b/DJBMIN0ksZ8cC9vR09lhXJDtTHEnH0N6x1jLVe1+f4PK7 kovJqKA7AZ/ZxTtoi5LoQ1Ze9VRxz1M0lE5K5f+btdYO22Vm6cdA1whVBoVS5DXtzj mp8+vqjyt7PkO1i1rFjS3Htv+Y6fRYL0WlcP37ss= 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.16 070/121] x86/kvm: Dont use pv tlb/ipi/sched_yield if on 1 vCPU Date: Mon, 14 Mar 2022 12:54:13 +0100 Message-Id: <20220314112746.077423912@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@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 59abbdad7729..ff3db164e52c 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -462,19 +462,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