From: jglisse@redhat.com
To: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
kvm@vger.kernel.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Jérôme Glisse" <jglisse@redhat.com>,
"Andrea Arcangeli" <aarcange@redhat.com>,
"Peter Xu" <peterx@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>
Subject: [PATCH v2 1/1] kvm/mmu_notifier: re-enable the change_pte() optimization.
Date: Wed, 20 Feb 2019 20:22:27 -0500 [thread overview]
Message-ID: <20190221012227.13236-2-jglisse@redhat.com> (raw)
In-Reply-To: <20190221012227.13236-1-jglisse@redhat.com>
From: Jérôme Glisse <jglisse@redhat.com>
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>
---
virt/kvm/kvm_main.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
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
--
2.17.2
prev parent reply other threads:[~2019-02-21 1:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 1:22 [PATCH v2 0/1] Restore change_pte optimization jglisse
2019-02-21 1:22 ` jglisse [this message]
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=20190221012227.13236-2-jglisse@redhat.com \
--to=jglisse@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=rkrcmar@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®