From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1941D1FC5 for ; Sun, 12 Mar 2023 13:01:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B906BC433EF; Sun, 12 Mar 2023 13:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678626089; bh=1Krpz6j4z+TXsdSXtawt+riN9oCjZV/jmhx3ZOwAZ4U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hnMZWCcdRDuX58WIy/8JvFQzU6GIHIl45Hzx9+Qzb7sGqOnQHGPUn9+U9GgMzDBEZ NGa5W9ub8RzMP0MJ7sCtw+2d6kgZmO8eoTNMqlldlkidubvt/Hiw5UXe+QfRYmotV0 U3fx/PdUcOA5hq1FXxwJttWnbHIBPfQzxsOAOMtdOxd9F1HHY1W1n6y9dsUtcRHcUj UTDkPSK/JFa1P8ILbwvftoCNeYsBY/Wvy0Pq4uUi5V7asAJBLg5IeGppTBVAVrRkic togWqyaQRfcxeMGWc+8jkmIVvxm7Omkxmu98YidbOsbj+Pnnjqz1fTdaxkZfwkXurp ZqjPRlJOwHKbQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pbLKJ-00GzXd-EF; Sun, 12 Mar 2023 13:01:27 +0000 Date: Sun, 12 Mar 2023 13:01:26 +0000 Message-ID: <874jqq5djt.wl-maz@kernel.org> From: Marc Zyngier To: Ricardo Koller Cc: pbonzini@redhat.com, oupton@google.com, yuzenghui@huawei.com, dmatlack@google.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, qperret@google.com, catalin.marinas@arm.com, andrew.jones@linux.dev, seanjc@google.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, eric.auger@redhat.com, gshan@redhat.com, reijiw@google.com, rananta@google.com, bgardon@google.com, ricarkol@gmail.com Subject: Re: [PATCH v6 11/12] KVM: arm64: Split huge pages during KVM_CLEAR_DIRTY_LOG In-Reply-To: <20230307034555.39733-12-ricarkol@google.com> References: <20230307034555.39733-1-ricarkol@google.com> <20230307034555.39733-12-ricarkol@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: ricarkol@google.com, pbonzini@redhat.com, oupton@google.com, yuzenghui@huawei.com, dmatlack@google.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, qperret@google.com, catalin.marinas@arm.com, andrew.jones@linux.dev, seanjc@google.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, eric.auger@redhat.com, gshan@redhat.com, reijiw@google.com, rananta@google.com, bgardon@google.com, ricarkol@gmail.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 07 Mar 2023 03:45:54 +0000, Ricardo Koller wrote: > > This is the arm64 counterpart of commit cb00a70bd4b7 ("KVM: x86/mmu: > Split huge pages mapped by the TDP MMU during KVM_CLEAR_DIRTY_LOG"), > which has the benefit of splitting the cost of splitting a memslot > across multiple ioctls. > > Split huge pages on the range specified using KVM_CLEAR_DIRTY_LOG. > And do not split when enabling dirty logging if > KVM_DIRTY_LOG_INITIALLY_SET is set. > > Signed-off-by: Ricardo Koller > --- > arch/arm64/kvm/mmu.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 910aea6bbd1e..d54223b5db97 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -1089,8 +1089,8 @@ static void kvm_mmu_split_memory_region(struct kvm *kvm, int slot) > * @mask: The mask of pages at offset 'gfn_offset' in this memory > * slot to enable dirty logging on > * > - * Writes protect selected pages to enable dirty logging for them. Caller must > - * acquire kvm->mmu_lock. > + * Splits selected pages to PAGE_SIZE and then writes protect them to enable > + * dirty logging for them. Caller must acquire kvm->mmu_lock. The code does things in the opposite order... > */ > void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm, > struct kvm_memory_slot *slot, > @@ -1103,6 +1103,13 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm, > lockdep_assert_held_write(&kvm->mmu_lock); > > stage2_wp_range(&kvm->arch.mmu, start, end); > + > + /* > + * If initially-all-set mode is not set, then huge-pages were already > + * split when enabling dirty logging: no need to do it again. > + */ > + if (kvm_dirty_log_manual_protect_and_init_set(kvm)) This contradicts the comment. Which one is correct? > + kvm_mmu_split_huge_pages(kvm, start, end); > } > > static void kvm_send_hwpoison_signal(unsigned long address, short lsb) > @@ -1889,7 +1896,9 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, > * this when deleting, moving, disabling dirty logging, or > * creating the memslot (a nop). Doing it for deletes makes > * sure we don't leak memory, and there's no need to keep the > - * cache around for any of the other cases. > + * cache around for any of the other cases. Keeping the cache > + * is useful for successive KVM_CLEAR_DIRTY_LOG calls, which is > + * not handled in this function. Where is it handled then? > */ > kvm_mmu_free_memory_cache(&kvm->arch.mmu.split_page_cache); > } Thanks, M. -- Without deviation from the norm, progress is not possible.