• Home
  • Raw
  • Download

Lines Matching full:pool

48     * - a pointer to the child pool to which this element belongs, or
62 /* Next page in the same child pool. */
83 * pool has been destroyed). Mark the element as freed and free the whole page
99 * Create a parent pool for the allocation of same-sized objects.
122 * Create a child pool linked to the given parent.
124 void slab_create_child(struct slab_child_pool *pool, in slab_create_child() argument
127 pool->parent = parent; in slab_create_child()
128 pool->pages = NULL; in slab_create_child()
129 pool->free = NULL; in slab_create_child()
130 pool->migrated = NULL; in slab_create_child()
134 * Destroy the child pool.
136 * Pages associated to the pool will be orphaned. They are eventually freed
139 void slab_destroy_child(struct slab_child_pool *pool) in slab_destroy_child() argument
141 if (!pool->parent) in slab_destroy_child()
144 simple_mtx_lock(&pool->parent->mutex); in slab_destroy_child()
146 while (pool->pages) { in slab_destroy_child()
147 struct slab_page_header *page = pool->pages; in slab_destroy_child()
148 pool->pages = page->u.next; in slab_destroy_child()
149 p_atomic_set(&page->u.num_remaining, pool->parent->num_elements); in slab_destroy_child()
151 for (unsigned i = 0; i < pool->parent->num_elements; ++i) { in slab_destroy_child()
152 struct slab_element_header *elt = slab_get_element(pool->parent, page, i); in slab_destroy_child()
157 while (pool->migrated) { in slab_destroy_child()
158 struct slab_element_header *elt = pool->migrated; in slab_destroy_child()
159 pool->migrated = elt->next; in slab_destroy_child()
163 simple_mtx_unlock(&pool->parent->mutex); in slab_destroy_child()
165 while (pool->free) { in slab_destroy_child()
166 struct slab_element_header *elt = pool->free; in slab_destroy_child()
167 pool->free = elt->next; in slab_destroy_child()
172 pool->parent = NULL; in slab_destroy_child()
176 slab_add_new_page(struct slab_child_pool *pool) in slab_add_new_page() argument
179 pool->parent->num_elements * pool->parent->element_size); in slab_add_new_page()
184 for (unsigned i = 0; i < pool->parent->num_elements; ++i) { in slab_add_new_page()
185 struct slab_element_header *elt = slab_get_element(pool->parent, page, i); in slab_add_new_page()
186 elt->owner = (intptr_t)pool; in slab_add_new_page()
189 elt->next = pool->free; in slab_add_new_page()
190 pool->free = elt; in slab_add_new_page()
194 page->u.next = pool->pages; in slab_add_new_page()
195 pool->pages = page; in slab_add_new_page()
201 * Allocate an object from the child pool. Single-threaded (i.e. the caller
202 * must ensure that no operation happens on the same child pool in another
206 slab_alloc(struct slab_child_pool *pool) in slab_alloc() argument
210 if (!pool->free) { in slab_alloc()
212 * different child pool. in slab_alloc()
214 simple_mtx_lock(&pool->parent->mutex); in slab_alloc()
215 pool->free = pool->migrated; in slab_alloc()
216 pool->migrated = NULL; in slab_alloc()
217 simple_mtx_unlock(&pool->parent->mutex); in slab_alloc()
220 if (!pool->free && !slab_add_new_page(pool)) in slab_alloc()
224 elt = pool->free; in slab_alloc()
225 pool->free = elt->next; in slab_alloc()
235 * must ensure that no operation happens on the same child pool in another
238 * Freeing an object in a different child pool from the one where it was
239 * allocated is allowed, as long the pool belong to the same parent. No
242 void slab_free(struct slab_child_pool *pool, void *ptr) in slab_free() argument
250 if (p_atomic_read(&elt->owner) == (intptr_t)pool) { in slab_free()
254 elt->next = pool->free; in slab_free()
255 pool->free = elt; in slab_free()
260 if (pool->parent) in slab_free()
261 simple_mtx_lock(&pool->parent->mutex); in slab_free()
263 /* Note: we _must_ re-read elt->owner here because the owning child pool in slab_free()
272 if (pool->parent) in slab_free()
273 simple_mtx_unlock(&pool->parent->mutex); in slab_free()
275 if (pool->parent) in slab_free()
276 simple_mtx_unlock(&pool->parent->mutex); in slab_free()