Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp252369pxb; Mon, 25 Oct 2021 07:39:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZsoyV6KezkG7zLt1JT+k8k1RhBb4R+7q5IO2SS9NfOhXDM2lEqrapHRCuVPW5P0Tauqz4 X-Received: by 2002:a17:90b:316:: with SMTP id ay22mr21682413pjb.114.1635172794164; Mon, 25 Oct 2021 07:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635172794; cv=none; d=google.com; s=arc-20160816; b=RRz/xSxRWfQvLRLbOuUXUDIGhKZcb7pwOGLkOpEkmRRhVEavk/408+VCCGF7hmK8Kj w/HgkkySZNTrMfQj7ANEiCCK653cJSprOVk4bJtj/EkeWUxQSul6oow55qTPKpR5cib2 2iGMk4ZjAyYI2sbl/NbhD58KzgUlrUCYH53ixZafPBUiAckD/wuqDS9XW5HrjNLf3KO7 +T9rB1qmebWfcWaDOFV2XOKEe86CUwUYIZNrPg7oJdrowk+UdBLheRTBIm4Rh5cBCxqx mj1Om672xftg1EQa0f+IsUzdw7/V+EH41L1JPNU8tQaHHKFsPZ7tgWbEVXEiy2biK3Ig v+Mw== 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=gyRr+oxbdq+D1XVZyshzBJhdWV6eJMpRCL2oDxsSBbM=; b=pyBqFjHl2mjX7SHU9aQIcE9VPrRss1PDeG7zjr0uaRiuoIT9/UpFwOgn3PzRmV5U3l acMts9dGwJO5jiSSEvDs2TuFZjMvT3eJI3jf1lqfkrmDI5T5KcCrvRkARt2UikZyGtBS NYvKxDyVfLmYjElQsQupt/xBnncblAuPnUi3LcK9RrtwuXdTpIdoiZEbP4XIMo6053nd 0MdMVNEDhJPY+bw9b7VZOJ+01dZN1vePJ4LezLldLNSOgokYmSwszjDX8Qw6ijqGTij3 F7UgWv5gxtPV9WLwEkQ4E4B9PV2khtwdYO3TJIJEFXK+huH/Lo8GHKNrbCtQcyKCrgYs jBcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SQBkGLBa; 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 q75si696080pgq.127.2021.10.25.07.39.41; Mon, 25 Oct 2021 07:39:54 -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=SQBkGLBa; 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 S230137AbhJYOhV (ORCPT + 99 others); Mon, 25 Oct 2021 10:37:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60540 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbhJYOhT (ORCPT ); Mon, 25 Oct 2021 10:37:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635172497; 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=gyRr+oxbdq+D1XVZyshzBJhdWV6eJMpRCL2oDxsSBbM=; b=SQBkGLBaOxog2hLaf6YXCS+UY/ndEWjokIqxk8Ws8KqvyTEE0Co3Z7LtBTIp697U1HlcgV DbTijGyr0ZSgkptCt4zGUrPXkUOcf8Ijn+i1BCLw8Bp7+I2iJW+Lhv0qI9q2PEV85OkVUT aMLTaFhNymZBkzU0xhx83l44CfHd3SE= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-ok9sdCwdNvuhTZv0VwuFRQ-1; Mon, 25 Oct 2021 10:34:56 -0400 X-MC-Unique: ok9sdCwdNvuhTZv0VwuFRQ-1 Received: by mail-ed1-f69.google.com with SMTP id k28-20020a508adc000000b003dd5e21da4bso2480445edk.11 for ; Mon, 25 Oct 2021 07:34:55 -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=gyRr+oxbdq+D1XVZyshzBJhdWV6eJMpRCL2oDxsSBbM=; b=yMpRwl3d8dgigHUArVjytcYgPU22ufM86mI9yDuasDT6DDDHNkijj2Ork/Lgzp0HP0 EZdVb0zDXeX4tu+NoEx2CE8MizO0ki62b+bT+IP2uyZ1LpCPg5yuZYr/o7lTG1ue17bp KOYSz2ek70mCZ0bi1tHCm1/VhYT83C1wjBtyDPqqurR5etu9zQ4QQnAat4MT7rpwG6Qv UE5G4Ln0sZIhy7E4xv24AI+t71Xyxy+LNLykbeBn53YIzbMMxGNI0kc4cPAr3ybcqrM+ Zke63NZLgVd157QfB8+1dKlr0o1Xm5QjqEBaxzkY+qkpYQS2VWGq1A+GEHvkJ1EiuaMx VwoA== X-Gm-Message-State: AOAM531eNJXN3stNfdpL1IkisRoNeIMWQsc0FYuY44cnx4yog3YLVyRh HrIPGphr+jbD8v7V85Nau9dbpIyL0U4w0tWPn0C26ivs3R0YAHxd1XjtMMjSszktviXhKeTLER+ +1CTN83mEM59NIY0KmRsqtCvI X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr26543456edd.101.1635172494807; Mon, 25 Oct 2021 07:34:54 -0700 (PDT) X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr26543421edd.101.1635172494578; Mon, 25 Oct 2021 07:34:54 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id m15sm10124432edd.5.2021.10.25.07.34.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Oct 2021 07:34:53 -0700 (PDT) Message-ID: <335822ac-b98b-1eec-4911-34e4d0e99907@redhat.com> Date: Mon, 25 Oct 2021 16:34:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v2 39/43] KVM: VMX: Don't do full kick when triggering posted interrupt "fails" Content-Language: en-US To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank 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 References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-40-seanjc@google.com> From: Paolo Bonzini In-Reply-To: <20211009021236.4122790-40-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10/21 04:12, Sean Christopherson wrote: > + /* > + * The smp_wmb() in kvm_make_request() pairs with the smp_mb_*() > + * after setting vcpu->mode in vcpu_enter_guest(), thus the vCPU > + * is guaranteed to see the event request if triggering a posted > + * interrupt "fails" because vcpu->mode != IN_GUEST_MODE. This explanation doesn't make much sense to me. This is just the usual request/kick pattern explained in Documentation/virt/kvm/vcpu-requests.rst; except that we don't bother with a "kick" out of guest mode because the entry always goes through kvm_check_request (in the nVMX case) or sync_pir_to_irr (if non-nested) and completes the delivery itself. In other word, it is a similar idea as patch 43/43. What this smp_wmb() pair with, is the smp_mb__after_atomic in kvm_check_request(KVM_REQ_EVENT, vcpu). Setting the interrupt in the PIR orders before kvm_make_request in this thread, and orders after kvm_make_request in the vCPU thread. Here, instead: > + /* > + * The implied barrier in pi_test_and_set_on() pairs with the smp_mb_*() > + * after setting vcpu->mode in vcpu_enter_guest(), thus the vCPU is > + * guaranteed to see PID.ON=1 and sync the PIR to IRR if triggering a > + * posted interrupt "fails" because vcpu->mode != IN_GUEST_MODE. > + */ > if (vcpu != kvm_get_running_vcpu() && > !kvm_vcpu_trigger_posted_interrupt(vcpu, false)) > - kvm_vcpu_kick(vcpu); > + kvm_vcpu_wake_up(vcpu); > it pairs with the smp_mb__after_atomic in vmx_sync_pir_to_irr(). As explained again in vcpu-requests.rst, the ON bit has the same function as vcpu->request in the previous case. Paolo > + */ > kvm_make_request(KVM_REQ_EVENT, vcpu);