Lines Matching full:pool
63 * freelists maintained in each pool. NCHUNKS_ORDER of 6 means that the
67 * 63 freelists per pool.
77 * struct zbud_pool - stores metadata for each zbud pool
78 * @lock: protects all pool fields and first|last_chunk fields of any
79 * zbud page in the pool
87 * @pages_nr: number of zbud pages in the pool.
89 * pool creation time.
91 * This structure is allocated at pool creation time and maintains metadata
92 * pertaining to a particular zbud pool.
110 * @buddy: links the zbud page into the unbuddied/buddied lists in the pool
111 * @lru: links the zbud page into the lru list in the pool
129 static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle) in zbud_zpool_evict() argument
131 if (pool->zpool && pool->zpool_ops && pool->zpool_ops->evict) in zbud_zpool_evict()
132 return pool->zpool_ops->evict(pool->zpool, handle); in zbud_zpool_evict()
145 struct zbud_pool *pool; in zbud_zpool_create() local
147 pool = zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL); in zbud_zpool_create()
148 if (pool) { in zbud_zpool_create()
149 pool->zpool = zpool; in zbud_zpool_create()
150 pool->zpool_ops = zpool_ops; in zbud_zpool_create()
152 return pool; in zbud_zpool_create()
155 static void zbud_zpool_destroy(void *pool) in zbud_zpool_destroy() argument
157 zbud_destroy_pool(pool); in zbud_zpool_destroy()
160 static int zbud_zpool_malloc(void *pool, size_t size, gfp_t gfp, in zbud_zpool_malloc() argument
163 return zbud_alloc(pool, size, gfp, handle); in zbud_zpool_malloc()
165 static void zbud_zpool_free(void *pool, unsigned long handle) in zbud_zpool_free() argument
167 zbud_free(pool, handle); in zbud_zpool_free()
170 static int zbud_zpool_shrink(void *pool, unsigned int pages, in zbud_zpool_shrink() argument
177 ret = zbud_reclaim_page(pool, 8); in zbud_zpool_shrink()
189 static void *zbud_zpool_map(void *pool, unsigned long handle, in zbud_zpool_map() argument
192 return zbud_map(pool, handle); in zbud_zpool_map()
194 static void zbud_zpool_unmap(void *pool, unsigned long handle) in zbud_zpool_unmap() argument
196 zbud_unmap(pool, handle); in zbud_zpool_unmap()
199 static u64 zbud_zpool_total_size(void *pool) in zbud_zpool_total_size() argument
201 return zbud_get_pool_size(pool) * PAGE_SIZE; in zbud_zpool_total_size()
258 * Pool lock should be held as this function accesses first|last_chunks
299 * zbud_create_pool() - create a new zbud pool
300 * @gfp: gfp flags when allocating the zbud pool structure
301 * @ops: user-defined operations for the zbud pool
303 * Return: pointer to the new zbud pool or NULL if the metadata allocation
308 struct zbud_pool *pool; in zbud_create_pool() local
311 pool = kzalloc(sizeof(struct zbud_pool), gfp); in zbud_create_pool()
312 if (!pool) in zbud_create_pool()
314 spin_lock_init(&pool->lock); in zbud_create_pool()
316 INIT_LIST_HEAD(&pool->unbuddied[i]); in zbud_create_pool()
317 INIT_LIST_HEAD(&pool->buddied); in zbud_create_pool()
318 INIT_LIST_HEAD(&pool->lru); in zbud_create_pool()
319 pool->pages_nr = 0; in zbud_create_pool()
320 pool->ops = ops; in zbud_create_pool()
321 return pool; in zbud_create_pool()
325 * zbud_destroy_pool() - destroys an existing zbud pool
326 * @pool: the zbud pool to be destroyed
328 * The pool should be emptied before this function is called.
330 void zbud_destroy_pool(struct zbud_pool *pool) in zbud_destroy_pool() argument
332 kfree(pool); in zbud_destroy_pool()
337 * @pool: zbud pool from which to allocate
339 * @gfp: gfp flags used if the pool needs to grow
342 * This function will attempt to find a free region in the pool large enough to
345 * allocated and added to the pool to satisfy the request.
348 * as zbud pool pages.
351 * gfp arguments are invalid or -ENOMEM if the pool was unable to allocate
354 int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, in zbud_alloc() argument
367 spin_lock(&pool->lock); in zbud_alloc()
371 if (!list_empty(&pool->unbuddied[i])) { in zbud_alloc()
372 zhdr = list_first_entry(&pool->unbuddied[i], in zbud_alloc()
384 spin_unlock(&pool->lock); in zbud_alloc()
388 spin_lock(&pool->lock); in zbud_alloc()
389 pool->pages_nr++; in zbud_alloc()
402 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_alloc()
405 list_add(&zhdr->buddy, &pool->buddied); in zbud_alloc()
411 list_add(&zhdr->lru, &pool->lru); in zbud_alloc()
414 spin_unlock(&pool->lock); in zbud_alloc()
421 * @pool: pool in which the allocation resided
429 void zbud_free(struct zbud_pool *pool, unsigned long handle) in zbud_free() argument
434 spin_lock(&pool->lock); in zbud_free()
445 spin_unlock(&pool->lock); in zbud_free()
456 pool->pages_nr--; in zbud_free()
460 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_free()
463 spin_unlock(&pool->lock); in zbud_free()
467 * zbud_reclaim_page() - evicts allocations from a pool page and frees it
468 * @pool: pool from which a page will attempt to be evicted
481 * zbud_reclaim_page() will remove a zbud page from the pool LRU list and call
482 * the user-defined eviction handler with the pool and handle as arguments.
501 int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries) in zbud_reclaim_page() argument
507 spin_lock(&pool->lock); in zbud_reclaim_page()
508 if (!pool->ops || !pool->ops->evict || list_empty(&pool->lru) || in zbud_reclaim_page()
510 spin_unlock(&pool->lock); in zbud_reclaim_page()
514 zhdr = list_last_entry(&pool->lru, struct zbud_header, lru); in zbud_reclaim_page()
529 spin_unlock(&pool->lock); in zbud_reclaim_page()
533 ret = pool->ops->evict(pool, first_handle); in zbud_reclaim_page()
538 ret = pool->ops->evict(pool, last_handle); in zbud_reclaim_page()
543 spin_lock(&pool->lock); in zbud_reclaim_page()
551 pool->pages_nr--; in zbud_reclaim_page()
552 spin_unlock(&pool->lock); in zbud_reclaim_page()
558 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_reclaim_page()
561 list_add(&zhdr->buddy, &pool->buddied); in zbud_reclaim_page()
565 list_add(&zhdr->lru, &pool->lru); in zbud_reclaim_page()
567 spin_unlock(&pool->lock); in zbud_reclaim_page()
573 * @pool: pool in which the allocation resides
583 void *zbud_map(struct zbud_pool *pool, unsigned long handle) in zbud_map() argument
590 * @pool: pool in which the allocation resides
593 void zbud_unmap(struct zbud_pool *pool, unsigned long handle) in zbud_unmap() argument
598 * zbud_get_pool_size() - gets the zbud pool size in pages
599 * @pool: pool whose size is being queried
601 * Returns: size in pages of the given pool. The pool lock need not be
604 u64 zbud_get_pool_size(struct zbud_pool *pool) in zbud_get_pool_size() argument
606 return pool->pages_nr; in zbud_get_pool_size()