Lines Matching defs:pool

28 /* Mutex pool routines.  These routines are designed to be used as short
30 * calling msleep()). They operate using a shared pool. A mutex is chosen
31 * from the pool based on the supplied pointer (which may or may not be
44 * - pool/pool dependency ordering cannot be depended on.
60 static MALLOC_DEFINE(M_MTXPOOL, "mtx_pool", "mutex pool");
95 * Return the (shared) pool mutex associated with the specified address.
101 mtx_pool_find(struct mtx_pool *pool, void *ptr)
105 KASSERT(pool != NULL, ("_mtx_pool_find(): null pool"));
110 p = ((HASH_MULTIPLIER * (uintptr_t)ptr) >> pool->mtx_pool_shift) &
111 pool->mtx_pool_mask;
112 return (&pool->mtx_pool_ary[p]);
116 mtx_pool_initialize(struct mtx_pool *pool, const char *mtx_name, int pool_size,
121 pool->mtx_pool_size = pool_size;
122 pool->mtx_pool_mask = pool_size - 1;
125 pool->mtx_pool_shift = POINTER_BITS - maskbits;
126 pool->mtx_pool_next = 0;
128 mtx_init(&pool->mtx_pool_ary[i], mtx_name, NULL, opts);
134 struct mtx_pool *pool;
137 printf("WARNING: %s pool size is not a power of 2.\n",
141 pool = malloc(sizeof (struct mtx_pool) +
144 mtx_pool_initialize(pool, mtx_name, pool_size, opts);
145 return pool;
152 struct mtx_pool *pool = *poolp;
154 for (i = pool->mtx_pool_size - 1; i >= 0; --i)
155 mtx_destroy(&pool->mtx_pool_ary[i]);
156 free(pool, M_MTXPOOL);
168 * Obtain a (shared) mutex from the pool. The returned mutex is a leaf
173 mtx_pool_alloc(struct mtx_pool *pool)
177 KASSERT(pool != NULL, ("mtx_pool_alloc(): null pool"));
183 i = pool->mtx_pool_next;
184 pool->mtx_pool_next = (i + 1) & pool->mtx_pool_mask;
185 return (&pool->mtx_pool_ary[i]);