Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2431070pxb; Sun, 31 Oct 2021 15:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfHGFcq3ouOmDW+ieDeVaisR21P/HAiGtAgZacxc45w4KJGPIsg2oH84dIncZnKFaglhZD X-Received: by 2002:a05:6638:2107:: with SMTP id n7mr81579jaj.70.1635720919434; Sun, 31 Oct 2021 15:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635720919; cv=none; d=google.com; s=arc-20160816; b=xNAU6x87tuzuTkva0AzTB5a+3vIjH1aCNMRPhVfylq+Bg6sBxhOAAz9ZQc0u7B/lql xfUWGw1Q61Hxgmb28ehtzhL9ctkm4KFUvOHSwr5p9KOfzePUdgz+4180o5PUFenkD+HS jNLaJjJVOqWXxxQBMQD6MeLKL0iZogdtoReik5AxkR6QGxi7HVRcAxXteNrNVX/jC8AW NW7/hiQ+ybLdQcaX8VtAjwjtWKB4V734WfcVmIbenB7COvgB3BWUqVHHMTSv/i8TZMJl VLgwf7S3/xLudomJ4VSs+/4CusGoaxlZtVPF9hMFLxdyMWciHIXOiK6vN77ppyCluRZY jk0g== 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=dQzBTZB2neuQYMfndsZa2+3/XGXbUkUJliSXmv07Tbg=; b=omd0/bkCaAGA0XbVqFbUDirJRnqcxCBW9DzVBpg1DDArSZwOGW8letDEACIqb6mKoF eW/yR7X/yAR5ZodrnDxuGvfcQxl55vOa59D9LViPKPUPQwX9lC3i6hTKQnY7o4zN68bh opoOQB5vSFGyAXo3qF8EDbcSsFOt+9yY9gtuNSO7Tcm2aHWCntemxn0YhejvtnSNB5Mh Shylvd3BN4lk9lkhInGM+Yv/Xl1Bx1lsLNbUclkAAUTEuQLarOydGSyR/UsKLUUKibVb WGnobERH+YiskWzbcNjgl0mRHkFUbkC39L7HpyDywTaIORdcRNMRRXFNf46XPvgZrU5w rvRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TewOPruT; 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 n12si20192857jaj.44.2021.10.31.15.55.08; Sun, 31 Oct 2021 15:55:19 -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=TewOPruT; 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 S230250AbhJaWyh (ORCPT + 99 others); Sun, 31 Oct 2021 18:54:37 -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); >