kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Ricardo Koller <ricarkol@google.com>
To: pbonzini@redhat.com, maz@kernel.org, oupton@google.com,
	 yuzenghui@huawei.com, dmatlack@google.com
Cc: 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, Ricardo Koller <ricarkol@google.com>
Subject: [PATCH v3 05/12] KVM: arm64: Refactor kvm_arch_commit_memory_region()
Date: Wed, 15 Feb 2023 17:40:39 +0000	[thread overview]
Message-ID: <20230215174046.2201432-6-ricarkol@google.com> (raw)
In-Reply-To: <20230215174046.2201432-1-ricarkol@google.com>

Refactor kvm_arch_commit_memory_region() as a preparation for a future
commit to look cleaner and more understandable. Also, it looks more
like its x86 counterpart (in kvm_mmu_slot_apply_flags()).

No functional change intended.

Signed-off-by: Ricardo Koller <ricarkol@google.com>
---
 arch/arm64/kvm/mmu.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 9bd3c2cfb476..d2c5e6992459 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1761,20 +1761,27 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
 				   const struct kvm_memory_slot *new,
 				   enum kvm_mr_change change)
 {
+	bool log_dirty_pages = new && new->flags & KVM_MEM_LOG_DIRTY_PAGES;
+
 	/*
 	 * At this point memslot has been committed and there is an
 	 * allocated dirty_bitmap[], dirty pages will be tracked while the
 	 * memory slot is write protected.
 	 */
-	if (change != KVM_MR_DELETE && new->flags & KVM_MEM_LOG_DIRTY_PAGES) {
+	if (log_dirty_pages) {
+
+		if (change == KVM_MR_DELETE)
+			return;
+
 		/*
 		 * If we're with initial-all-set, we don't need to write
 		 * protect any pages because they're all reported as dirty.
 		 * Huge pages and normal pages will be write protect gradually.
 		 */
-		if (!kvm_dirty_log_manual_protect_and_init_set(kvm)) {
-			kvm_mmu_wp_memory_region(kvm, new->id);
-		}
+		if (kvm_dirty_log_manual_protect_and_init_set(kvm))
+			return;
+
+		kvm_mmu_wp_memory_region(kvm, new->id);
 	}
 }
 
-- 
2.39.1.637.g21b0678d19-goog


  parent reply	other threads:[~2023-02-15 17:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 17:40 [PATCH v3 00/12] Implement Eager Page Splitting for ARM Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 01/12] KVM: arm64: Add KVM_PGTABLE_WALK ctx->flags for skipping BBM and CMO Ricardo Koller
2023-02-16  2:56   ` Shaoqin Huang
2023-02-16 18:41     ` Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 02/12] KVM: arm64: Rename free_unlinked to free_removed Ricardo Koller
2023-02-15 23:51   ` Oliver Upton
2023-02-16  3:13   ` Shaoqin Huang
2023-02-16 18:44     ` Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 03/12] KVM: arm64: Add helper for creating unlinked stage2 subtrees Ricardo Koller
2023-02-16  0:13   ` Oliver Upton
2023-02-16 18:34     ` Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 04/12] KVM: arm64: Add kvm_pgtable_stage2_split() Ricardo Koller
2023-02-16  0:36   ` Oliver Upton
2023-02-16 18:07     ` Ricardo Koller
2023-02-16 18:14       ` Ricardo Koller
2023-02-16 12:22   ` Shaoqin Huang
2023-02-16 18:30     ` Ricardo Koller
2023-02-17  4:07   ` Shaoqin Huang
2023-02-15 17:40 ` Ricardo Koller [this message]
2023-02-15 17:40 ` [PATCH v3 06/12] KVM: arm64: Add kvm_uninit_stage2_mmu() Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 07/12] KVM: arm64: Export kvm_are_all_memslots_empty() Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 08/12] KVM: arm64: Add KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 09/12] KVM: arm64: Split huge pages when dirty logging is enabled Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 10/12] KVM: arm64: Open-code kvm_mmu_write_protect_pt_masked() Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 11/12] KVM: arm64: Split huge pages during KVM_CLEAR_DIRTY_LOG Ricardo Koller
2023-02-15 17:40 ` [PATCH v3 12/12] KVM: arm64: Use local TLBI on permission relaxation Ricardo Koller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230215174046.2201432-6-ricarkol@google.com \
    --to=ricarkol@google.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=bgardon@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=dmatlack@google.com \
    --cc=eric.auger@redhat.com \
    --cc=gshan@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=qperret@google.com \
    --cc=rananta@google.com \
    --cc=reijiw@google.com \
    --cc=ricarkol@gmail.com \
    --cc=seanjc@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).