Lines Matching refs:pool

26 /* Mutex pool routines.  These routines are designed to be used as short
28 * calling msleep()). They operate using a shared pool. A mutex is chosen
29 * from the pool based on the supplied pointer (which may or may not be
42 * - pool/pool dependency ordering cannot be depended on.
59 static MALLOC_DEFINE(M_MTXPOOL, "mtx_pool", "mutex pool");
94 * Return the (shared) pool mutex associated with the specified address.
100 mtx_pool_find(struct mtx_pool *pool, void *ptr)
104 KASSERT(pool != NULL, ("_mtx_pool_find(): null pool"));
109 p = ((HASH_MULTIPLIER * (uintptr_t)ptr) >> pool->mtx_pool_shift) &
110 pool->mtx_pool_mask;
111 return (&pool->mtx_pool_ary[p]);
115 mtx_pool_initialize(struct mtx_pool *pool, const char *mtx_name, int pool_size,
120 pool->mtx_pool_size = pool_size;
121 pool->mtx_pool_mask = pool_size - 1;
124 pool->mtx_pool_shift = POINTER_BITS - maskbits;
125 pool->mtx_pool_next = 0;
127 mtx_init(&pool->mtx_pool_ary[i], mtx_name, NULL, opts);
133 struct mtx_pool *pool;
136 printf("WARNING: %s pool size is not a power of 2.\n",
140 pool = malloc(sizeof (struct mtx_pool) +
143 mtx_pool_initialize(pool, mtx_name, pool_size, opts);
144 return pool;
151 struct mtx_pool *pool = *poolp;
153 for (i = pool->mtx_pool_size - 1; i >= 0; --i)
154 mtx_destroy(&pool->mtx_pool_ary[i]);
155 free(pool, M_MTXPOOL);
167 * Obtain a (shared) mutex from the pool. The returned mutex is a leaf
172 mtx_pool_alloc(struct mtx_pool *pool)
176 KASSERT(pool != NULL, ("mtx_pool_alloc(): null pool"));
182 i = pool->mtx_pool_next;
183 pool->mtx_pool_next = (i + 1) & pool->mtx_pool_mask;
184 return (&pool->mtx_pool_ary[i]);