FreeBSD kernel kern code
kern_mtxpool.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/systm.h>
Include dependency graph for kern_mtxpool.c:

Go to the source code of this file.

Data Structures

struct  mtxpool_header
 
struct  mtx_pool
 
struct  mtx_pool_lockbuilder
 

Macros

#define MTX_POOL_LOCKBUILDER_SIZE   128
 
#define MTX_POOL_SLEEP_SIZE   128
 
#define mtx_pool_size   mtx_pool_header.mtxpool_size
 
#define mtx_pool_mask   mtx_pool_header.mtxpool_mask
 
#define mtx_pool_shift   mtx_pool_header.mtxpool_shift
 
#define mtx_pool_next   mtx_pool_header.mtxpool_next
 
#define POINTER_BITS   64
 
#define HASH_MULTIPLIER   11400714819323198485u /* (2^64)*(sqrt(5)-1)/2 */
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_MTXPOOL,"mtx_pool","mutex pool")
 
struct mtx * mtx_pool_find (struct mtx_pool *pool, void *ptr)
 
static void mtx_pool_initialize (struct mtx_pool *pool, const char *mtx_name, int pool_size, int opts)
 
struct mtx_poolmtx_pool_create (const char *mtx_name, int pool_size, int opts)
 
void mtx_pool_destroy (struct mtx_pool **poolp)
 
static void mtx_pool_setup_static (void *dummy __unused)
 
static void mtx_pool_setup_dynamic (void *dummy __unused)
 
struct mtx * mtx_pool_alloc (struct mtx_pool *pool)
 
 SYSINIT (mtxpooli1, SI_SUB_MTX_POOL_STATIC, SI_ORDER_FIRST, mtx_pool_setup_static, NULL)
 
 SYSINIT (mtxpooli2, SI_SUB_MTX_POOL_DYNAMIC, SI_ORDER_FIRST, mtx_pool_setup_dynamic, NULL)
 

Variables

static struct mtx_pool_lockbuilder lockbuilder_pool
 
struct mtx_poolmtxpool_sleep
 
struct mtx_poolmtxpool_lockbuilder
 

Macro Definition Documentation

#define HASH_MULTIPLIER   11400714819323198485u /* (2^64)*(sqrt(5)-1)/2 */

Definition at line 96 of file kern_mtxpool.c.

Referenced by mtx_pool_find().

#define MTX_POOL_LOCKBUILDER_SIZE   128

Definition at line 63 of file kern_mtxpool.c.

Referenced by mtx_pool_setup_static().

#define mtx_pool_mask   mtx_pool_header.mtxpool_mask

Definition at line 87 of file kern_mtxpool.c.

#define mtx_pool_next   mtx_pool_header.mtxpool_next

Definition at line 89 of file kern_mtxpool.c.

#define mtx_pool_shift   mtx_pool_header.mtxpool_shift

Definition at line 88 of file kern_mtxpool.c.

#define mtx_pool_size   mtx_pool_header.mtxpool_size

Definition at line 86 of file kern_mtxpool.c.

#define MTX_POOL_SLEEP_SIZE   128

Definition at line 66 of file kern_mtxpool.c.

Referenced by mtx_pool_setup_dynamic().

#define POINTER_BITS   64

Definition at line 95 of file kern_mtxpool.c.

Referenced by mtx_pool_initialize().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static MALLOC_DEFINE ( M_MTXPOOL  ,
"mtx_pool"  ,
"mutex pool"   
)
static
struct mtx* mtx_pool_alloc ( struct mtx_pool pool)

Definition at line 190 of file kern_mtxpool.c.

References mtx_pool::mtx_pool_ary.

struct mtx_pool* mtx_pool_create ( const char *  mtx_name,
int  pool_size,
int  opts 
)

Definition at line 140 of file kern_mtxpool.c.

References malloc(), mtx_pool_initialize(), and printf().

Referenced by mtx_pool_setup_dynamic(), and selectinit().

Here is the call graph for this function:

Here is the caller graph for this function:

void mtx_pool_destroy ( struct mtx_pool **  poolp)

Definition at line 157 of file kern_mtxpool.c.

References free(), mtx_destroy(), and mtx_pool::mtx_pool_ary.

Here is the call graph for this function:

struct mtx* mtx_pool_find ( struct mtx_pool pool,
void *  ptr 
)

Definition at line 109 of file kern_mtxpool.c.

References HASH_MULTIPLIER, and mtx_pool::mtx_pool_ary.

Referenced by bdone(), biodone(), biowait(), bpin(), bunpin(), bunpin_wait(), bwait(), foffset_lock(), foffset_unlock(), get_advice(), selrecord(), vn_read(), and vn_write().

Here is the caller graph for this function:

static void mtx_pool_initialize ( struct mtx_pool pool,
const char *  mtx_name,
int  pool_size,
int  opts 
)
static

Definition at line 124 of file kern_mtxpool.c.

References mtx_init(), mtx_pool::mtx_pool_ary, and POINTER_BITS.

Referenced by mtx_pool_create(), and mtx_pool_setup_static().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mtx_pool_setup_dynamic ( void *dummy  __unused)
static

Definition at line 178 of file kern_mtxpool.c.

References mtx_pool_create(), and MTX_POOL_SLEEP_SIZE.

Here is the call graph for this function:

static void mtx_pool_setup_static ( void *dummy  __unused)
static

Definition at line 169 of file kern_mtxpool.c.

References lockbuilder_pool, mtx_pool_initialize(), and MTX_POOL_LOCKBUILDER_SIZE.

Here is the call graph for this function:

SYSINIT ( mtxpooli1  ,
SI_SUB_MTX_POOL_STATIC  ,
SI_ORDER_FIRST  ,
mtx_pool_setup_static  ,
NULL   
)
SYSINIT ( mtxpooli2  ,
SI_SUB_MTX_POOL_DYNAMIC  ,
SI_ORDER_FIRST  ,
mtx_pool_setup_dynamic  ,
NULL   
)

Variable Documentation

struct mtx_pool_lockbuilder lockbuilder_pool
static

Referenced by mtx_pool_setup_static().

struct mtx_pool* mtxpool_lockbuilder

Definition at line 92 of file kern_mtxpool.c.