diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2008-09-16 19:54:47 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-10-15 08:25:06 -0400 |
commit | 4c2155ce81c193788082d4b8cdbc26d79edebc58 (patch) | |
tree | 5c028fe4a18c55b5c0e9c4e80be459dad3f96da7 /virt/kvm | |
parent | 777b3f49d297e387866604093b635e5bc9b9d2a6 (diff) |
KVM: switch to get_user_pages_fast
Convert gfn_to_pfn to use get_user_pages_fast, which can do lockless
pagetable lookups on x86. Kernel compilation on 4-way guest is 3.7%
faster on VMX.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/kvm_main.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2907d05cfcc3..cd34f73513d3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -723,9 +723,6 @@ unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn) | |||
723 | } | 723 | } |
724 | EXPORT_SYMBOL_GPL(gfn_to_hva); | 724 | EXPORT_SYMBOL_GPL(gfn_to_hva); |
725 | 725 | ||
726 | /* | ||
727 | * Requires current->mm->mmap_sem to be held | ||
728 | */ | ||
729 | pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn) | 726 | pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn) |
730 | { | 727 | { |
731 | struct page *page[1]; | 728 | struct page *page[1]; |
@@ -741,20 +738,23 @@ pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn) | |||
741 | return page_to_pfn(bad_page); | 738 | return page_to_pfn(bad_page); |
742 | } | 739 | } |
743 | 740 | ||
744 | npages = get_user_pages(current, current->mm, addr, 1, 1, 0, page, | 741 | npages = get_user_pages_fast(addr, 1, 1, page); |
745 | NULL); | ||
746 | 742 | ||
747 | if (unlikely(npages != 1)) { | 743 | if (unlikely(npages != 1)) { |
748 | struct vm_area_struct *vma; | 744 | struct vm_area_struct *vma; |
749 | 745 | ||
746 | down_read(¤t->mm->mmap_sem); | ||
750 | vma = find_vma(current->mm, addr); | 747 | vma = find_vma(current->mm, addr); |
748 | |||
751 | if (vma == NULL || addr < vma->vm_start || | 749 | if (vma == NULL || addr < vma->vm_start || |
752 | !(vma->vm_flags & VM_PFNMAP)) { | 750 | !(vma->vm_flags & VM_PFNMAP)) { |
751 | up_read(¤t->mm->mmap_sem); | ||
753 | get_page(bad_page); | 752 | get_page(bad_page); |
754 | return page_to_pfn(bad_page); | 753 | return page_to_pfn(bad_page); |
755 | } | 754 | } |
756 | 755 | ||
757 | pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; | 756 | pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; |
757 | up_read(¤t->mm->mmap_sem); | ||
758 | BUG_ON(!is_mmio_pfn(pfn)); | 758 | BUG_ON(!is_mmio_pfn(pfn)); |
759 | } else | 759 | } else |
760 | pfn = page_to_pfn(page[0]); | 760 | pfn = page_to_pfn(page[0]); |