Lines Matching refs:pool
19 objpool_init_percpu_slot(struct objpool_head *pool, in objpool_init_percpu_slot() argument
24 void *obj = (void *)&slot->entries[pool->capacity]; in objpool_init_percpu_slot()
28 slot->mask = pool->capacity - 1; in objpool_init_percpu_slot()
37 obj = obj + pool->obj_size; in objpool_init_percpu_slot()
40 pool->nr_objs++; in objpool_init_percpu_slot()
48 objpool_init_percpu_slots(struct objpool_head *pool, int nr_objs, in objpool_init_percpu_slots() argument
63 nodes = nr_objs / pool->nr_possible_cpus; in objpool_init_percpu_slots()
64 if (cpu_count < (nr_objs % pool->nr_possible_cpus)) in objpool_init_percpu_slots()
68 size = struct_size(slot, entries, pool->capacity) + in objpool_init_percpu_slots()
69 pool->obj_size * nodes; in objpool_init_percpu_slots()
83 if ((pool->gfp & (GFP_ATOMIC | GFP_KERNEL)) != GFP_ATOMIC) in objpool_init_percpu_slots()
84 slot = __vmalloc_node(size, sizeof(void *), pool->gfp, in objpool_init_percpu_slots()
88 slot = kmalloc_node(size, pool->gfp, cpu_to_node(i)); in objpool_init_percpu_slots()
93 pool->cpu_slots[i] = slot; in objpool_init_percpu_slots()
96 rc = objpool_init_percpu_slot(pool, slot, nodes, context, objinit); in objpool_init_percpu_slots()
105 static void objpool_fini_percpu_slots(struct objpool_head *pool) in objpool_fini_percpu_slots() argument
109 if (!pool->cpu_slots) in objpool_fini_percpu_slots()
113 kvfree(pool->cpu_slots[i]); in objpool_fini_percpu_slots()
114 kfree(pool->cpu_slots); in objpool_fini_percpu_slots()
118 int objpool_init(struct objpool_head *pool, int nr_objs, int object_size, in objpool_init() argument
138 memset(pool, 0, sizeof(struct objpool_head)); in objpool_init()
139 pool->nr_possible_cpus = num_possible_cpus(); in objpool_init()
140 pool->obj_size = object_size; in objpool_init()
141 pool->capacity = capacity; in objpool_init()
142 pool->gfp = gfp & ~__GFP_ZERO; in objpool_init()
143 pool->context = context; in objpool_init()
144 pool->release = release; in objpool_init()
146 pool->cpu_slots = kzalloc(slot_size, pool->gfp); in objpool_init()
147 if (!pool->cpu_slots) in objpool_init()
151 rc = objpool_init_percpu_slots(pool, nr_objs, context, objinit); in objpool_init()
153 objpool_fini_percpu_slots(pool); in objpool_init()
155 refcount_set(&pool->ref, pool->nr_objs + 1); in objpool_init()
162 void objpool_free(struct objpool_head *pool) in objpool_free() argument
164 if (!pool->cpu_slots) in objpool_free()
168 objpool_fini_percpu_slots(pool); in objpool_free()
171 if (pool->release) in objpool_free()
172 pool->release(pool, pool->context); in objpool_free()
177 int objpool_drop(void *obj, struct objpool_head *pool) in objpool_drop() argument
179 if (!obj || !pool) in objpool_drop()
182 if (refcount_dec_and_test(&pool->ref)) { in objpool_drop()
183 objpool_free(pool); in objpool_drop()
192 void objpool_fini(struct objpool_head *pool) in objpool_fini() argument
197 while (objpool_pop(pool)) in objpool_fini()
200 if (refcount_sub_and_test(count, &pool->ref)) in objpool_fini()
201 objpool_free(pool); in objpool_fini()