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 37B40C433EF for ; Sun, 31 Oct 2021 22:52:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1962460E78 for ; Sun, 31 Oct 2021 22:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbhJaWyi (ORCPT ); Sun, 31 Oct 2021 18:54:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23041 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbhJaWyg (ORCPT ); Sun, 31 Oct 2021 18:54:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635720723; 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=dQzBTZB2neuQYMfndsZa2+3/XGXbUkUJliSXmv07Tbg=; b=TewOPruTUwM2k0xjQHDskCDRHUq6yLeFDZgV2emtnflNAZlnNeuc5bGcI/vCBBu54IWtgk 0CPU8en6ErBnXCC8c5UKQh/v7MG+VS6RIJm1AdmtqOHYJLFugS15F2BPrORuJTuQ8zz7RA 8lyAGEpBKLMBoK9J2g2HJUp5tu2TSQg= 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-479-8bdx3_mDPHG0BFe5kWTFcQ-1; Sun, 31 Oct 2021 18:52:00 -0400 X-MC-Unique: 8bdx3_mDPHG0BFe5kWTFcQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE91391272; Sun, 31 Oct 2021 22:51:56 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DE0810023AB; Sun, 31 Oct 2021 22:51:41 +0000 (UTC) Message-ID: <432666f36add6647283631770f1b140656c67c62.camel@redhat.com> Subject: Re: [PATCH v2 27/43] KVM: VMX: Move Posted Interrupt ndst computation out of write loop From: Maxim Levitsky To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini , 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: Mon, 01 Nov 2021 00:51:39 +0200 In-Reply-To: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-28-seanjc@google.com> <643d9c249b5863f04290a6f047ea1a2d98bd75f9.camel@redhat.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.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-10-28 at 16:12 +0000, Sean Christopherson wrote: > On Thu, Oct 28, 2021, Maxim Levitsky wrote: > > On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > > > Hoist the CPU => APIC ID conversion for the Posted Interrupt descriptor > > > out of the loop to write the descriptor, preemption is disabled so the > > > CPU won't change, and if the APIC ID changes KVM has bigger problems. > > > > > > No functional change intended. > > > > Is preemption always disabled in vmx_vcpu_pi_load? vmx_vcpu_pi_load is called > > from vmx_vcpu_load, which is called indirectly from vcpu_load which is called > > from many ioctls, which userspace does. In these places I don't think that > > preemption is disabled. > > Preemption is disabled in vcpu_load() by the get_cpu(). The "cpu" param that's > passed around the vcpu_load() stack is also why I think it's ok to _not_ assert > that preemption is disabled in vmx_vcpu_pi_load(); if preemption is enabled, > "cpu" is unstable and thus the entire "load" operation is busted. Yes, I even knew about the get_cpu() behavier which indeed has to disable preemption. But I didn't notice call to it, when I wrote this mail! Later I did notice it but it was too late. Sometimes sending all the review mails at once at the end does make sense after all, I guess. Best regards, Maxim Levitsky > > > #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) > #define put_cpu() preempt_enable() > > > void vcpu_load(struct kvm_vcpu *vcpu) > { > int cpu = get_cpu(); > > __this_cpu_write(kvm_running_vcpu, vcpu); > preempt_notifier_register(&vcpu->preempt_notifier); > kvm_arch_vcpu_load(vcpu, cpu); > put_cpu(); > } > EXPORT_SYMBOL_GPL(vcpu_load); > 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 0D003C433F5 for ; Sun, 31 Oct 2021 22:52:26 +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 C0EFD60E78 for ; Sun, 31 Oct 2021 22:52:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C0EFD60E78 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=pk1uauHKlLMUPRrfsxRmE0GlYUF3koWE9KYG3SF57ME=; b=yOG9oqXn28M6HW VjOUF03od2AjjaaCnOCtTBFA0gU7xzMyIUp0jknJfZOibEcqmmRJNv4V60sMuBUUZLD9dbs1KJ+oi PuJJdaCr26JvtlRom+2pjPPSN8ZnWaBKxvD1MIz0CxEx7jdYHn4kR5apwELxfiwqXVW00240SFf8I Vp1w/SagtFHmcwniIe8I6Zq+mAmGPWYgSjTcqPNiPnZHFJf5pszlSYWdAHbRvsiGicxrNUce0Vlr5 lFTQ8T1aj0b7S5xlOGGvFL4HmtMmiV0YEfxpOeOeY9R5/sh70i+vLx9MrQfqJgcnS+m3xiwdINd9h XN5hJA8l4lxbHoa4fOaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhJgZ-00ErOj-6V; Sun, 31 Oct 2021 22:52:19 +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 1mhJgK-00ErL8-Uf for linux-riscv@lists.infradead.org; Sun, 31 Oct 2021 22:52:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635720723; 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=dQzBTZB2neuQYMfndsZa2+3/XGXbUkUJliSXmv07Tbg=; b=TewOPruTUwM2k0xjQHDskCDRHUq6yLeFDZgV2emtnflNAZlnNeuc5bGcI/vCBBu54IWtgk 0CPU8en6ErBnXCC8c5UKQh/v7MG+VS6RIJm1AdmtqOHYJLFugS15F2BPrORuJTuQ8zz7RA 8lyAGEpBKLMBoK9J2g2HJUp5tu2TSQg= 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-479-8bdx3_mDPHG0BFe5kWTFcQ-1; Sun, 31 Oct 2021 18:52:00 -0400 X-MC-Unique: 8bdx3_mDPHG0BFe5kWTFcQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE91391272; Sun, 31 Oct 2021 22:51:56 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DE0810023AB; Sun, 31 Oct 2021 22:51:41 +0000 (UTC) Message-ID: <432666f36add6647283631770f1b140656c67c62.camel@redhat.com> Subject: Re: [PATCH v2 27/43] KVM: VMX: Move Posted Interrupt ndst computation out of write loop From: Maxim Levitsky To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini , 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: Mon, 01 Nov 2021 00:51:39 +0200 In-Reply-To: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-28-seanjc@google.com> <643d9c249b5863f04290a6f047ea1a2d98bd75f9.camel@redhat.com> User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211031_155205_131561_BD536D5F X-CRM114-Status: GOOD ( 18.27 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Thu, 2021-10-28 at 16:12 +0000, Sean Christopherson wrote: > On Thu, Oct 28, 2021, Maxim Levitsky wrote: > > On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > > > Hoist the CPU => APIC ID conversion for the Posted Interrupt descriptor > > > out of the loop to write the descriptor, preemption is disabled so the > > > CPU won't change, and if the APIC ID changes KVM has bigger problems. > > > > > > No functional change intended. > > > > Is preemption always disabled in vmx_vcpu_pi_load? vmx_vcpu_pi_load is called > > from vmx_vcpu_load, which is called indirectly from vcpu_load which is called > > from many ioctls, which userspace does. In these places I don't think that > > preemption is disabled. > > Preemption is disabled in vcpu_load() by the get_cpu(). The "cpu" param that's > passed around the vcpu_load() stack is also why I think it's ok to _not_ assert > that preemption is disabled in vmx_vcpu_pi_load(); if preemption is enabled, > "cpu" is unstable and thus the entire "load" operation is busted. Yes, I even knew about the get_cpu() behavier which indeed has to disable preemption. But I didn't notice call to it, when I wrote this mail! Later I did notice it but it was too late. Sometimes sending all the review mails at once at the end does make sense after all, I guess. Best regards, Maxim Levitsky > > > #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) > #define put_cpu() preempt_enable() > > > void vcpu_load(struct kvm_vcpu *vcpu) > { > int cpu = get_cpu(); > > __this_cpu_write(kvm_running_vcpu, vcpu); > preempt_notifier_register(&vcpu->preempt_notifier); > kvm_arch_vcpu_load(vcpu, cpu); > put_cpu(); > } > EXPORT_SYMBOL_GPL(vcpu_load); > _______________________________________________ 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 9949BC433F5 for ; Sun, 31 Oct 2021 22:53:42 +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 5FFF160E78 for ; Sun, 31 Oct 2021 22:53:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5FFF160E78 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=vFNFuzUNjUELAKDv5H9xnJmaAi5Nx+JzHaJGTutoi2I=; b=X8ur41m2w1MaW0 0HbEG+7By+V4hdOx3qgu1oh1WnBKpDwZv60yt8ba4ltZybgqz+oPHDScq0Vp0rabzExGvMt2a1bB4 2bmxqVrDPrYfRTQhsd4UnqxoghbklNSNud7qKbsh6ez9F4xP0lha5noQSIrESRQM/Sql2pLvq+ws4 wD/1H5Jw2XOYc5UHhrvoC/nIz+NG5fteUsHUacXnH3RWZcUcGT68kjEDF+DvK225BBmBpily0Q5Ho h856c2TxGQJbpex5x66MyOhJ4YOCy2WAA6tQLJWynS6fyQf1NKgmIYItN1tQ680u+pikJ9fc/NCOl pxvihO8pAPaQJHLZijug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhJgO-00ErMk-PH; Sun, 31 Oct 2021 22:52:09 +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 1mhJgK-00ErL9-Ue for linux-arm-kernel@lists.infradead.org; Sun, 31 Oct 2021 22:52:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635720723; 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=dQzBTZB2neuQYMfndsZa2+3/XGXbUkUJliSXmv07Tbg=; b=TewOPruTUwM2k0xjQHDskCDRHUq6yLeFDZgV2emtnflNAZlnNeuc5bGcI/vCBBu54IWtgk 0CPU8en6ErBnXCC8c5UKQh/v7MG+VS6RIJm1AdmtqOHYJLFugS15F2BPrORuJTuQ8zz7RA 8lyAGEpBKLMBoK9J2g2HJUp5tu2TSQg= 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-479-8bdx3_mDPHG0BFe5kWTFcQ-1; Sun, 31 Oct 2021 18:52:00 -0400 X-MC-Unique: 8bdx3_mDPHG0BFe5kWTFcQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE91391272; Sun, 31 Oct 2021 22:51:56 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DE0810023AB; Sun, 31 Oct 2021 22:51:41 +0000 (UTC) Message-ID: <432666f36add6647283631770f1b140656c67c62.camel@redhat.com> Subject: Re: [PATCH v2 27/43] KVM: VMX: Move Posted Interrupt ndst computation out of write loop From: Maxim Levitsky To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini , 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: Mon, 01 Nov 2021 00:51:39 +0200 In-Reply-To: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-28-seanjc@google.com> <643d9c249b5863f04290a6f047ea1a2d98bd75f9.camel@redhat.com> User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211031_155205_130804_329C914B X-CRM114-Status: GOOD ( 19.18 ) 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 Thu, 2021-10-28 at 16:12 +0000, Sean Christopherson wrote: > On Thu, Oct 28, 2021, Maxim Levitsky wrote: > > On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > > > Hoist the CPU => APIC ID conversion for the Posted Interrupt descriptor > > > out of the loop to write the descriptor, preemption is disabled so the > > > CPU won't change, and if the APIC ID changes KVM has bigger problems. > > > > > > No functional change intended. > > > > Is preemption always disabled in vmx_vcpu_pi_load? vmx_vcpu_pi_load is called > > from vmx_vcpu_load, which is called indirectly from vcpu_load which is called > > from many ioctls, which userspace does. In these places I don't think that > > preemption is disabled. > > Preemption is disabled in vcpu_load() by the get_cpu(). The "cpu" param that's > passed around the vcpu_load() stack is also why I think it's ok to _not_ assert > that preemption is disabled in vmx_vcpu_pi_load(); if preemption is enabled, > "cpu" is unstable and thus the entire "load" operation is busted. Yes, I even knew about the get_cpu() behavier which indeed has to disable preemption. But I didn't notice call to it, when I wrote this mail! Later I did notice it but it was too late. Sometimes sending all the review mails at once at the end does make sense after all, I guess. Best regards, Maxim Levitsky > > > #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) > #define put_cpu() preempt_enable() > > > void vcpu_load(struct kvm_vcpu *vcpu) > { > int cpu = get_cpu(); > > __this_cpu_write(kvm_running_vcpu, vcpu); > preempt_notifier_register(&vcpu->preempt_notifier); > kvm_arch_vcpu_load(vcpu, cpu); > put_cpu(); > } > EXPORT_SYMBOL_GPL(vcpu_load); > _______________________________________________ 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 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 B86DAC433EF for ; Mon, 1 Nov 2021 21:40:26 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 65C8060F36 for ; Mon, 1 Nov 2021 21:40:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 65C8060F36 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 1802F4B235; Mon, 1 Nov 2021 17:40:26 -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 pvtcVWl1tepp; Mon, 1 Nov 2021 17:40:24 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 82B244B26B; Mon, 1 Nov 2021 17:40:14 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 160094B12C for ; Sun, 31 Oct 2021 18:52:05 -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 fxFOXlD9d4x6 for ; Sun, 31 Oct 2021 18:52:03 -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 DADAA4B129 for ; Sun, 31 Oct 2021 18:52:03 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635720723; 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=dQzBTZB2neuQYMfndsZa2+3/XGXbUkUJliSXmv07Tbg=; b=TewOPruTUwM2k0xjQHDskCDRHUq6yLeFDZgV2emtnflNAZlnNeuc5bGcI/vCBBu54IWtgk 0CPU8en6ErBnXCC8c5UKQh/v7MG+VS6RIJm1AdmtqOHYJLFugS15F2BPrORuJTuQ8zz7RA 8lyAGEpBKLMBoK9J2g2HJUp5tu2TSQg= 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-479-8bdx3_mDPHG0BFe5kWTFcQ-1; Sun, 31 Oct 2021 18:52:00 -0400 X-MC-Unique: 8bdx3_mDPHG0BFe5kWTFcQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE91391272; Sun, 31 Oct 2021 22:51:56 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DE0810023AB; Sun, 31 Oct 2021 22:51:41 +0000 (UTC) Message-ID: <432666f36add6647283631770f1b140656c67c62.camel@redhat.com> Subject: Re: [PATCH v2 27/43] KVM: VMX: Move Posted Interrupt ndst computation out of write loop From: Maxim Levitsky To: Sean Christopherson Date: Mon, 01 Nov 2021 00:51:39 +0200 In-Reply-To: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-28-seanjc@google.com> <643d9c249b5863f04290a6f047ea1a2d98bd75f9.camel@redhat.com> User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mailman-Approved-At: Mon, 01 Nov 2021 17:40:12 -0400 Cc: Cornelia Huck , Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-kernel@vger.kernel.org, Paul Mackerras , Atish Patra , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Janosch Frank , Marc Zyngier , Joerg Roedel , Huacai Chen , Christian Borntraeger , Aleksandar Markovic , Albert Ou , kvm-ppc@vger.kernel.org, Paul Walmsley , David Matlack , linux-arm-kernel@lists.infradead.org, Jim Mattson , Anup Patel , linux-mips@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Paolo Bonzini , 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thu, 2021-10-28 at 16:12 +0000, Sean Christopherson wrote: > On Thu, Oct 28, 2021, Maxim Levitsky wrote: > > On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > > > Hoist the CPU => APIC ID conversion for the Posted Interrupt descriptor > > > out of the loop to write the descriptor, preemption is disabled so the > > > CPU won't change, and if the APIC ID changes KVM has bigger problems. > > > > > > No functional change intended. > > > > Is preemption always disabled in vmx_vcpu_pi_load? vmx_vcpu_pi_load is called > > from vmx_vcpu_load, which is called indirectly from vcpu_load which is called > > from many ioctls, which userspace does. In these places I don't think that > > preemption is disabled. > > Preemption is disabled in vcpu_load() by the get_cpu(). The "cpu" param that's > passed around the vcpu_load() stack is also why I think it's ok to _not_ assert > that preemption is disabled in vmx_vcpu_pi_load(); if preemption is enabled, > "cpu" is unstable and thus the entire "load" operation is busted. Yes, I even knew about the get_cpu() behavier which indeed has to disable preemption. But I didn't notice call to it, when I wrote this mail! Later I did notice it but it was too late. Sometimes sending all the review mails at once at the end does make sense after all, I guess. Best regards, Maxim Levitsky > > > #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) > #define put_cpu() preempt_enable() > > > void vcpu_load(struct kvm_vcpu *vcpu) > { > int cpu = get_cpu(); > > __this_cpu_write(kvm_running_vcpu, vcpu); > preempt_notifier_register(&vcpu->preempt_notifier); > kvm_arch_vcpu_load(vcpu, cpu); > put_cpu(); > } > EXPORT_SYMBOL_GPL(vcpu_load); > _______________________________________________ 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 From: Maxim Levitsky Date: Sun, 31 Oct 2021 22:51:39 +0000 Subject: Re: [PATCH v2 27/43] KVM: VMX: Move Posted Interrupt ndst computation out of write loop Message-Id: <432666f36add6647283631770f1b140656c67c62.camel@redhat.com> List-Id: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-28-seanjc@google.com> <643d9c249b5863f04290a6f047ea1a2d98bd75f9.camel@redhat.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini , 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 Thu, 2021-10-28 at 16:12 +0000, Sean Christopherson wrote: > On Thu, Oct 28, 2021, Maxim Levitsky wrote: > > On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > > > Hoist the CPU => APIC ID conversion for the Posted Interrupt descriptor > > > out of the loop to write the descriptor, preemption is disabled so the > > > CPU won't change, and if the APIC ID changes KVM has bigger problems. > > > > > > No functional change intended. > > > > Is preemption always disabled in vmx_vcpu_pi_load? vmx_vcpu_pi_load is called > > from vmx_vcpu_load, which is called indirectly from vcpu_load which is called > > from many ioctls, which userspace does. In these places I don't think that > > preemption is disabled. > > Preemption is disabled in vcpu_load() by the get_cpu(). The "cpu" param that's > passed around the vcpu_load() stack is also why I think it's ok to _not_ assert > that preemption is disabled in vmx_vcpu_pi_load(); if preemption is enabled, > "cpu" is unstable and thus the entire "load" operation is busted. Yes, I even knew about the get_cpu() behavier which indeed has to disable preemption. But I didn't notice call to it, when I wrote this mail! Later I did notice it but it was too late. Sometimes sending all the review mails at once at the end does make sense after all, I guess. Best regards, Maxim Levitsky > > > #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) > #define put_cpu() preempt_enable() > > > void vcpu_load(struct kvm_vcpu *vcpu) > { > int cpu = get_cpu(); > > __this_cpu_write(kvm_running_vcpu, vcpu); > preempt_notifier_register(&vcpu->preempt_notifier); > kvm_arch_vcpu_load(vcpu, cpu); > put_cpu(); > } > EXPORT_SYMBOL_GPL(vcpu_load); >