WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xmem_pool_create interface missing important interfa

To: "Xen-Devel (E-mail)" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] xmem_pool_create interface missing important interface info
From: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Date: Tue, 10 Feb 2009 20:49:03 +0000 (GMT)
Delivery-date: Tue, 10 Feb 2009 12:50:18 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
The work late last year to substitute xmalloc_tlsf for xmalloc
exported the tlsf memory pool interface so that code other
than xmalloc could utilize it.  However,  xmem_pool_alloc
doesn't differentiate between failure due to lack of memory
and failure due to a too-large request.  This adds a new
interface to allow the max allocation size to be obtained.
This can be called once and the result squirreled away as
the value is fixed for the life of the tlsf pool.

Keir, note that this will be included in next rev of
tmem patch, so no need to apply it now, but I wanted
to get some separate review, since afaik this is the
first non-xmalloc code to use the xmem_pool_create
interface.

diff -r 4ac8bc60c000 xen/common/xmalloc_tlsf.c
--- a/xen/common/xmalloc_tlsf.c Tue Feb 10 05:51:00 2009 +0000
+++ b/xen/common/xmalloc_tlsf.c Tue Feb 10 13:40:53 2009 -0700
@@ -496,6 +496,11 @@ void xmem_pool_free(void *ptr, struct xm
     spin_unlock(&pool->lock);
 }
 
+int xmem_pool_maxalloc(struct xmem_pool *pool)
+{
+    return pool->grow_size - (2 * BHDR_OVERHEAD);
+}
+
 /*
  * Glue for xmalloc().
  */
diff -r 4ac8bc60c000 xen/include/xen/xmalloc.h
--- a/xen/include/xen/xmalloc.h Tue Feb 10 05:51:00 2009 +0000
+++ b/xen/include/xen/xmalloc.h Tue Feb 10 13:40:53 2009 -0700
@@ -76,7 +76,13 @@ void *xmem_pool_alloc(unsigned long size
 void *xmem_pool_alloc(unsigned long size, struct xmem_pool *pool);
 
 /**
- * xmem_pool_free - free memory from given pool
+ * xmem_pool_maxalloc - xmem_pool_alloc's greater than this size will fail
+ * @mem_pool: pool
+ */
+int xmem_pool_maxalloc(struct xmem_pool *pool);
+
+/**
+ * xmem_pool_maxsize - 
  * @ptr: address of memory to be freed
  * @mem_pool: pool to free from
  */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] xmem_pool_create interface missing important interface info, Dan Magenheimer <=