Lines Matching +full:- +full:v

1 // SPDX-License-Identifier: BSD-2-Clause
3 * Copyright (c) 2014, STMicroelectronics International N.V.
4 * Copyright (c) 2018-2019, Linaro Limited
29 * - the total size (in bytes) of the pool
30 * - the offset of the last item allocated in the pool (struct
31 * mempool_item). This offset is -1 is nothing is allocated yet.
34 * - the size of the item
35 * - the offsets, in the pool, of the previous and next items
40 * - the heap is never used.
41 * - there is no assumption on the size of the allocated memory buffers. Only
43 * - a constant time allocation and free as there is no list scan
44 * - but a potentially fragmented memory as the allocation does not take into
49 * - should have a short life cycle
50 * - if an item A is allocated before another item B, then A should be
75 size_t sz = pool->size - raw_malloc_get_ctx_size(); in init_mpool()
76 vaddr_t v = ROUNDDOWN(pool->data + sz, sizeof(long) * 2); in init_mpool() local
79 * v is the placed as close to the end of the data pool as possible in init_mpool()
85 assert(v > pool->data); in init_mpool()
86 pool->mctx = (struct malloc_ctx *)v; in init_mpool()
87 raw_malloc_init_ctx(pool->mctx); in init_mpool()
88 raw_malloc_add_pool(pool->mctx, (void *)pool->data, v - pool->data); in init_mpool()
94 mutex_lock_recursive(&pool->mu); in get_pool()
95 if (!pool->mctx) in get_pool()
104 if (mutex_get_recursive_lock_depth(&pool->mu) == 1) { in put_pool()
109 if (pool->release_mem) { in put_pool()
110 pool->mctx = NULL; in put_pool()
111 pool->release_mem((void *)pool->data, pool->size); in put_pool()
114 mutex_unlock_recursive(&pool->mu); in put_pool()
125 assert(!((vaddr_t)data & (MEMPOOL_ALIGN - 1))); in mempool_alloc_pool()
128 pool->size = size; in mempool_alloc_pool()
129 pool->data = (vaddr_t)data; in mempool_alloc_pool()
131 pool->release_mem = release_mem; in mempool_alloc_pool()
132 mutex_init_recursive(&pool->mu); in mempool_alloc_pool()
147 p = raw_malloc(0, 0, size, pool->mctx); in mempool_alloc()
152 raw_malloc_get_stats(pool->mctx, &stats); in mempool_alloc()
153 if (stats.max_allocated > pool->max_allocated) { in mempool_alloc()
154 pool->max_allocated = stats.max_allocated; in mempool_alloc()
156 pool->max_allocated); in mempool_alloc()
185 raw_free(ptr, pool->mctx, false /*!wipe*/); in mempool_free()