spinlock_t lock;
- unsigned long init_size;
unsigned long max_size;
unsigned long grow_size;
struct list_head list;
- void *init_region;
char name[MAX_POOL_NAME_LEN];
};
const char *name,
xmem_pool_get_memory get_mem,
xmem_pool_put_memory put_mem,
- unsigned long init_size,
unsigned long max_size,
unsigned long grow_size)
{
struct xmem_pool *pool;
int pool_bytes, pool_order;
- BUG_ON(max_size && (max_size < init_size));
+ BUG_ON(max_size && (max_size < grow_size));
pool_bytes = ROUNDUP_SIZE(sizeof(*pool));
pool_order = get_order_from_bytes(pool_bytes);
memset(pool, 0, pool_bytes);
/* Round to next page boundary */
- init_size = ROUNDUP_PAGE(init_size);
max_size = ROUNDUP_PAGE(max_size);
grow_size = ROUNDUP_PAGE(grow_size);
/* pool global overhead not included in used size */
pool->used_size = 0;
- pool->init_size = init_size;
pool->max_size = max_size;
pool->grow_size = grow_size;
pool->get_mem = get_mem;
pool->put_mem = put_mem;
strlcpy(pool->name, name, sizeof(pool->name));
- /* always obtain init_region lazily now to ensure it is get_mem'd
- * in the same "context" as all other regions */
-
spin_lock_init(&pool->lock);
spin_lock(&pool_list_lock);
{
unsigned long total;
total = ROUNDUP_SIZE(sizeof(*pool))
- + pool->init_size
+ (pool->num_regions - 1) * pool->grow_size;
return total;
}
if ( pool == NULL )
return;
- /* User is destroying without ever allocating from this pool */
- if ( xmem_pool_get_used_size(pool) == BHDR_OVERHEAD )
- {
- ASSERT(!pool->init_region);
- pool->used_size -= BHDR_OVERHEAD;
- }
-
/* Check for memory leaks in this pool */
if ( xmem_pool_get_used_size(pool) )
printk("memory leak in pool: %s (%p). "
int fl, sl;
unsigned long tmp_size;
- if ( pool->init_region == NULL )
- {
- if ( (region = pool->get_mem(pool->init_size)) == NULL )
- goto out;
- ADD_REGION(region, pool->init_size, pool);
- pool->init_region = region;
- }
-
size = (size < MIN_BLOCK_SIZE) ? MIN_BLOCK_SIZE : ROUNDUP_SIZE(size);
/* Rounding up the requested size and calculating fl and sl */
/* Not found */
if ( size > (pool->grow_size - 2 * BHDR_OVERHEAD) )
goto out_locked;
- if ( pool->max_size && (pool->init_size +
- pool->num_regions * pool->grow_size
+ if ( pool->max_size && (pool->num_regions * pool->grow_size
> pool->max_size) )
goto out_locked;
spin_unlock(&pool->lock);
static void tlsf_init(void)
{
- xenpool = xmem_pool_create(
- "xmalloc", xmalloc_pool_get, xmalloc_pool_put,
- PAGE_SIZE, 0, PAGE_SIZE);
+ xenpool = xmem_pool_create("xmalloc", xmalloc_pool_get,
+ xmalloc_pool_put, 0, PAGE_SIZE);
BUG_ON(!xenpool);
}
* @name: name of the pool
* @get_mem: callback function used to expand pool
* @put_mem: callback function used to shrink pool
- * @init_size: inital pool size (in bytes)
* @max_size: maximum pool size (in bytes) - set this as 0 for no limit
* @grow_size: amount of memory (in bytes) added to pool whenever required
*
const char *name,
xmem_pool_get_memory get_mem,
xmem_pool_put_memory put_mem,
- unsigned long init_size,
unsigned long max_size,
unsigned long grow_size);