From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 928EDC433F5 for ; Sun, 31 Oct 2021 14:52:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57B8C60E9C for ; Sun, 31 Oct 2021 14:52:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 57B8C60E9C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZcYu9jlVDYCKJcmFU533QRiaHMRvjTNIlOApJge/DkM=; b=aKD4O2CodTLqi3 7EIAa2FRkdanM3WTL246bdpBZUBsUCQ+YjcdBVOJtCQOIIA3mKP5Rq6hOL8XA8VAidZRYKvf5tbVr se1SxtQYlknoE2yO/ayekfDwQeeGambYqI9XaCzMx6s6uoNqmFwzpUqcurg8dNOECJj+szJzbw73/ 6dr2yWOEH9wQ1AnoXxxBy5ixuDfmV991lw36USGwrE7RXYOHVeSp6IB8KuHTQX65F3QbNpb5NwAKe zfVIwLDM2u8YZYKRIf92LbKiI68q3BDl4b/5RgvdtZ7cwBqV3MZ/Jp9IQLkW+Fua3U55sW/naWppD Uunyg13cpiO6FqRRnPXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhCBD-00EENn-Mg; Sun, 31 Oct 2021 14:51:27 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhCB9-00EELV-CO for linux-arm-kernel@lists.infradead.org; Sun, 31 Oct 2021 14:51:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635691880; 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=JWkqObtzatE8ZqTA7P0n9xOaXL3kRPYh9u09IqRGd+c=; b=Wupjguvd8R9WYamN/ILzDHXO5MTmIeCRjNILg5ocIEPI4et7KJIazkzXFE8Oq1FmrR9zU0 4eUXab+q099MTToOMkMdDuiCVc7eLToNwzqSlUHvz0U/Q8vlDrfjaVgrZFjSCDQ1pwkP3l vUPUeRzRtZTk5FlzakcPMiPr/pS7B5U= 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-595-hgIuyZhQNzuaYxdMVVu2jQ-1; Sun, 31 Oct 2021 10:51:14 -0400 X-MC-Unique: hgIuyZhQNzuaYxdMVVu2jQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C08418D6A25; Sun, 31 Oct 2021 14:51:10 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 885E65F4E9; Sun, 31 Oct 2021 14:50:40 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 36/43] KVM: SVM: Don't bother checking for "running" AVIC when kicking for IPIs 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: Sun, 31 Oct 2021 16:50:39 +0200 In-Reply-To: <20211009021236.4122790-37-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-37-seanjc@google.com> User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211031_075123_558848_E2F1E5D6 X-CRM114-Status: GOOD ( 26.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > Drop the avic_vcpu_is_running() check when waking vCPUs in response to a > VM-Exit due to incomplete IPI delivery. The check isn't wrong per se, but > it's not 100% accurate in the sense that it doesn't guarantee that the vCPU > was one of the vCPUs that didn't receive the IPI. > > The check isn't required for correctness as blocking == !running in this > context. > > From a performance perspective, waking a live task is not expensive as the > only moderately costly operation is a locked operation to temporarily > disable preemption. And if that is indeed a performance issue, > kvm_vcpu_is_blocking() would be a better check than poking into the AVIC. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/svm/avic.c | 15 +++++++++------ > arch/x86/kvm/svm/svm.h | 11 ----------- > 2 files changed, 9 insertions(+), 17 deletions(-) > > diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c > index cbf02e7e20d0..b43b05610ade 100644 > --- a/arch/x86/kvm/svm/avic.c > +++ b/arch/x86/kvm/svm/avic.c > @@ -295,13 +295,16 @@ static void avic_kick_target_vcpus(struct kvm *kvm, struct kvm_lapic *source, > struct kvm_vcpu *vcpu; > int i; > > + /* > + * Wake any target vCPUs that are blocking, i.e. waiting for a wake > + * event. There's no need to signal doorbells, as hardware has handled > + * vCPUs that were in guest at the time of the IPI, and vCPUs that have > + * since entered the guest will have processed pending IRQs at VMRUN. > + */ > kvm_for_each_vcpu(i, vcpu, kvm) { > - bool m = kvm_apic_match_dest(vcpu, source, > - icrl & APIC_SHORT_MASK, > - GET_APIC_DEST_FIELD(icrh), > - icrl & APIC_DEST_MASK); > - > - if (m && !avic_vcpu_is_running(vcpu)) > + if (kvm_apic_match_dest(vcpu, source, icrl & APIC_SHORT_MASK, > + GET_APIC_DEST_FIELD(icrh), > + icrl & APIC_DEST_MASK)) > kvm_vcpu_wake_up(vcpu); > } > } > diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h > index 0d7bbe548ac3..7f5b01bbee29 100644 > --- a/arch/x86/kvm/svm/svm.h > +++ b/arch/x86/kvm/svm/svm.h > @@ -509,17 +509,6 @@ extern struct kvm_x86_nested_ops svm_nested_ops; > > #define VMCB_AVIC_APIC_BAR_MASK 0xFFFFFFFFFF000ULL > > -static inline bool (struct kvm_vcpu *vcpu) > -{ > - struct vcpu_svm *svm = to_svm(vcpu); > - u64 *entry = svm->avic_physical_id_cache; > - > - if (!entry) > - return false; > - > - return (READ_ONCE(*entry) & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK); > -} > - > int avic_ga_log_notifier(u32 ga_tag); > void avic_vm_destroy(struct kvm *kvm); > int avic_vm_init(struct kvm *kvm); I guess this makes sense to do, to get rid of the avic_vcpu_is_running. As you explained in previous patch, waking up a live task isn't that expensive, so let it be. Reviewed-by: Maxim Levitsky Best regards, Maxim Levitsky _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel