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

RE: [Xen-devel] Tmem vs order>0 allocation, workaround RFC



> Simply, avail_heap_pages would fail if total_avail_pages
> is less than 1%(?) of the total memory on the system AND
> the request is order==0.  Essentially, this is reserving
> a "zone" for order>0 allocations.

Avoid worst fragmentation issues by reserving a "zone"
of physical memory only for order>0 allocations.

Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>

g`"--- a/xen/common/page_alloc.c        Fri Feb 12 09:24:18 2010 +0000
+++ b/xen/common/page_alloc.c   Fri Feb 12 11:05:19 2010 -0700
@@ -223,6 +223,10 @@ static heap_by_zone_and_order_t *_heap[M
 
 static unsigned long *avail[MAX_NUMNODES];
 static long total_avail_pages;
+static long max_total_avail_pages; /* highwater mark */
+#define ORDER_NONZERO_FRAC 128
+static long order_nonzero_zonesize; /* reserved for order>0 allocations */
+
 
 static DEFINE_SPINLOCK(heap_lock);
 
@@ -304,6 +308,13 @@ static struct page_info *alloc_heap_page
     spin_lock(&heap_lock);
 
     /*
+       When available memory is scarce, allow only larger allocations
+       to avoid worst of fragmentation issues
+    */
+    if ( !order && (total_avail_pages <= order_nonzero_zonesize) )
+        goto fail;
+
+    /*
      * Start with requested node, but exhaust all node memory in requested 
      * zone before failing, only calc new node value if we fail to find memory 
      * in target node, this avoids needless computation on fast-path.
@@ -337,6 +348,7 @@ static struct page_info *alloc_heap_page
     }
 
     /* No suitable memory blocks. Fail the request. */
+fail:
     spin_unlock(&heap_lock);
     return NULL;
 
@@ -503,6 +515,11 @@ static void free_heap_pages(
 
     avail[node][zone] += 1 << order;
     total_avail_pages += 1 << order;
+    if ( total_avail_pages > max_total_avail_pages )
+    {
+        max_total_avail_pages = total_avail_pages;
+        order_nonzero_zonesize = max_total_avail_pages / ORDER_NONZERO_FRAC;
+    }
 
     /* Merge chunks as far as possible. */
     while ( order < MAX_ORDER )

Attachment: nonzero_alloc.patch
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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