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 330FFC433EF for ; Mon, 25 Oct 2021 14:35:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A17F60720 for ; Mon, 25 Oct 2021 14:35:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232801AbhJYOhW (ORCPT ); Mon, 25 Oct 2021 10:37:22 -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-Google-Smtp-Source: ABdhPJw1PVpqtFTaT+fZx+ngmF47w1xHlBRHe6pB6EMZ006WM53WXRFnHCfF7AOxx4PQB6o6e4saOQ== 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); 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 C324EC433F5 for ; Mon, 25 Oct 2021 14:35:13 +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 8AD7A60720 for ; Mon, 25 Oct 2021 14:35:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8AD7A60720 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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q0/tgo9oZ0R4ubCZGy07lZphxuWyfh/LNNMqSJo6L2o=; b=OTV2QBeTTiJFQG op4qx3a5yLsaM618LRz3QLgbZPDchZwfmy4HTv1I+UsvIYuLM3/AIbHnxJYRZALDChTNbYeuxRDYJ CTFw/xzeORGxkebjGKswKpVTKs1oEoolx/ZwcS7+mn0fZfBRtAXv6ff+XTR1P7DIniqXqK4Bq2125 0aGB4pSY7f7S4hzJjbEBV5h1Mk8GWXqhtyoZuu1H+Ctn3H0fUyrEuCxlEtEqQjKTgRaD6NjxDF8Se ReoSgjF/n3Vkwk5p2ouybZMnCnb2JRUtVxW2OiVoTCbDTEyl6XT7YUS6Mg9WQBQaNFQP00TlwgtsE KzdLwc2Vldx4jQ+GqxVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf141-00GiRJ-Ki; Mon, 25 Oct 2021 14:35:01 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf13y-00GiQ0-5J for linux-riscv@lists.infradead.org; Mon, 25 Oct 2021 14:34:59 +0000 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-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-WKlQVSmUP_K_gcCq2_cwEw-1; Mon, 25 Oct 2021 10:34:56 -0400 X-MC-Unique: WKlQVSmUP_K_gcCq2_cwEw-1 Received: by mail-ed1-f72.google.com with SMTP id c25-20020a056402143900b003dc19782ea8so10158363edx.3 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=CIDlaDt6EQtKSQCQUl8hs5TES3s2kebzgQlcjh8q4g6iXfWvVnKCe9ck4l/HfTgScz 3h2Mk48dapSSe9/wDJQuWFTqNGJB5jMHjut60Y47AEqx9eitZwWQQwVMULI6jgds68uO yOIdbDv3c9A6twRWJuCIhA1NmMwycCniF3vdou4CCk0rUmhl7VSCfiGAQnqTyeNGHAW8 VVEVWyXE9wd/hMBq0VKRQ3MIEi6bD0CiJdgqVLAI3IVbpJkJfRuBLNhICuf6qQKJF8FB YQw7TluluA8le/vlRl4UF7EnbMdxd0I/xDAS/POYO8yftcAM5jvOlE0PA9OMD66yjh5o ctcw== X-Gm-Message-State: AOAM532VKa0HOjZVKSS3RYxnGqmxOwVrMCBrluXka/6bhZgEnc1NiA8Q VtaPr/4ASJ4ALmG8eAFFBmyqWkY8UBXHU4shqVJhBz50sxUyYgvA4fpZM9H1XG20TuuAUIYrWI+ INhLIlZd6c3JXWbNhOtcoPESSS3D6 X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr26543462edd.101.1635172494815; Mon, 25 Oct 2021 07:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1PVpqtFTaT+fZx+ngmF47w1xHlBRHe6pB6EMZ006WM53WXRFnHCfF7AOxx4PQB6o6e4saOQ== 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" 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> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211025_073458_316231_94CD5B4C X-CRM114-Status: GOOD ( 12.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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); _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 CFDD2C433EF for ; Mon, 25 Oct 2021 14:35:03 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 495EC60F4F for ; Mon, 25 Oct 2021 14:35:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 495EC60F4F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C26C04B108; Mon, 25 Oct 2021 10:35:02 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QIqWqI+b9Jac; Mon, 25 Oct 2021 10:35:01 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0FBB44B0DF; Mon, 25 Oct 2021 10:35:01 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6F7264B0B8 for ; Mon, 25 Oct 2021 10:34:59 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C+b8NL2tJjbU for ; Mon, 25 Oct 2021 10:34:57 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E2287405A6 for ; Mon, 25 Oct 2021 10:34:57 -0400 (EDT) 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-567-Kt8_rBF5OzO0cyX1WeKU4Q-1; Mon, 25 Oct 2021 10:34:56 -0400 X-MC-Unique: Kt8_rBF5OzO0cyX1WeKU4Q-1 Received: by mail-ed1-f69.google.com with SMTP id z1-20020a05640235c100b003dcf0fbfbd8so10115959edc.6 for ; Mon, 25 Oct 2021 07:34:56 -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=BC00LvlOH4vzxocRKcJTwCNiXCC3bDJ4SoKCSwO2lTMBRukvRwarcxwPqrMZcLePVq tNjAVHNiG3FZo8sDPLHWD55gn+RD1MVJjgo20XYyHPC6BV7LzQc1rc5ne6Q1rX3+ck5q eKJoD0G4w5/Hgy/7dwRDUzX32bOlt6C7s9vzns6lgEtd1kzdoBSrb1a+Onzh0a1zkkYT F9VtEwQzjr0M3AE4wR3cLsOQyyxi0YiPqdnMLXqQsf2ceDTi4Cdl3C1Ar5HTUrpdhpE5 wL0VGmyRn0kJMybNEqXP8J+qsAZQv5K5ZAolUMdjG5iAM7g+ozRapPmyXKAuJkq5PMdU QqRg== X-Gm-Message-State: AOAM530eD8LHUjoA0z5ouhlkniRU7na8U0GbiOc6SUry9ja3iR0KTmX1 rjho+Z/lkshDEDss6LoYy1/+xgPBfwb5uiTCHTigY+JSJvM5HyTFRIAxqLPM5YiTHKP2pHrqJEh WjLxyXv/Lm0DTa8qP4lcPuTHf X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr26543457edd.101.1635172494814; Mon, 25 Oct 2021 07:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1PVpqtFTaT+fZx+ngmF47w1xHlBRHe6pB6EMZ006WM53WXRFnHCfF7AOxx4PQB6o6e4saOQ== 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" To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank 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> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Cc: Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-kernel@vger.kernel.org, Atish Patra , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Joerg Roedel , kvm-ppc@vger.kernel.org, David Matlack , linux-arm-kernel@lists.infradead.org, Jim Mattson , Cornelia Huck , linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, Vitaly Kuznetsov X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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); _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 806E5C433EF for ; Mon, 25 Oct 2021 14:36:21 +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 42C8B60EFF for ; Mon, 25 Oct 2021 14:36:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 42C8B60EFF 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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bXAL7Uk0R0h+/4TLDs21NUUeHsqwRsAY4F0qLo3enVo=; b=haSMcTMpVxzIjJ N3RrlHmxMxe7HZTssFOxAIlJ+2cw8VUJ6mVTkPEr20XvY8thBBtAaL6t8PJdtEA42G2Wlh4AfFiNb hLE4NHAX07fgPxxyBFtNAcHD8jOyO9rsRUsuwyhXF8otMxjS4Xjq73WRY46W3DOGE5x1Whc1fQF1R kvUs8NeTNLx0hU9odE/524QD+d+NMxFbI1vP9XkVj9faO/iY5nEPAcRYUdJakXBbBjKY2UjN271t0 Rp1aJEcQ0iA36gt/6M3YVhZrUNZuu6PhbQZgI1GkCLtxY4fk3p7awGcM6ELgN8cP3JUu87vaWKn2E zQYlqe1hX8FUl+xzjaYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf146-00GiSx-A6; Mon, 25 Oct 2021 14:35:06 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf13y-00GiQ3-7X for linux-arm-kernel@lists.infradead.org; Mon, 25 Oct 2021 14:34:59 +0000 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-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-LQSxQxzINHimrBPoRFoNfw-1; Mon, 25 Oct 2021 10:34:56 -0400 X-MC-Unique: LQSxQxzINHimrBPoRFoNfw-1 Received: by mail-ed1-f70.google.com with SMTP id f21-20020a0564021e9500b003dd77985601so787916edf.9 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=jdp8kIrQuOteDgfMq5u1ErVPsXzTNgOpTolIZHMCG6owPD4jBc6OXi6mmSZAD90043 MRnX7Y22dlRv0yjeXvx0crfW92UGxNaiw1mA6+Ga4AyJHS3mET3YPcsipnQrNc23Sqnz 0akrYEnv35xXQb1MfZWLDvHnmAb8UZrLN2ZsOLz46q5ty2BOL0rawJCZTwfnJw45LUKg lFJmJyaGhZ2k4lr8leu2JEYmS5tzxoJmXCu5RxJ2Lqpc2NGPp/ZtWr/avgXj7kZLx5iz 0wCnwTE81nlqODa2bhBgj0dNb9j3tUHf63ZgosC7vPgmqWxfeMnvIXEHPpE6UaQwTpWD x7+g== X-Gm-Message-State: AOAM532qSQT75rXjaPF+gVL2tptdvh1i8j5l17Z4EJ6qgDTDLtrAhuTr G04foFsHU3KrnhQUR6/zzV4JEKQK+VqhdXFmL2hpISID1aAz/+YbQMbUzHUdQxiyjD/3WvvuekL zDxN/dFO/Fx6IErYvqJeAleoNJZrfAkQuSVA= X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr26543477edd.101.1635172494830; Mon, 25 Oct 2021 07:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1PVpqtFTaT+fZx+ngmF47w1xHlBRHe6pB6EMZ006WM53WXRFnHCfF7AOxx4PQB6o6e4saOQ== 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" 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> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211025_073458_354874_E18CED4D X-CRM114-Status: GOOD ( 13.53 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Date: Mon, 25 Oct 2021 14:34:43 +0000 Subject: Re: [PATCH v2 39/43] KVM: VMX: Don't do full kick when triggering posted interrupt "fails" Message-Id: <335822ac-b98b-1eec-4911-34e4d0e99907@redhat.com> List-Id: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-40-seanjc@google.com> In-Reply-To: <20211009021236.4122790-40-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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);