Lines Matching full:pool
62 * freelists maintained in each pool. NCHUNKS_ORDER of 6 means that the
66 * 63 freelists per pool.
78 * struct zbud_pool - stores metadata for each zbud pool
79 * @lock: protects all pool fields and first|last_chunk fields of any
80 * zbud page in the pool
86 * @pages_nr: number of zbud pages in the pool.
88 * This structure is allocated at pool creation time and maintains metadata
89 * pertaining to a particular zbud pool.
107 * @buddy: links the zbud page into the unbuddied/buddied lists in the pool
153 * Pool lock should be held as this function accesses first|last_chunks
194 * zbud_create_pool() - create a new zbud pool
195 * @gfp: gfp flags when allocating the zbud pool structure
197 * Return: pointer to the new zbud pool or NULL if the metadata allocation
202 struct zbud_pool *pool; in zbud_create_pool() local
205 pool = kzalloc(sizeof(struct zbud_pool), gfp); in zbud_create_pool()
206 if (!pool) in zbud_create_pool()
208 spin_lock_init(&pool->lock); in zbud_create_pool()
210 INIT_LIST_HEAD(&pool->unbuddied[i]); in zbud_create_pool()
211 INIT_LIST_HEAD(&pool->buddied); in zbud_create_pool()
212 pool->pages_nr = 0; in zbud_create_pool()
213 return pool; in zbud_create_pool()
217 * zbud_destroy_pool() - destroys an existing zbud pool
218 * @pool: the zbud pool to be destroyed
220 * The pool should be emptied before this function is called.
222 static void zbud_destroy_pool(struct zbud_pool *pool) in zbud_destroy_pool() argument
224 kfree(pool); in zbud_destroy_pool()
229 * @pool: zbud pool from which to allocate
231 * @gfp: gfp flags used if the pool needs to grow
234 * This function will attempt to find a free region in the pool large enough to
237 * allocated and added to the pool to satisfy the request.
240 * as zbud pool pages.
243 * gfp arguments are invalid or -ENOMEM if the pool was unable to allocate
246 static int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, in zbud_alloc() argument
259 spin_lock(&pool->lock); in zbud_alloc()
263 if (!list_empty(&pool->unbuddied[i])) { in zbud_alloc()
264 zhdr = list_first_entry(&pool->unbuddied[i], in zbud_alloc()
276 spin_unlock(&pool->lock); in zbud_alloc()
280 spin_lock(&pool->lock); in zbud_alloc()
281 pool->pages_nr++; in zbud_alloc()
294 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_alloc()
297 list_add(&zhdr->buddy, &pool->buddied); in zbud_alloc()
301 spin_unlock(&pool->lock); in zbud_alloc()
308 * @pool: pool in which the allocation resided
311 static void zbud_free(struct zbud_pool *pool, unsigned long handle) in zbud_free() argument
316 spin_lock(&pool->lock); in zbud_free()
331 pool->pages_nr--; in zbud_free()
335 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_free()
338 spin_unlock(&pool->lock); in zbud_free()
343 * @pool: pool in which the allocation resides
353 static void *zbud_map(struct zbud_pool *pool, unsigned long handle) in zbud_map() argument
360 * @pool: pool in which the allocation resides
363 static void zbud_unmap(struct zbud_pool *pool, unsigned long handle) in zbud_unmap() argument
368 * zbud_get_pool_size() - gets the zbud pool size in pages
369 * @pool: pool whose size is being queried
371 * Returns: size in pages of the given pool. The pool lock need not be
374 static u64 zbud_get_pool_size(struct zbud_pool *pool) in zbud_get_pool_size() argument
376 return pool->pages_nr; in zbud_get_pool_size()
388 static void zbud_zpool_destroy(void *pool) in zbud_zpool_destroy() argument
390 zbud_destroy_pool(pool); in zbud_zpool_destroy()
393 static int zbud_zpool_malloc(void *pool, size_t size, gfp_t gfp, in zbud_zpool_malloc() argument
396 return zbud_alloc(pool, size, gfp, handle); in zbud_zpool_malloc()
398 static void zbud_zpool_free(void *pool, unsigned long handle) in zbud_zpool_free() argument
400 zbud_free(pool, handle); in zbud_zpool_free()
403 static void *zbud_zpool_map(void *pool, unsigned long handle, in zbud_zpool_map() argument
406 return zbud_map(pool, handle); in zbud_zpool_map()
408 static void zbud_zpool_unmap(void *pool, unsigned long handle) in zbud_zpool_unmap() argument
410 zbud_unmap(pool, handle); in zbud_zpool_unmap()
413 static u64 zbud_zpool_total_size(void *pool) in zbud_zpool_total_size() argument
415 return zbud_get_pool_size(pool) * PAGE_SIZE; in zbud_zpool_total_size()