summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Glisse <jglisse@redhat.com>2019-01-31 13:37:06 -0500
committerJérôme Glisse <jglisse@redhat.com>2019-02-19 11:58:37 -0500
commitf4da8ec51b57b92aba7f9bd5c2e3664f8e26e8e8 (patch)
treef481f46f18b1aecce0d764483cac6105a7a397cd
parent7c5a7630402a9d6ef1b53d2aead1c949f78486e5 (diff)
kvm/mmu_notifier: re-enable the change_pte() optimization.mmu-notifier-v05
Since changes to mmu notifier the change_pte() optimization was lost for kvm. This re-enable it, when ever a pte is going from read and write to read only with same pfn, or from read only to read and write with different pfn. It is safe to update the secondary MMUs, because the primary MMU pte invalidate must have already happened with a ptep_clear_flush() before set_pte_at_notify() is invoked (and thus before change_pte() callback). Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: kvm@vger.kernel.org
-rw-r--r--virt/kvm/kvm_main.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 629760c0fb95..0f979f02bf1c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -369,6 +369,14 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
int need_tlb_flush = 0, idx;
int ret;
+ /*
+ * Nothing to do when using change_pte() which will be call for each
+ * individual pte update at the right time. See mmu_notifier.h for more
+ * informations.
+ */
+ if (mmu_notifier_range_use_change_pte(range))
+ return 0;
+
idx = srcu_read_lock(&kvm->srcu);
spin_lock(&kvm->mmu_lock);
/*
@@ -399,6 +407,14 @@ static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
{
struct kvm *kvm = mmu_notifier_to_kvm(mn);
+ /*
+ * Nothing to do when using change_pte() which will be call for each
+ * individual pte update at the right time. See mmu_notifier.h for more
+ * informations.
+ */
+ if (mmu_notifier_range_use_change_pte(range))
+ return;
+
spin_lock(&kvm->mmu_lock);
/*
* This sequence increase will notify the kvm page fault that