Lines Matching refs:pool
128 static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle) in zbud_zpool_evict() argument
130 if (pool->zpool && pool->zpool_ops && pool->zpool_ops->evict) in zbud_zpool_evict()
131 return pool->zpool_ops->evict(pool->zpool, handle); in zbud_zpool_evict()
144 struct zbud_pool *pool; in zbud_zpool_create() local
146 pool = zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL); in zbud_zpool_create()
147 if (pool) { in zbud_zpool_create()
148 pool->zpool = zpool; in zbud_zpool_create()
149 pool->zpool_ops = zpool_ops; in zbud_zpool_create()
151 return pool; in zbud_zpool_create()
154 static void zbud_zpool_destroy(void *pool) in zbud_zpool_destroy() argument
156 zbud_destroy_pool(pool); in zbud_zpool_destroy()
159 static int zbud_zpool_malloc(void *pool, size_t size, gfp_t gfp, in zbud_zpool_malloc() argument
162 return zbud_alloc(pool, size, gfp, handle); in zbud_zpool_malloc()
164 static void zbud_zpool_free(void *pool, unsigned long handle) in zbud_zpool_free() argument
166 zbud_free(pool, handle); in zbud_zpool_free()
169 static int zbud_zpool_shrink(void *pool, unsigned int pages, in zbud_zpool_shrink() argument
176 ret = zbud_reclaim_page(pool, 8); in zbud_zpool_shrink()
188 static void *zbud_zpool_map(void *pool, unsigned long handle, in zbud_zpool_map() argument
191 return zbud_map(pool, handle); in zbud_zpool_map()
193 static void zbud_zpool_unmap(void *pool, unsigned long handle) in zbud_zpool_unmap() argument
195 zbud_unmap(pool, handle); in zbud_zpool_unmap()
198 static u64 zbud_zpool_total_size(void *pool) in zbud_zpool_total_size() argument
200 return zbud_get_pool_size(pool) * PAGE_SIZE; in zbud_zpool_total_size()
307 struct zbud_pool *pool; in zbud_create_pool() local
310 pool = kzalloc(sizeof(struct zbud_pool), gfp); in zbud_create_pool()
311 if (!pool) in zbud_create_pool()
313 spin_lock_init(&pool->lock); in zbud_create_pool()
315 INIT_LIST_HEAD(&pool->unbuddied[i]); in zbud_create_pool()
316 INIT_LIST_HEAD(&pool->buddied); in zbud_create_pool()
317 INIT_LIST_HEAD(&pool->lru); in zbud_create_pool()
318 pool->pages_nr = 0; in zbud_create_pool()
319 pool->ops = ops; in zbud_create_pool()
320 return pool; in zbud_create_pool()
329 void zbud_destroy_pool(struct zbud_pool *pool) in zbud_destroy_pool() argument
331 kfree(pool); in zbud_destroy_pool()
353 int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, in zbud_alloc() argument
366 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()
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()
504 int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries) in zbud_reclaim_page() argument
510 spin_lock(&pool->lock); in zbud_reclaim_page()
511 if (!pool->ops || !pool->ops->evict || list_empty(&pool->lru) || in zbud_reclaim_page()
513 spin_unlock(&pool->lock); in zbud_reclaim_page()
517 zhdr = list_tail_entry(&pool->lru, struct zbud_header, lru); in zbud_reclaim_page()
532 spin_unlock(&pool->lock); in zbud_reclaim_page()
536 ret = pool->ops->evict(pool, first_handle); in zbud_reclaim_page()
541 ret = pool->ops->evict(pool, last_handle); in zbud_reclaim_page()
546 spin_lock(&pool->lock); in zbud_reclaim_page()
554 pool->pages_nr--; in zbud_reclaim_page()
555 spin_unlock(&pool->lock); in zbud_reclaim_page()
561 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_reclaim_page()
564 list_add(&zhdr->buddy, &pool->buddied); in zbud_reclaim_page()
568 list_add(&zhdr->lru, &pool->lru); in zbud_reclaim_page()
570 spin_unlock(&pool->lock); in zbud_reclaim_page()
586 void *zbud_map(struct zbud_pool *pool, unsigned long handle) in zbud_map() argument
596 void zbud_unmap(struct zbud_pool *pool, unsigned long handle) in zbud_unmap() argument
607 u64 zbud_get_pool_size(struct zbud_pool *pool) in zbud_get_pool_size() argument
609 return pool->pages_nr; in zbud_get_pool_size()