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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27BA4C4332F for ; Sun, 22 May 2022 10:22:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3498C10E0E6; Sun, 22 May 2022 10:22:19 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id F2FBF10E0E6 for ; Sun, 22 May 2022 10:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653214937; 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=b/PRTGgzJSajLmASm1ImWykhYRAoLKce07yOgwd/E/o=; b=IH0X6jqtlg4aOOaWaSkgVaGjYNZinM6AZuLW8bQyte9qQtpCSGvLiUkzMFOyWiTp2MCON6 ET4mZs2dIRV5st3Yy4Pz/zsmX6wmS4Eo2s3GDitVIa3uxN+ofKT+Tb6YR3UdXzKWU/0RdO s9PhEBjHpnwECDdgfozJqsv719VhHEM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-78527TvaMxCx363TuhOEMA-1; Sun, 22 May 2022 06:22:13 -0400 X-MC-Unique: 78527TvaMxCx363TuhOEMA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0ADC71C05AEF; Sun, 22 May 2022 10:22:12 +0000 (UTC) Received: from starship (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7845340CFD00; Sun, 22 May 2022 10:22:06 +0000 (UTC) Message-ID: <5ed0d0e5a88bbee2f95d794dbbeb1ad16789f319.camel@redhat.com> From: Maxim Levitsky To: Sean Christopherson Date: Sun, 22 May 2022 13:22:05 +0300 In-Reply-To: References: <20220427200314.276673-1-mlevitsk@redhat.com> <20220427200314.276673-5-mlevitsk@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.11.54.1 Subject: Re: [Intel-gfx] [RFC PATCH v3 04/19] KVM: x86: mmu: allow to enable write tracking externally X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , kvm@vger.kernel.org, David Airlie , Dave Hansen , dri-devel@lists.freedesktop.org, "H. Peter Anvin" , Brijesh Singh , Joerg Roedel , x86@kernel.org, Ingo Molnar , Tom Lendacky , intel-gfx@lists.freedesktop.org, Borislav Petkov , Rodrigo Vivi , Thomas Gleixner , intel-gvt-dev@lists.freedesktop.org, Jim Mattson , linux-kernel@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Thu, 2022-05-19 at 16:37 +0000, Sean Christopherson wrote: > On Wed, Apr 27, 2022, Maxim Levitsky wrote: > > @@ -5753,6 +5752,10 @@ int kvm_mmu_init_vm(struct kvm *kvm) > > node->track_write = kvm_mmu_pte_write; > > node->track_flush_slot = kvm_mmu_invalidate_zap_pages_in_memslot; > > kvm_page_track_register_notifier(kvm, node); > > Can you add a patch to move this call to kvm_page_track_register_notifier() into > mmu_enable_write_tracking(), and simultaneously add a WARN in the register path > that page tracking is enabled? > > Oh, actually, a better idea. Add an inner __kvm_page_track_register_notifier() > that is not exported and thus used only by KVM, invoke mmu_enable_write_tracking() > from the exported kvm_page_track_register_notifier(), and then do the above. > That will require modifying KVMGT and KVM in a single patch, but that's ok. > > That will avoid any possibility of an external user failing to enabling tracking > before registering its notifier, and also avoids bikeshedding over what to do with > the one-line wrapper to enable tracking. > This is a good idea as well, especially looking at kvmgt and seeing that it registers the page track notifier, when the vGPU is opened. I'll do this in the next series. Thanks for the review! Best regards, Maxim Levitsky 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DEBD9C433FE for ; Sun, 22 May 2022 10:22:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D668F10E03D; Sun, 22 May 2022 10:22:17 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id EADFD10E03D for ; Sun, 22 May 2022 10:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653214936; 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=b/PRTGgzJSajLmASm1ImWykhYRAoLKce07yOgwd/E/o=; b=F8hcFq49Cq72X8AhWXVlo8cPF5QC9+KynXsvQGGN6Ctpqrg4rGhmrRhKomR4nVjM0o3iGo /L1w2tZXuf7rziyYeBEa5O5Mv2wI+kMHqeJyI4nKLdEGQUS6tggxDavkhk++Pp1Ls3I6ex RTu+X8C43/faGzPsMKM3xH/EgvqWzL0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-78527TvaMxCx363TuhOEMA-1; Sun, 22 May 2022 06:22:13 -0400 X-MC-Unique: 78527TvaMxCx363TuhOEMA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0ADC71C05AEF; Sun, 22 May 2022 10:22:12 +0000 (UTC) Received: from starship (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7845340CFD00; Sun, 22 May 2022 10:22:06 +0000 (UTC) Message-ID: <5ed0d0e5a88bbee2f95d794dbbeb1ad16789f319.camel@redhat.com> Subject: Re: [RFC PATCH v3 04/19] KVM: x86: mmu: allow to enable write tracking externally From: Maxim Levitsky To: Sean Christopherson Date: Sun, 22 May 2022 13:22:05 +0300 In-Reply-To: References: <20220427200314.276673-1-mlevitsk@redhat.com> <20220427200314.276673-5-mlevitsk@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.11.54.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , kvm@vger.kernel.org, David Airlie , Dave Hansen , dri-devel@lists.freedesktop.org, "H. Peter Anvin" , Brijesh Singh , Joerg Roedel , x86@kernel.org, Ingo Molnar , Zhi Wang , Tom Lendacky , intel-gfx@lists.freedesktop.org, Borislav Petkov , Rodrigo Vivi , Thomas Gleixner , intel-gvt-dev@lists.freedesktop.org, Jim Mattson , Tvrtko Ursulin , linux-kernel@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, 2022-05-19 at 16:37 +0000, Sean Christopherson wrote: > On Wed, Apr 27, 2022, Maxim Levitsky wrote: > > @@ -5753,6 +5752,10 @@ int kvm_mmu_init_vm(struct kvm *kvm) > > node->track_write = kvm_mmu_pte_write; > > node->track_flush_slot = kvm_mmu_invalidate_zap_pages_in_memslot; > > kvm_page_track_register_notifier(kvm, node); > > Can you add a patch to move this call to kvm_page_track_register_notifier() into > mmu_enable_write_tracking(), and simultaneously add a WARN in the register path > that page tracking is enabled? > > Oh, actually, a better idea. Add an inner __kvm_page_track_register_notifier() > that is not exported and thus used only by KVM, invoke mmu_enable_write_tracking() > from the exported kvm_page_track_register_notifier(), and then do the above. > That will require modifying KVMGT and KVM in a single patch, but that's ok. > > That will avoid any possibility of an external user failing to enabling tracking > before registering its notifier, and also avoids bikeshedding over what to do with > the one-line wrapper to enable tracking. > This is a good idea as well, especially looking at kvmgt and seeing that it registers the page track notifier, when the vGPU is opened. I'll do this in the next series. Thanks for the review! Best regards, Maxim Levitsky 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 230C5C433FE for ; Sun, 22 May 2022 10:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243714AbiEVKWW (ORCPT ); Sun, 22 May 2022 06:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243752AbiEVKWS (ORCPT ); Sun, 22 May 2022 06:22:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3AAFB36B7B for ; Sun, 22 May 2022 03:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653214934; 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=b/PRTGgzJSajLmASm1ImWykhYRAoLKce07yOgwd/E/o=; b=bxD9S+8Ur6WXZDt6qo+yC/YTL7TnYDBoxjvy79aXi9BYsA1PsXp9Li9ylCb23WEJKW57pe F7wCMkA0U8Sl681VDlC4joHIitUKpOoOZDX+Dh4U2pWq5c/TJV+P1jtTN1NZG6hIpsSSg6 v6sHkeMq7y52ryZ9Xm3/yTXFxmp2mUA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-78527TvaMxCx363TuhOEMA-1; Sun, 22 May 2022 06:22:13 -0400 X-MC-Unique: 78527TvaMxCx363TuhOEMA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0ADC71C05AEF; Sun, 22 May 2022 10:22:12 +0000 (UTC) Received: from starship (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7845340CFD00; Sun, 22 May 2022 10:22:06 +0000 (UTC) Message-ID: <5ed0d0e5a88bbee2f95d794dbbeb1ad16789f319.camel@redhat.com> Subject: Re: [RFC PATCH v3 04/19] KVM: x86: mmu: allow to enable write tracking externally From: Maxim Levitsky To: Sean Christopherson Cc: kvm@vger.kernel.org, Wanpeng Li , Vitaly Kuznetsov , Jani Nikula , Paolo Bonzini , Tvrtko Ursulin , Rodrigo Vivi , Zhenyu Wang , Joonas Lahtinen , Tom Lendacky , Ingo Molnar , David Airlie , Thomas Gleixner , Dave Hansen , x86@kernel.org, intel-gfx@lists.freedesktop.org, Daniel Vetter , Borislav Petkov , Joerg Roedel , linux-kernel@vger.kernel.org, Jim Mattson , Zhi Wang , Brijesh Singh , "H. Peter Anvin" , intel-gvt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Sun, 22 May 2022 13:22:05 +0300 In-Reply-To: References: <20220427200314.276673-1-mlevitsk@redhat.com> <20220427200314.276673-5-mlevitsk@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.11.54.1 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, 2022-05-19 at 16:37 +0000, Sean Christopherson wrote: > On Wed, Apr 27, 2022, Maxim Levitsky wrote: > > @@ -5753,6 +5752,10 @@ int kvm_mmu_init_vm(struct kvm *kvm) > > node->track_write = kvm_mmu_pte_write; > > node->track_flush_slot = kvm_mmu_invalidate_zap_pages_in_memslot; > > kvm_page_track_register_notifier(kvm, node); > > Can you add a patch to move this call to kvm_page_track_register_notifier() into > mmu_enable_write_tracking(), and simultaneously add a WARN in the register path > that page tracking is enabled? > > Oh, actually, a better idea. Add an inner __kvm_page_track_register_notifier() > that is not exported and thus used only by KVM, invoke mmu_enable_write_tracking() > from the exported kvm_page_track_register_notifier(), and then do the above. > That will require modifying KVMGT and KVM in a single patch, but that's ok. > > That will avoid any possibility of an external user failing to enabling tracking > before registering its notifier, and also avoids bikeshedding over what to do with > the one-line wrapper to enable tracking. > This is a good idea as well, especially looking at kvmgt and seeing that it registers the page track notifier, when the vGPU is opened. I'll do this in the next series. Thanks for the review! Best regards, Maxim Levitsky