Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1419664pxb; Thu, 28 Oct 2021 03:23:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyECwrcbCdddKOTaqEZZR49+u+bmFHXut5/K7ez73xHNXvhqsEwZKJtYk0/oIn9P8YKb1A0 X-Received: by 2002:a05:6402:35d6:: with SMTP id z22mr5015687edc.93.1635416601653; Thu, 28 Oct 2021 03:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635416601; cv=none; d=google.com; s=arc-20160816; b=OLmwxmdPTW5Oudpf9Rzfvh1LLB/7hridWZnNLEpKFfmz0vhSbv6jy2BoJQ3QrTRXRO zGNYmkEEutz0GatYXZlVZBH1ELgzMj6ddvkWs0ddANiPbuyaWsUWBHMnl18i3hi1S90q +WnFx49tUYvh9Z1tKLdGSLTs2tf6gQF2pNuWwzsMCOAxkdlBbush/DrU942HZJwZuXeY XCMoHl5/hkQfheEwDVEqmU5J0hvTnW+krAqkAh6WanqArKJB5bEB3yMAf5/uz/d+FE8u kZJXdolaSBIhk2nnBbS2EtNfiWQfe1c/mDc+/zxWiO2/YUY3GIjOaTMWAp2w9bDdIKJW UBFA== 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=WNjfMGWJgQRyrsFW4O+8W6gSms2YGqJfs44+x3miEeo=; b=yMr2zt3SiOnkXsKO+0aDpW8A3VqHwy3xdgyrPgyLPQfexI1hbfcyiEFEuUHdnlS7aU bGwY8iNFvAiAZvrj/HX46/++VZKbR+EDfyCCTcsvwAP8N9JrJGIHiVIWtNG71HSFrFTj 1li6mhjxvUeKWJQvQUwnsmewiK84s+vYbPAXYxeFfyvOqVoVy6617u2o4GgMt5hFKf33 lNbPhzEpuVA/aIPG5YKqp6RkoPziMnJDbJWS5TRi0dIkCG4mbArZhl8PCGhYNQlRS6P4 eVw8tfAuIayItSaq3kJak4Kank3A/X4hGRIMGCX3aoZ4/0resQZHyDZHUeUTrdcFQxzf yMqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PYZXtyiT; 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 k3si3353282edk.215.2021.10.28.03.22.57; Thu, 28 Oct 2021 03:23:21 -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=PYZXtyiT; 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 S230111AbhJ1KXg (ORCPT + 99 others); Thu, 28 Oct 2021 06:23:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41723 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbhJ1KXf (ORCPT ); Thu, 28 Oct 2021 06:23:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635416468; 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=WNjfMGWJgQRyrsFW4O+8W6gSms2YGqJfs44+x3miEeo=; b=PYZXtyiTVQwdozDtRgnJY94yy4J4g9dVa4tsm7JzVPygADKddabVVwx6Zg6yojE74PJYzS G2Zr35RoUyK866e+nP+LBedWF+tyz4oulJ1WW/IG1IIYmxs0wiXEfxMVGKxhA9e+IMFemT lUCvO53j0lwMoUZAWiyLL35Ur3oM2eg= 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-268-0q32FwVmMIWh3L38BGVE8w-1; Thu, 28 Oct 2021 06:21:05 -0400 X-MC-Unique: 0q32FwVmMIWh3L38BGVE8w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F27B7802682; Thu, 28 Oct 2021 10:21:00 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id B194417CE1; Thu, 28 Oct 2021 10:20:21 +0000 (UTC) Message-ID: <6b2bdfad87e268e861b6cc331d25790dade8e27b.camel@redhat.com> Subject: Re: [PATCH v2 21/43] KVM: VMX: Clean up PI pre/post-block WARNs 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 13:20:20 +0300 In-Reply-To: <20211009021236.4122790-22-seanjc@google.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-22-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.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > Move the WARN sanity checks out of the PI descriptor update loop so as > not to spam the kernel log if the condition is violated and the update > takes multiple attempts due to another writer. This also eliminates a > few extra uops from the retry path. > > Technically not checking every attempt could mean KVM will now fail to > WARN in a scenario that would have failed before, but any such failure > would be inherently racy as some other agent (CPU or device) would have > to concurrent modify the PI descriptor. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/posted_intr.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c > index 351666c41bbc..67cbe6ab8f66 100644 > --- a/arch/x86/kvm/vmx/posted_intr.c > +++ b/arch/x86/kvm/vmx/posted_intr.c > @@ -100,10 +100,11 @@ static void __pi_post_block(struct kvm_vcpu *vcpu) > struct pi_desc old, new; > unsigned int dest; > > + WARN(pi_desc->nv != POSTED_INTR_WAKEUP_VECTOR, > + "Wakeup handler not enabled while the vCPU was blocking"); > + > do { > old.control = new.control = pi_desc->control; > - WARN(old.nv != POSTED_INTR_WAKEUP_VECTOR, > - "Wakeup handler not enabled while the VCPU is blocked\n"); > > dest = cpu_physical_id(vcpu->cpu); > > @@ -161,13 +162,12 @@ int pi_pre_block(struct kvm_vcpu *vcpu) > spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu)); > } > > + WARN(pi_desc->sn == 1, > + "Posted Interrupt Suppress Notification set before blocking"); > + > do { > old.control = new.control = pi_desc->control; > > - WARN((pi_desc->sn == 1), > - "Warning: SN field of posted-interrupts " > - "is set before blocking\n"); > - > /* > * Since vCPU can be preempted during this process, > * vcpu->cpu could be different with pre_pcpu, we Don't know for sure if this is desired. I'll would just use WARN_ON_ONCE instead if the warning spams the log. If there is a race I would rather want to catch it even if rare. Best regards, Maxim Levitsky