Lines Matching defs: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
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;
205 pool = kzalloc(sizeof(struct zbud_pool), gfp);
206 if (!pool)
208 spin_lock_init(&pool->lock);
210 INIT_LIST_HEAD(&pool->unbuddied[i]);
211 INIT_LIST_HEAD(&pool->buddied);
212 pool->pages_nr = 0;
213 return 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)
224 kfree(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,
259 spin_lock(&pool->lock);
263 if (!list_empty(&pool->unbuddied[i])) {
264 zhdr = list_first_entry(&pool->unbuddied[i],
276 spin_unlock(&pool->lock);
280 spin_lock(&pool->lock);
281 pool->pages_nr++;
294 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
297 list_add(&zhdr->buddy, &pool->buddied);
301 spin_unlock(&pool->lock);
308 * @pool: pool in which the allocation resided
311 static void zbud_free(struct zbud_pool *pool, unsigned long handle)
316 spin_lock(&pool->lock);
331 pool->pages_nr--;
335 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
338 spin_unlock(&pool->lock);
343 * @pool: pool in which the allocation resides
353 static void *zbud_map(struct zbud_pool *pool, unsigned long handle)
360 * @pool: pool in which the allocation resides
363 static void zbud_unmap(struct zbud_pool *pool, unsigned long handle)
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)
376 return pool->pages_nr;
388 static void zbud_zpool_destroy(void *pool)
390 zbud_destroy_pool(pool);
393 static int zbud_zpool_malloc(void *pool, size_t size, gfp_t gfp,
396 return zbud_alloc(pool, size, gfp, handle);
398 static void zbud_zpool_free(void *pool, unsigned long handle)
400 zbud_free(pool, handle);
403 static void *zbud_zpool_map(void *pool, unsigned long handle,
406 return zbud_map(pool, handle);
408 static void zbud_zpool_unmap(void *pool, unsigned long handle)
410 zbud_unmap(pool, handle);
413 static u64 zbud_zpool_total_size(void *pool)
415 return zbud_get_pool_size(pool) * PAGE_SIZE;