Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1360081pxb; Thu, 28 Oct 2021 02:14:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynrLlQF07YId9zxfkQR4HRSAiz2TgUfCDIEMM7/VJTvHHYqiwUqRmdcQIBuMvgIeuCD/We X-Received: by 2002:a17:90b:4f90:: with SMTP id qe16mr3260674pjb.137.1635412447889; Thu, 28 Oct 2021 02:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635412447; cv=none; d=google.com; s=arc-20160816; b=iO2MXUyTJIMAY7UnuRnXqHU6XdSYWuQqzuER2rYZIyo9StlCOeUz2Ijh0CZTASkUaq OINqeFlZ96vyN1LeahTD313b3l9t/aVE8xPoJjNMAqoTNeAb7oOlYSHd6SpVJyGjlTkK kgvFlW1EyPYsTXpa8cJvrO9OQ7Kkp4MFeDaOJps22IrYW2jOKWiuw3Ba+cxFgO5NePnr VAX81tqEaL/AahjVNod9of8guSFjZVGJAWZaCe5L5bnkX9C3S/2oxTk/rUxW4ozQzWAz pedUDV4Wqgt029ABlCoc6urvwmgu8ymaHvdyoqLK1EBL+QyC/mXsK9BMIdQdYVy2k3sO nHtg== 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:date:cc:to:from:subject :message-id:dkim-signature; bh=l1MWdjra8eZcIIlx8zcoZvMR0jtyOa/xjrbhOVDWvpc=; b=Cprw3FzAtGj9WdNwAEtgBOqA9q2ygZ3HmHu/3kDuIhJPX7iJwglCPpx2WHApxRPyKy CdDNZLpgyGQTwkfgdQ27ZLajdsRXdkrQXi2ugP5u9fYcmj38H/Hq06z/Z1HRKAMo//rK MP0hxjgxPKI4UBp6ubCncfeFmBxeXZ5/Fy88i0T2p1H/Z+a8y/n3LAzCnR5WLBupGDBW qY9Yn2ACvQejOwnDTsWYpzQOmz2wT9SPOnaYgWuilUjLHdurqzbp5kNvnjnZCcdYDu5x aaybnQGNtSbu/s/CSagg0tiU33G6a2U/1MpIjQWNFOpli+DNGXE5JNaSLoVrP9cSn5x/ +paQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="V8a5sB/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si2907937plt.43.2021.10.28.02.13.47; Thu, 28 Oct 2021 02:14:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="V8a5sB/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230071AbhJ1JPN (ORCPT + 99 others); Thu, 28 Oct 2021 05:15:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46088 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhJ1JPM (ORCPT ); Thu, 28 Oct 2021 05:15:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635412365; 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=l1MWdjra8eZcIIlx8zcoZvMR0jtyOa/xjrbhOVDWvpc=; b=V8a5sB/JvhD+0u4HLs9/Gr4edBOkIui2t+oyYZ+cghAw1/Hq+cteD509Ue0t6KHzCrKos1 AvzI4TWIaZMeP6iqW752YJpFgc+s5aKgU/hZW7zD+K9mMcqiD7IaI6vy/9BE7HO+/W9a1P 7SF9adeb3+GF2wTxqMq838l1SVnw/G8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-547-sp4eSFtgN52tnt6kECXjIQ-1; Thu, 28 Oct 2021 05:12:40 -0400 X-MC-Unique: sp4eSFtgN52tnt6kECXjIQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE71D1966321; Thu, 28 Oct 2021 09:12:36 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4625A5F707; Thu, 28 Oct 2021 09:12:15 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 20/43] KVM: VMX: Skip Posted Interrupt updates if APICv is hard disabled From: Maxim Levitsky To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , Oliver Upton , Jing Zhang Date: Thu, 28 Oct 2021 12:12:13 +0300 In-Reply-To: <20211009021236.4122790-21-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-21-seanjc@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > Explicitly skip posted interrupt updates if APICv is disabled in all of > KVM, or if the guest doesn't have an in-kernel APIC. The PI descriptor > is kept up-to-date if APICv is inhibited, e.g. so that re-enabling APICv > doesn't require a bunch of updates, but neither the module param nor the > APIC type can be changed on-the-fly. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/posted_intr.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c > index 3263056784f5..351666c41bbc 100644 > --- a/arch/x86/kvm/vmx/posted_intr.c > +++ b/arch/x86/kvm/vmx/posted_intr.c > @@ -28,11 +28,14 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) > unsigned int dest; > > /* > - * In case of hot-plug or hot-unplug, we may have to undo > - * vmx_vcpu_pi_put even if there is no assigned device. And we > - * always keep PI.NDST up to date for simplicity: it makes the > - * code easier, and CPU migration is not a fast path. > + * To simplify hot-plug and dynamic toggling of APICv, keep PI.NDST and > + * PI.SN up-to-date even if there is no assigned device or if APICv is > + * deactivated due to a dynamic inhibit bit, e.g. for Hyper-V's SyncIC. > */ > + if (!enable_apicv || !lapic_in_kernel(vcpu)) > + return; > + > + /* Nothing to do if PI.SN==0 and the vCPU isn't being migrated. */ > if (!pi_test_sn(pi_desc) && vcpu->cpu == cpu) > return; > Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky