Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4735174ioa; Wed, 27 Apr 2022 09:57:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyigp1WGJaN8hum/4DlIykcNzICT//ZWWGuz0xwN7v5HdsIcbpK5tAb7JOvSOKA7PwuVtoQ X-Received: by 2002:a17:90b:2252:b0:1d2:891d:b5e9 with SMTP id hk18-20020a17090b225200b001d2891db5e9mr45347309pjb.160.1651078677873; Wed, 27 Apr 2022 09:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651078677; cv=none; d=google.com; s=arc-20160816; b=JAz0tpV5/mfD3Pc/546o6vcWwHOGhQSy7kFVB/LAwqKGejIRDcbbxbaZY03UbmQqUZ sWLK8OeiYRe1075iNFLGpU9f6V7+Wepv3xbu4Y9m6sSnH1sy8djCONYu9z4SaSNmhj6K BcYdBZbq3UO0OjIoQ7LVLdmCQtTPeLfvM63bBXCl9ef+ebaQubu/aPdRdwXQjl1LO0a6 qkBHyWSA0FQqVGTS04vBo/RhEbHxPB5U89KyIC2oGRwbv+0eMyxwdqQ8XNX42N25uEEV DW6ES2oFGyjVhocqbIJ4EmbH0A6mrZPd+us5S7QslOCoMK6jfBfXmO29mxPZsfMjhjoF jFTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=0vtvSuzLYLcgoD95SpJhSmih26+GW1SKNz4Ydfjj5rE=; b=zBtacppO6lgd3rFphPe9kJBeVuaMnOkOdIxBtQuCo8a75Np0n0F7HCQDrYFo9m0yvB gKaS1I3g1NcHuV0DLtQuU2aHE2rYVWbYUaU2A2cMtuckuBS+NLJzVBr8efuwusOlTYH5 d+BIZ8GnoHfwHtAqCqgi+aUWZwsmQoRYGeDiWhQ6lG/ydlX23rb4DMIlj+karMbAGgDO Lpj7q8LWdH2JkMngRYDw0tjsPSNzo9tMBnHwhrYUvUoul7GOvadmZ+gtkatmLsDZ1EAw w+dw2tk+74e2ZD0p+a40tY+M5gXcPsEnbHTcyVCQg81w9U6oCJyqLG/BVkmOoonTQQXg hN7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fbPkNQy4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id be14-20020a656e4e000000b003816043f0dfsi2242208pgb.724.2022.04.27.09.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:57:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fbPkNQy4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6E7A57140; Wed, 27 Apr 2022 09:28:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242908AbiD0Q2d (ORCPT + 99 others); Wed, 27 Apr 2022 12:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242979AbiD0Q2I (ORCPT ); Wed, 27 Apr 2022 12:28:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EB3B436B47 for ; Wed, 27 Apr 2022 09:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651076550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0vtvSuzLYLcgoD95SpJhSmih26+GW1SKNz4Ydfjj5rE=; b=fbPkNQy4/sXURsFvC9WnUMkrbJ1/sUlfex7qXpJ9TBYD9jQ4ioaputyEUolBRPYrpG4Gfd K//tffAq3u6+2v+mLWZ+v/D58F6iAphFfibLRldoYFoXVse+FjhdN6GFzeMlL7QWhCKPsj M4na0zGvdaPhhLKSSAp3HUOut3xJri0= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-222-Hj0KTJwkP4-IGzzjIoxHPg-1; Wed, 27 Apr 2022 12:19:20 -0400 X-MC-Unique: Hj0KTJwkP4-IGzzjIoxHPg-1 Received: by mail-ej1-f69.google.com with SMTP id sa27-20020a1709076d1b00b006e8b357a2e7so1433688ejc.14 for ; Wed, 27 Apr 2022 09:19:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=0vtvSuzLYLcgoD95SpJhSmih26+GW1SKNz4Ydfjj5rE=; b=adYs8Nj8Ww5OKwa6RiyCfi7/t9vAMjv0Vnqd12S6Gx3YdgNa9vQUFn2dHeyS9Ls+cs ADAcWvmFSqvltEcOsLjqoS2+sc7RHHANBWDs3VK1PWwEq59UnBiPN/dM8vrkKDrffKnJ jmzY5ERP2QwcuE2TwUezZ7zLaQnl5Ykbh286xe4RpACBglzXXglsCQzKOTei8P1N/C4M KKU7mpgeaYfqPIT1HJnpBiEFSiRKvkUnrQWJRruIgm39QNUHYcmdNqESeWYX0qr1gjKh EmlzqMREghqIjf8YRb+lhPJpnwWpUgPKXDOQoZXKRET+bnA0clYQsujk/87Q56F8Fp++ zWIA== X-Gm-Message-State: AOAM532JY0QDekptzG6AumhhJTtHfoiIGqlrxHJQNcc3xfuLyWmDHm+w tnnEUMmIjb5DcZ7CjA1WsW1jAggrP3mJaqsXNTGq6Za47dd0uVqcCGgorG/z/hdcDhZGHvDIKX8 /mdTPvNeyKOIdQ80+SeL9tfvm X-Received: by 2002:a17:906:2709:b0:6f0:13d5:d58f with SMTP id z9-20020a170906270900b006f013d5d58fmr27200707ejc.443.1651076359510; Wed, 27 Apr 2022 09:19:19 -0700 (PDT) X-Received: by 2002:a17:906:2709:b0:6f0:13d5:d58f with SMTP id z9-20020a170906270900b006f013d5d58fmr27200676ejc.443.1651076359238; Wed, 27 Apr 2022 09:19:19 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:1c09:f536:3de6:228c? ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.googlemail.com with ESMTPSA id mf1-20020a1709071a4100b006f39f556011sm3841382ejc.125.2022.04.27.09.19.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 09:19:17 -0700 (PDT) Message-ID: <37137ef4-c2db-44a2-9ed3-1d9ab8bad9f8@redhat.com> Date: Wed, 27 Apr 2022 18:19:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH MANUALSEL 5.10 4/4] KVM: LAPIC: Enable timer posted-interrupt only when mwait/hlt is advertised Content-Language: en-US To: Sasha Levin , linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wanpeng Li , Aili Yao , Sean Christopherson , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, kvm@vger.kernel.org References: <20220427155435.19554-1-sashal@kernel.org> <20220427155435.19554-4-sashal@kernel.org> From: Paolo Bonzini In-Reply-To: <20220427155435.19554-4-sashal@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 On 4/27/22 17:54, Sasha Levin wrote: > From: Wanpeng Li > > [ Upstream commit 1714a4eb6fb0cb79f182873cd011a8ed60ac65e8 ] > > As commit 0c5f81dad46 ("KVM: LAPIC: Inject timer interrupt via posted > interrupt") mentioned that the host admin should well tune the guest > setup, so that vCPUs are placed on isolated pCPUs, and with several pCPUs > surplus for *busy* housekeeping. In this setup, it is preferrable to > disable mwait/hlt/pause vmexits to keep the vCPUs in non-root mode. > > However, if only some guests isolated and others not, they would not > have any benefit from posted timer interrupts, and at the same time lose > VMX preemption timer fast paths because kvm_can_post_timer_interrupt() > returns true and therefore forces kvm_can_use_hv_timer() to false. > > By guaranteeing that posted-interrupt timer is only used if MWAIT or > HLT are done without vmexit, KVM can make a better choice and use the > VMX preemption timer and the corresponding fast paths. > > Reported-by: Aili Yao > Reviewed-by: Sean Christopherson > Cc: Aili Yao > Cc: Sean Christopherson > Signed-off-by: Wanpeng Li > Message-Id: <1643112538-36743-1-git-send-email-wanpengli@tencent.com> > Signed-off-by: Paolo Bonzini > Signed-off-by: Sasha Levin > --- > arch/x86/kvm/lapic.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index e45ebf0870b6..a3ef793fce5f 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -113,7 +113,8 @@ static inline u32 kvm_x2apic_id(struct kvm_lapic *apic) > > static bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu) > { > - return pi_inject_timer && kvm_vcpu_apicv_active(vcpu); > + return pi_inject_timer && kvm_vcpu_apicv_active(vcpu) && > + (kvm_mwait_in_guest(vcpu->kvm) || kvm_hlt_in_guest(vcpu->kvm)); > } > > bool kvm_can_use_hv_timer(struct kvm_vcpu *vcpu) Acked-by: Paolo Bonzini