From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 1/2] KVM: opencode gfn_to_page in kvm_vm_fault
Date: Tue, 16 Sep 2008 20:54:46 -0300 [thread overview]
Message-ID: <20080916235523.509181089@localhost.localdomain> (raw)
In-Reply-To: 20080916235445.291854374@localhost.localdomain
[-- Attachment #1: kvm-vm-fault --]
[-- Type: text/plain, Size: 1132 bytes --]
kvm_vm_fault is invoked with mmap_sem held in read mode. Since gfn_to_page
will be converted to get_user_pages_fast, which requires this lock NOT
to be held, switch to opencoded get_user_pages.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm.tip/virt/kvm/kvm_main.c
===================================================================
--- kvm.tip.orig/virt/kvm/kvm_main.c
+++ kvm.tip/virt/kvm/kvm_main.c
@@ -1394,17 +1394,22 @@ out:
static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
+ struct page *page[1];
+ unsigned long addr;
+ int npages;
+ gfn_t gfn = vmf->pgoff;
struct kvm *kvm = vma->vm_file->private_data;
- struct page *page;
- if (!kvm_is_visible_gfn(kvm, vmf->pgoff))
+ addr = gfn_to_hva(kvm, gfn);
+ if (kvm_is_error_hva(addr))
return VM_FAULT_SIGBUS;
- page = gfn_to_page(kvm, vmf->pgoff);
- if (is_error_page(page)) {
- kvm_release_page_clean(page);
+
+ npages = get_user_pages(current, current->mm, addr, 1, 1, 0, page,
+ NULL);
+ if (unlikely(npages != 1))
return VM_FAULT_SIGBUS;
- }
- vmf->page = page;
+
+ vmf->page = page[0];
return 0;
}
--
next prev parent reply other threads:[~2008-09-16 23:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-16 23:54 [patch 0/2] switch to get_user_pages_fast Marcelo Tosatti
2008-09-16 23:54 ` Marcelo Tosatti [this message]
2008-09-16 23:54 ` [patch 2/2] KVM: " Marcelo Tosatti
2008-09-17 14:42 ` Hollis Blanchard
2008-09-17 6:12 ` [patch 0/2] " Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2008-09-11 13:43 Marcelo Tosatti
2008-09-11 13:43 ` [patch 1/2] KVM: opencode gfn_to_page in kvm_vm_fault 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=20080916235523.509181089@localhost.localdomain \
--to=mtosatti@redhat.com \
--cc=avi@qumranet.com \
--cc=kvm@vger.kernel.org \
/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