[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xmem_pool_create interface missing important interface info
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |