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

[Xen-changelog] [xen master] x86/PoD: tighten conditions for checking super page



commit 513c203a0046232c55adf6d70ec1dbe54e8d157f
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Nov 20 12:37:37 2015 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Nov 20 12:37:37 2015 +0100

    x86/PoD: tighten conditions for checking super page
    
    Since calling the function isn't cheap, try to avoid the call when we
    know up front it won't help; see the code comment for details on those
    conditions.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
 xen/arch/x86/mm/p2m-pod.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index be15cf3..5d23b0d 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -528,7 +528,6 @@ p2m_pod_decrease_reservation(struct domain *d,
     if ( unlikely(d->is_dying) )
         goto out_unlock;
 
-recount:
     pod = nonpod = ram = 0;
 
     /* Figure out if we need to steal some freed memory for our cache */
@@ -568,15 +567,20 @@ recount:
         goto out_entry_check;
     }
 
-    /* Try to grab entire superpages if possible.  Since the common case is 
for drivers
-     * to pass back singleton pages, see if we can take the whole page back 
and mark the
-     * rest PoD. */
-    if ( steal_for_cache
-         && p2m_pod_zero_check_superpage(p2m, gpfn & ~(SUPERPAGE_PAGES-1)))
+    /*
+     * Try to grab entire superpages if possible.  Since the common case is for
+     * drivers to pass back singleton pages, see if we can take the whole page
+     * back and mark the rest PoD.
+     * No need to do this though if
+     * - order >= SUPERPAGE_ORDER (the loop below will take care of this)
+     * - not all of the pages were RAM (now knowing order < SUPERPAGE_ORDER)
+     */
+    if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1 << order) &&
+         p2m_pod_zero_check_superpage(p2m, gpfn & ~(SUPERPAGE_PAGES - 1)) )
     {
-        /* Since order may be arbitrary, we may have taken more or less
-         * than we were actually asked to; so just re-count from scratch */
-        goto recount;
+        pod = 1 << order;
+        ram = nonpod = 0;
+        ASSERT(steal_for_cache == (p2m->pod.entry_count > p2m->pod.count));
     }
 
     /* Process as long as:
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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