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 dependancy ordering cannot be depended on.
59 static MALLOC_DEFINE(M_MTXPOOL, "mtx_pool", "mutex pool");
103 * Return the (shared) pool mutex associated with the specified address.
109 mtx_pool_find(struct mtx_pool *pool, void *ptr)
113 KASSERT(pool != NULL, ("_mtx_pool_find(): null pool"));
118 p = ((HASH_MULTIPLIER * (uintptr_t)ptr) >> pool->mtx_pool_shift) &
119 pool->mtx_pool_mask;
120 return (&pool->mtx_pool_ary[p]);
124 mtx_pool_initialize(struct mtx_pool *pool, const char *mtx_name, int pool_size,
129 pool->mtx_pool_size = pool_size;
130 pool->mtx_pool_mask = pool_size - 1;
133 pool->mtx_pool_shift = POINTER_BITS - maskbits;
134 pool->mtx_pool_next = 0;
136 mtx_init(&pool->mtx_pool_ary[i], mtx_name, NULL, opts);
142 struct mtx_pool *pool;
145 printf("WARNING: %s pool size is not a power of 2.\n",
149 pool = malloc(sizeof (struct mtx_pool) +
152 mtx_pool_initialize(pool, mtx_name, pool_size, opts);
153 return pool;
160 struct mtx_pool *pool = *poolp;
162 for (i = pool->mtx_pool_size - 1; i >= 0; --i)
163 mtx_destroy(&pool->mtx_pool_ary[i]);
164 free(pool, M_MTXPOOL);
185 * Obtain a (shared) mutex from the pool. The returned mutex is a leaf
190 mtx_pool_alloc(struct mtx_pool *pool)
194 KASSERT(pool != NULL, ("mtx_pool_alloc(): null pool"));
200 i = pool->mtx_pool_next;
201 pool->mtx_pool_next = (i + 1) & pool->mtx_pool_mask;
202 return (&pool->mtx_pool_ary[i]);
206 * The lockbuilder pool must be initialized early because the lockmgr
211 * We can't call malloc() to dynamically allocate the sleep pool