Lines Matching refs:slab_pool
35 struct slab *slab_pool = (struct slab *)kmalloc(sizeof(struct slab), 0); in slab_create() local
38 if (slab_pool == NULL) in slab_create()
44 memset(slab_pool, 0, sizeof(struct slab)); in slab_create()
46 slab_pool->size = SIZEOF_LONG_ALIGN(size); in slab_create()
47 slab_pool->count_total_using = 0; in slab_create()
48 slab_pool->count_total_free = 0; in slab_create()
50 slab_pool->cache_pool_entry = (struct slab_obj *)kmalloc(sizeof(struct slab_obj), 0); in slab_create()
53 if (slab_pool->cache_pool_entry == NULL) in slab_create()
56 kfree(slab_pool); in slab_create()
59 memset(slab_pool->cache_pool_entry, 0, sizeof(struct slab_obj)); in slab_create()
62 slab_pool->cache_dma_pool_entry = NULL; in slab_create()
65 slab_pool->constructor = constructor; in slab_create()
66 slab_pool->destructor = destructor; in slab_create()
68 list_init(&slab_pool->cache_pool_entry->list); in slab_create()
71 slab_pool->cache_pool_entry->page = alloc_pages(ZONE_NORMAL, 1, PAGE_KERNEL); in slab_create()
74 if (slab_pool->cache_pool_entry->page == NULL) in slab_create()
77 kfree(slab_pool->cache_pool_entry); in slab_create()
78 kfree(slab_pool); in slab_create()
84 slab_pool->cache_pool_entry->count_using = 0; in slab_create()
85 slab_pool->cache_pool_entry->count_free = PAGE_2M_SIZE / slab_pool->size; in slab_create()
87 slab_pool->count_total_free = slab_pool->cache_pool_entry->count_free; in slab_create()
89 slab_pool->cache_pool_entry->vaddr = phys_2_virt(slab_pool->cache_pool_entry->page->addr_phys); in slab_create()
92 slab_pool->cache_pool_entry->bmp_count = slab_pool->cache_pool_entry->count_free; in slab_create()
95 …slab_pool->cache_pool_entry->bmp_len = ((slab_pool->cache_pool_entry->bmp_count + sizeof(ul) * 8 -… in slab_create()
97 slab_pool->cache_pool_entry->bmp = (ul *)kmalloc(slab_pool->cache_pool_entry->bmp_len, 0); in slab_create()
100 if (slab_pool->cache_pool_entry->bmp == NULL) in slab_create()
103 free_pages(slab_pool->cache_pool_entry->page, 1); in slab_create()
104 kfree(slab_pool->cache_pool_entry); in slab_create()
105 kfree(slab_pool); in slab_create()
109 memset(slab_pool->cache_pool_entry->bmp, 0, slab_pool->cache_pool_entry->bmp_len); in slab_create()
111 return slab_pool; in slab_create()
121 ul slab_destroy(struct slab *slab_pool) in slab_destroy() argument
123 struct slab_obj *slab_obj_ptr = slab_pool->cache_pool_entry; in slab_destroy()
124 if (slab_pool->count_total_using) in slab_destroy()
152 kfree(slab_pool); in slab_destroy()
163 void *slab_malloc(struct slab *slab_pool, ul arg) in slab_malloc() argument
165 struct slab_obj *slab_obj_ptr = slab_pool->cache_pool_entry; in slab_malloc()
169 if (slab_pool->count_total_free == 0) in slab_malloc()
194 tmp_slab_obj->count_free = PAGE_2M_SIZE / slab_pool->size; in slab_malloc()
212 list_add(&slab_pool->cache_pool_entry->list, &tmp_slab_obj->list); in slab_malloc()
214 slab_pool->count_total_free += tmp_slab_obj->count_free; in slab_malloc()
249 ++(slab_pool->count_total_using); in slab_malloc()
250 --(slab_pool->count_total_free); in slab_malloc()
252 if (slab_pool->constructor != NULL) in slab_malloc()
255 … return slab_pool->constructor((char *)slab_obj_ptr->vaddr + slab_pool->size * i, arg); in slab_malloc()
259 return (void *)((char *)slab_obj_ptr->vaddr + slab_pool->size * i); in slab_malloc()
263 } while (slab_obj_ptr != slab_pool->cache_pool_entry); in slab_malloc()
289 ul slab_free(struct slab *slab_pool, void *addr, ul arg) in slab_free() argument
291 struct slab_obj *slab_obj_ptr = slab_pool->cache_pool_entry; in slab_free()
304 int index = (addr - slab_obj_ptr->vaddr) / slab_pool->size; in slab_free()
312 ++(slab_pool->count_total_free); in slab_free()
313 --(slab_pool->count_total_using); in slab_free()
316 if (slab_pool->destructor != NULL) in slab_free()
317 slab_pool->destructor((char *)slab_obj_ptr->vaddr + slab_pool->size * index, arg); in slab_free()
320 …j_ptr->count_using == 0) && ((slab_pool->count_total_free >> 1) >= slab_obj_ptr->count_free) && (s… in slab_free()
324 slab_pool->count_total_free -= slab_obj_ptr->count_free; in slab_free()
335 } while (slab_obj_ptr != slab_pool->cache_pool_entry); in slab_free()