From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>, Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: [PATCH] kvm: allow RO page when atomic && !write_fault
Date: Mon, 21 Feb 2011 11:47:36 +0800 [thread overview]
Message-ID: <4D61E058.9080201@cn.fujitsu.com> (raw)
Atomic-able hva_to_pfn() patches and allow-read-only-page patches
are merged almost the same time. But hva_to_pfn() does not handle
these two issues well together.
When @atomic && !@write_fault && host-is-read-only-page-mapped
the code will return fault_page, actually, it will be better
if we return the pfn of the read-only-page.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1fa0d29..f49cfc0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1060,31 +1060,27 @@ static pfn_t hva_to_pfn(struct kvm *kvm, unsigned long addr, bool atomic,
BUG_ON(!write_fault && !writable);
if (writable)
- *writable = true;
+ *writable = write_fault;
if (atomic || async)
- npages = __get_user_pages_fast(addr, 1, 1, page);
+ npages = __get_user_pages_fast(addr, 1, write_fault, page);
if (unlikely(npages != 1) && !atomic) {
might_sleep();
-
- if (writable)
- *writable = write_fault;
-
npages = get_user_pages_fast(addr, 1, write_fault, page);
+ }
- /* map read fault as writable if possible */
- if (unlikely(!write_fault) && npages == 1) {
- struct page *wpage[1];
+ /* map read fault as writable if possible */
+ if (unlikely(!write_fault) && npages == 1) {
+ struct page *wpage[1];
- npages = __get_user_pages_fast(addr, 1, 1, wpage);
- if (npages == 1) {
- *writable = true;
- put_page(page[0]);
- page[0] = wpage[0];
- }
- npages = 1;
+ npages = __get_user_pages_fast(addr, 1, 1, wpage);
+ if (npages == 1) {
+ *writable = true;
+ put_page(page[0]);
+ page[0] = wpage[0];
}
+ npages = 1;
}
if (unlikely(npages != 1)) {
next reply other threads:[~2011-02-21 3:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-21 3:47 Lai Jiangshan [this message]
2011-02-21 9:47 ` [PATCH] kvm: allow RO page when atomic && !write_fault Gleb Natapov
2011-02-22 8:24 ` Lai Jiangshan
2011-02-22 19:24 ` Marcelo Tosatti
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=4D61E058.9080201@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=avi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.