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
 

Macros

#define MTX_POOL_SLEEP_SIZE   1024
 
#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 ("$FreeBSD$")
 
static MALLOC_DEFINE (M_MTXPOOL, "mtx_pool", "mutex pool")
 
struct mtxmtx_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_dynamic (void *dummy __unused)
 
struct mtxmtx_pool_alloc (struct mtx_pool *pool)
 
 SYSINIT (mtxpooli2, SI_SUB_MTX_POOL_DYNAMIC, SI_ORDER_FIRST, mtx_pool_setup_dynamic, NULL)
 

Variables

struct mtx_pool __read_mostlymtxpool_sleep
 

Macro Definition Documentation

◆ HASH_MULTIPLIER

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

Definition at line 88 of file kern_mtxpool.c.

◆ mtx_pool_mask

#define mtx_pool_mask   mtx_pool_header.mtxpool_mask

Definition at line 80 of file kern_mtxpool.c.

◆ mtx_pool_next

#define mtx_pool_next   mtx_pool_header.mtxpool_next

Definition at line 82 of file kern_mtxpool.c.

◆ mtx_pool_shift

#define mtx_pool_shift   mtx_pool_header.mtxpool_shift

Definition at line 81 of file kern_mtxpool.c.

◆ mtx_pool_size

#define mtx_pool_size   mtx_pool_header.mtxpool_size

Definition at line 79 of file kern_mtxpool.c.

◆ MTX_POOL_SLEEP_SIZE

#define MTX_POOL_SLEEP_SIZE   1024

Definition at line 64 of file kern_mtxpool.c.

◆ POINTER_BITS

#define POINTER_BITS   64

Definition at line 87 of file kern_mtxpool.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_MTXPOOL  ,
"mtx_pool"  ,
"mutex pool"   
)
static

◆ mtx_pool_alloc()

struct mtx * mtx_pool_alloc ( struct mtx_pool pool)

Definition at line 173 of file kern_mtxpool.c.

References mtx_pool::mtx_pool_ary.

◆ mtx_pool_create()

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

Definition at line 132 of file kern_mtxpool.c.

References malloc(), mtx, 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:

◆ mtx_pool_destroy()

void mtx_pool_destroy ( struct mtx_pool **  poolp)

Definition at line 149 of file kern_mtxpool.c.

References free(), and mtx_pool::mtx_pool_ary.

Here is the call graph for this function:

◆ mtx_pool_find()

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

Definition at line 101 of file kern_mtxpool.c.

References HASH_MULTIPLIER, and mtx_pool::mtx_pool_ary.

Referenced by bdone(), biodone(), biowait(), bwait(), get_advice(), selrecord(), uipc_close(), uipc_detach(), unp_connectat(), and vfs_unp_reclaim().

Here is the caller graph for this function:

◆ mtx_pool_initialize()

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

Definition at line 116 of file kern_mtxpool.c.

References mtx_pool::mtx_pool_ary, and POINTER_BITS.

Referenced by mtx_pool_create().

Here is the caller graph for this function:

◆ mtx_pool_setup_dynamic()

static void mtx_pool_setup_dynamic ( void *dummy  __unused)
static

Definition at line 161 of file kern_mtxpool.c.

References mtx_pool_create(), MTX_POOL_SLEEP_SIZE, and mtxpool_sleep.

Here is the call graph for this function:

◆ SYSINIT()

SYSINIT ( mtxpooli2  ,
SI_SUB_MTX_POOL_DYNAMIC  ,
SI_ORDER_FIRST  ,
mtx_pool_setup_dynamic  ,
NULL   
)

Variable Documentation

◆ mtxpool_sleep