[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC/PATCH] Improve speed of mapping guest memory into Dom0



On 14/11/12 16:39, David Vrabel wrote:
On 14/11/12 13:08, David Vrabel wrote:
On 14/11/12 11:13, Mats Petersson wrote:

I have also found that the munmap() call used to unmap the guest memory
from Dom0 is about 35% slower in 3.7 kernel than in the 2.6 kernel (3.8M
cycles vs 2.8M cycles).
This performance reduction only occurs with 32-bit guests is the Xen
then traps-and-emulates both halves of the PTE write.

I think this could be made quicker by using a
direct write of zero rather than the compare exchange operation that is
currently used [which traps into Xen, performs the compare & exchange] -
This is something I noticed but never got around to producing a patch.
How about this (uncomplied!) patch?

-- a/mm/memory.c
+++ b/mm/memory.c
@@ -1146,8 +1146,16 @@ again:
                                     page->index > details->last_index))
                                        continue;
                        }
-                       ptent = ptep_get_and_clear_full(mm, addr, pte,
-                                                       tlb->fullmm);
+                       /*
+                        * No need for the expensive atomic get and
+                        * clear for anonymous mappings as the dirty
+                        * and young bits are not used.
+                        */
+                       if (PageAnon(page))
The mapping might not be backed by pages (e.g., foreign mappings) so:

if (!page || PageAnon(page))
Indeed, this works fine - it now takes just under 500K cycles to "unmap" 1024 pages - compared to 3800k cycles with the original code.

--
Mats

+                               pte_clear(mm, addr, pte);
+                       else
+                               ptent = ptep_get_and_clear_full(mm, addr, pte,
+                                                               tlb->fullmm);
                        tlb_remove_tlb_entry(tlb, pte, addr);
                        if (unlikely(!page))
                                continue;
David




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.