Lines Matching refs:pool
124 static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle) in zbud_zpool_evict() argument
126 return zpool_evict(pool, handle); in zbud_zpool_evict()
139 static void zbud_zpool_destroy(void *pool) in zbud_zpool_destroy() argument
141 zbud_destroy_pool(pool); in zbud_zpool_destroy()
144 static int zbud_zpool_malloc(void *pool, size_t size, gfp_t gfp, in zbud_zpool_malloc() argument
147 return zbud_alloc(pool, size, gfp, handle); in zbud_zpool_malloc()
149 static void zbud_zpool_free(void *pool, unsigned long handle) in zbud_zpool_free() argument
151 zbud_free(pool, handle); in zbud_zpool_free()
154 static int zbud_zpool_shrink(void *pool, unsigned int pages, in zbud_zpool_shrink() argument
161 ret = zbud_reclaim_page(pool, 8); in zbud_zpool_shrink()
173 static void *zbud_zpool_map(void *pool, unsigned long handle, in zbud_zpool_map() argument
176 return zbud_map(pool, handle); in zbud_zpool_map()
178 static void zbud_zpool_unmap(void *pool, unsigned long handle) in zbud_zpool_unmap() argument
180 zbud_unmap(pool, handle); in zbud_zpool_unmap()
183 static u64 zbud_zpool_total_size(void *pool) in zbud_zpool_total_size() argument
185 return zbud_get_pool_size(pool) * PAGE_SIZE; in zbud_zpool_total_size()
292 struct zbud_pool *pool; in zbud_create_pool() local
295 pool = kmalloc(sizeof(struct zbud_pool), gfp); in zbud_create_pool()
296 if (!pool) in zbud_create_pool()
298 spin_lock_init(&pool->lock); in zbud_create_pool()
300 INIT_LIST_HEAD(&pool->unbuddied[i]); in zbud_create_pool()
301 INIT_LIST_HEAD(&pool->buddied); in zbud_create_pool()
302 INIT_LIST_HEAD(&pool->lru); in zbud_create_pool()
303 pool->pages_nr = 0; in zbud_create_pool()
304 pool->ops = ops; in zbud_create_pool()
305 return pool; in zbud_create_pool()
314 void zbud_destroy_pool(struct zbud_pool *pool) in zbud_destroy_pool() argument
316 kfree(pool); in zbud_destroy_pool()
338 int zbud_alloc(struct zbud_pool *pool, size_t size, gfp_t gfp, in zbud_alloc() argument
351 spin_lock(&pool->lock); in zbud_alloc()
356 if (!list_empty(&pool->unbuddied[i])) { in zbud_alloc()
357 zhdr = list_first_entry(&pool->unbuddied[i], in zbud_alloc()
369 spin_unlock(&pool->lock); in zbud_alloc()
373 spin_lock(&pool->lock); in zbud_alloc()
374 pool->pages_nr++; in zbud_alloc()
387 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_alloc()
390 list_add(&zhdr->buddy, &pool->buddied); in zbud_alloc()
396 list_add(&zhdr->lru, &pool->lru); in zbud_alloc()
399 spin_unlock(&pool->lock); in zbud_alloc()
414 void zbud_free(struct zbud_pool *pool, unsigned long handle) in zbud_free() argument
419 spin_lock(&pool->lock); in zbud_free()
430 spin_unlock(&pool->lock); in zbud_free()
441 pool->pages_nr--; in zbud_free()
445 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_free()
448 spin_unlock(&pool->lock); in zbud_free()
489 int zbud_reclaim_page(struct zbud_pool *pool, unsigned int retries) in zbud_reclaim_page() argument
495 spin_lock(&pool->lock); in zbud_reclaim_page()
496 if (!pool->ops || !pool->ops->evict || list_empty(&pool->lru) || in zbud_reclaim_page()
498 spin_unlock(&pool->lock); in zbud_reclaim_page()
502 zhdr = list_tail_entry(&pool->lru, struct zbud_header, lru); in zbud_reclaim_page()
517 spin_unlock(&pool->lock); in zbud_reclaim_page()
521 ret = pool->ops->evict(pool, first_handle); in zbud_reclaim_page()
526 ret = pool->ops->evict(pool, last_handle); in zbud_reclaim_page()
531 spin_lock(&pool->lock); in zbud_reclaim_page()
539 pool->pages_nr--; in zbud_reclaim_page()
540 spin_unlock(&pool->lock); in zbud_reclaim_page()
546 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_reclaim_page()
549 list_add(&zhdr->buddy, &pool->buddied); in zbud_reclaim_page()
553 list_add(&zhdr->lru, &pool->lru); in zbud_reclaim_page()
555 spin_unlock(&pool->lock); in zbud_reclaim_page()
571 void *zbud_map(struct zbud_pool *pool, unsigned long handle) in zbud_map() argument
581 void zbud_unmap(struct zbud_pool *pool, unsigned long handle) in zbud_unmap() argument
592 u64 zbud_get_pool_size(struct zbud_pool *pool) in zbud_get_pool_size() argument
594 return pool->pages_nr; in zbud_get_pool_size()