Lines Matching refs: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()
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()
330 void zbud_destroy_pool(struct zbud_pool *pool) in zbud_destroy_pool() argument
332 kfree(pool); in zbud_destroy_pool()
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()
372 if (!list_empty(&pool->unbuddied[i])) { in zbud_alloc()
373 zhdr = list_first_entry(&pool->unbuddied[i], in zbud_alloc()
385 spin_unlock(&pool->lock); in zbud_alloc()
389 spin_lock(&pool->lock); in zbud_alloc()
390 pool->pages_nr++; in zbud_alloc()
403 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_alloc()
406 list_add(&zhdr->buddy, &pool->buddied); in zbud_alloc()
412 list_add(&zhdr->lru, &pool->lru); in zbud_alloc()
415 spin_unlock(&pool->lock); in zbud_alloc()
430 void zbud_free(struct zbud_pool *pool, unsigned long handle) in zbud_free() argument
435 spin_lock(&pool->lock); in zbud_free()
446 spin_unlock(&pool->lock); in zbud_free()
457 pool->pages_nr--; in zbud_free()
461 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_free()
464 spin_unlock(&pool->lock); in zbud_free()
502 int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries) in zbud_reclaim_page() argument
508 spin_lock(&pool->lock); in zbud_reclaim_page()
509 if (!pool->ops || !pool->ops->evict || list_empty(&pool->lru) || in zbud_reclaim_page()
511 spin_unlock(&pool->lock); in zbud_reclaim_page()
515 zhdr = list_last_entry(&pool->lru, struct zbud_header, lru); in zbud_reclaim_page()
530 spin_unlock(&pool->lock); in zbud_reclaim_page()
534 ret = pool->ops->evict(pool, first_handle); in zbud_reclaim_page()
539 ret = pool->ops->evict(pool, last_handle); in zbud_reclaim_page()
544 spin_lock(&pool->lock); in zbud_reclaim_page()
552 pool->pages_nr--; in zbud_reclaim_page()
553 spin_unlock(&pool->lock); in zbud_reclaim_page()
559 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_reclaim_page()
562 list_add(&zhdr->buddy, &pool->buddied); in zbud_reclaim_page()
566 list_add(&zhdr->lru, &pool->lru); in zbud_reclaim_page()
568 spin_unlock(&pool->lock); in zbud_reclaim_page()
584 void *zbud_map(struct zbud_pool *pool, unsigned long handle) in zbud_map() argument
594 void zbud_unmap(struct zbud_pool *pool, unsigned long handle) in zbud_unmap() argument
605 u64 zbud_get_pool_size(struct zbud_pool *pool) in zbud_get_pool_size() argument
607 return pool->pages_nr; in zbud_get_pool_size()