mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
To: mtosatti@redhat.com, gleb@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/7] KVM: Make kvm_mmu_slot_remove_write_access() take mmu_lock by itself
Date: Tue, 18 Dec 2012 16:30:03 +0900	[thread overview]
Message-ID: <20121218163003.0185affe.yoshikawa_takuya_b1@lab.ntt.co.jp> (raw)
In-Reply-To: <20121218162558.65a8bfd3.yoshikawa_takuya_b1@lab.ntt.co.jp>

Better to place mmu_lock handling and TLB flushing code together since
this is a self-contained function.

Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
---
 arch/x86/kvm/mmu.c |    3 +++
 arch/x86/kvm/x86.c |    5 +----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index fc7d84a..b7a1235 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4199,6 +4199,8 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
 	memslot = id_to_memslot(kvm->memslots, slot);
 	last_gfn = memslot->base_gfn + memslot->npages - 1;
 
+	spin_lock(&kvm->mmu_lock);
+
 	for (i = PT_PAGE_TABLE_LEVEL;
 	     i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) {
 		unsigned long *rmapp;
@@ -4214,6 +4216,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
 	}
 
 	kvm_flush_remote_tlbs(kvm);
+	spin_unlock(&kvm->mmu_lock);
 }
 
 void kvm_mmu_zap_all(struct kvm *kvm)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d9d0f6b..aa183e9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6900,11 +6900,8 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
 	 * not be created until the end of the logging.
 	 */
 	if ((mem->flags & KVM_MEM_LOG_DIRTY_PAGES) &&
-	    !(old.flags & KVM_MEM_LOG_DIRTY_PAGES)) {
-		spin_lock(&kvm->mmu_lock);
+	    !(old.flags & KVM_MEM_LOG_DIRTY_PAGES))
 		kvm_mmu_slot_remove_write_access(kvm, mem->slot);
-		spin_unlock(&kvm->mmu_lock);
-	}
 	/*
 	 * If memory slot is created, or moved, we need to clear all
 	 * mmio sptes.
-- 
1.7.5.4


  parent reply	other threads:[~2012-12-18  7:53 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18  7:25 [PATCH 0/7] KVM: Alleviate mmu_lock hold time when we start dirty logging Takuya Yoshikawa
2012-12-18  7:26 ` [PATCH 1/7] KVM: Write protect the updated slot only " Takuya Yoshikawa
2012-12-24 13:27   ` Gleb Natapov
2012-12-25  4:08     ` Takuya Yoshikawa
2012-12-25  5:05       ` Gleb Natapov
2012-12-25  5:26         ` Takuya Yoshikawa
2013-01-07 20:11   ` Marcelo Tosatti
2013-01-08 11:50     ` Gleb Natapov
2012-12-18  7:27 ` [PATCH 2/7] KVM: MMU: Remove unused parameter level from __rmap_write_protect() Takuya Yoshikawa
2012-12-18  7:28 ` [PATCH 3/7] KVM: MMU: Make kvm_mmu_slot_remove_write_access() rmap based Takuya Yoshikawa
2012-12-18  7:28 ` [PATCH 4/7] KVM: x86: Remove unused slot_bitmap from kvm_mmu_page Takuya Yoshikawa
2012-12-18  7:29 ` [PATCH 5/7] KVM: Make kvm_mmu_change_mmu_pages() take mmu_lock by itself Takuya Yoshikawa
2012-12-18  7:30 ` Takuya Yoshikawa [this message]
2012-12-18  7:30 ` [PATCH 7/7] KVM: Conditionally reschedule when kvm_mmu_slot_remove_write_access() takes a long time Takuya Yoshikawa
2012-12-19 12:30 ` [PATCH 0/7] KVM: Alleviate mmu_lock hold time when we start dirty logging Takuya Yoshikawa
2012-12-19 15:42   ` Alex Williamson
2012-12-20  5:02     ` Takuya Yoshikawa
2012-12-20 12:59       ` Marcelo Tosatti
2012-12-20 13:22         ` Gleb Natapov
2012-12-20 13:41           ` Alex Williamson
2012-12-20 14:35             ` Takuya Yoshikawa
2012-12-20 14:55               ` Alex Williamson
2012-12-21  8:02                 ` Takuya Yoshikawa
2012-12-21  8:54                   ` Gleb Natapov
2012-12-21 13:24                     ` Alex Williamson
2012-12-21  8:05                 ` Takuya Yoshikawa
2013-01-07 20:36 ` Marcelo Tosatti
2013-01-08 10:40   ` Takuya Yoshikawa
2013-01-08 10:42 [PATCH 0/7 -v2] " Takuya Yoshikawa
2013-01-08 10:46 ` [PATCH 6/7] KVM: Make kvm_mmu_slot_remove_write_access() take mmu_lock by itself Takuya Yoshikawa

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=20121218163003.0185affe.yoshikawa_takuya_b1@lab.ntt.co.jp \
    --to=yoshikawa_takuya_b1@lab.ntt.co.jp \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.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

all inboxes | Powered by JetHome®