From 86e16d2206ef86848a3af20ed694767d0f4cedfa Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Aug 2008 17:52:53 -0500 Subject: [PATCH] --- yaml --- r: 108223 b: refs/heads/master c: 71a3f4edc11b9dd7af28d003acbbd33496003da1 h: refs/heads/master i: 108221: 573cccfa292dc3322ec2b3dd83878fde1e5840ff 108219: bf0ef6061bb1ed02257abdd5cf78ba444f9fc850 108215: 08f0bf27ff42c391cda257014999b3bd73679804 108207: d6b1589fb89553618d5b41923a3ac466f2167160 108191: 3bfe58b2628dcda29d238f71e0625d74e4b3dba2 108159: 70acdfb960b790d44fdcc56defd47839a9afae3c v: v3 --- [refs] | 2 +- trunk/drivers/lguest/page_tables.c | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/[refs] b/[refs] index a018d99a4e9d..82565ccb28d2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 912985dce45ef18fcdd9f5439fef054e0e22302a +refs/heads/master: 71a3f4edc11b9dd7af28d003acbbd33496003da1 diff --git a/trunk/drivers/lguest/page_tables.c b/trunk/drivers/lguest/page_tables.c index d93500f24fbb..81d0c6053447 100644 --- a/trunk/drivers/lguest/page_tables.c +++ b/trunk/drivers/lguest/page_tables.c @@ -108,9 +108,8 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr) } /*:*/ -/*M:014 get_pfn is slow; it takes the mmap sem and calls get_user_pages. We - * could probably try to grab batches of pages here as an optimization - * (ie. pre-faulting). :*/ +/*M:014 get_pfn is slow: we could probably try to grab batches of pages here as + * an optimization (ie. pre-faulting). :*/ /*H:350 This routine takes a page number given by the Guest and converts it to * an actual, physical page number. It can fail for several reasons: the @@ -123,19 +122,13 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr) static unsigned long get_pfn(unsigned long virtpfn, int write) { struct page *page; - /* This value indicates failure. */ - unsigned long ret = -1UL; - /* get_user_pages() is a complex interface: it gets the "struct - * vm_area_struct" and "struct page" assocated with a range of pages. - * It also needs the task's mmap_sem held, and is not very quick. - * It returns the number of pages it got. */ - down_read(¤t->mm->mmap_sem); - if (get_user_pages(current, current->mm, virtpfn << PAGE_SHIFT, - 1, write, 1, &page, NULL) == 1) - ret = page_to_pfn(page); - up_read(¤t->mm->mmap_sem); - return ret; + /* gup me one page at this address please! */ + if (get_user_pages_fast(virtpfn << PAGE_SHIFT, 1, write, &page) == 1) + return page_to_pfn(page); + + /* This value indicates failure. */ + return -1UL; } /*H:340 Converting a Guest page table entry to a shadow (ie. real) page table @@ -174,7 +167,7 @@ static pte_t gpte_to_spte(struct lg_cpu *cpu, pte_t gpte, int write) /*H:460 And to complete the chain, release_pte() looks like this: */ static void release_pte(pte_t pte) { - /* Remember that get_user_pages() took a reference to the page, in + /* Remember that get_user_pages_fast() took a reference to the page, in * get_pfn()? We have to put it back now. */ if (pte_flags(pte) & _PAGE_PRESENT) put_page(pfn_to_page(pte_pfn(pte)));