FreeBSD kernel kern code
subr_lock.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_mprof.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/lock_profile.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/pcpu.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <machine/cpufunc.h>
Include dependency graph for subr_lock.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
 SDT_PROVIDER_DEFINE (lock)
 
 SDT_PROBE_DEFINE1 (lock,,, starvation, "u_int")
 
 CTASSERT (LOCK_CLASS_MAX==15)
 
void lock_init (struct lock_object *lock, struct lock_class *class, const char *name, const char *type, int flags)
 
void lock_destroy (struct lock_object *lock)
 
static SYSCTL_NODE (_debug, OID_AUTO, lock, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "lock debugging")
 
static SYSCTL_NODE (_debug_lock, OID_AUTO, delay, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "lock delay")
 
 SYSCTL_INT (_debug_lock_delay, OID_AUTO, starvation_limit, CTLFLAG_RW, &starvation_limit, 0, "")
 
 SYSCTL_INT (_debug_lock_delay, OID_AUTO, restrict_starvation, CTLFLAG_RW, &restrict_starvation, 0, "")
 
void lock_delay (struct lock_delay_arg *la)
 
static u_int lock_roundup_2 (u_int val)
 
void lock_delay_default_init (struct lock_delay_config *lc)
 
 SYSCTL_U16 (_debug_lock, OID_AUTO, delay_base, CTLFLAG_RW, &locks_delay.base, 0, "")
 
 SYSCTL_U16 (_debug_lock, OID_AUTO, delay_max, CTLFLAG_RW, &locks_delay.max, 0, "")
 
 SYSCTL_U16 (_debug_lock, OID_AUTO, delay_retries, CTLFLAG_RW, &locks_delay_retries, 0, "")
 
 SYSCTL_U16 (_debug_lock, OID_AUTO, delay_loops, CTLFLAG_RW, &locks_delay_loops, 0, "")
 
static void locks_delay_init (void *arg __unused)
 
 LOCK_DELAY_SYSINIT (locks_delay_init)
 

Variables

struct lock_class * lock_classes [LOCK_CLASS_MAX+1]
 
static u_int __read_mostly starvation_limit = 131072
 
static u_int __read_mostly restrict_starvation = 0
 
struct lock_delay_config __read_frequently locks_delay
 
u_short __read_frequently locks_delay_retries
 
u_short __read_frequently locks_delay_loops
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ CTASSERT()

CTASSERT ( LOCK_CLASS_MAX  = =15)

◆ lock_delay()

void lock_delay ( struct lock_delay_arg *  la)

◆ lock_delay_default_init()

void lock_delay_default_init ( struct lock_delay_config *  lc)

Definition at line 164 of file subr_lock.c.

References lc, lock_roundup_2(), and mp_ncpus.

Referenced by locks_delay_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LOCK_DELAY_SYSINIT()

LOCK_DELAY_SYSINIT ( locks_delay_init  )

◆ lock_destroy()

void lock_destroy ( struct lock_object *  lock)

Definition at line 108 of file subr_lock.c.

Referenced by _mtx_destroy(), _rw_destroy(), lockdestroy(), rm_destroy(), and sx_destroy().

Here is the caller graph for this function:

◆ lock_init()

void lock_init ( struct lock_object *  lock,
struct lock_class *  class,
const char *  name,
const char *  type,
int  flags 
)

Definition at line 83 of file subr_lock.c.

References flags, lock_classes, name, and type.

Referenced by _mtx_init(), _rw_init_flags(), lockinit(), rm_init_flags(), and sx_init_flags().

Here is the caller graph for this function:

◆ lock_roundup_2()

static u_int lock_roundup_2 ( u_int  val)
static

Definition at line 153 of file subr_lock.c.

References res.

Referenced by lock_delay_default_init().

Here is the caller graph for this function:

◆ locks_delay_init()

static void locks_delay_init ( void *arg  __unused)
static

Definition at line 187 of file subr_lock.c.

References lock_delay_default_init(), locks_delay, locks_delay_loops, and locks_delay_retries.

Here is the call graph for this function:

◆ SDT_PROBE_DEFINE1()

SDT_PROBE_DEFINE1 ( lock  ,
starvation  ,
"u_int"   
)

◆ SDT_PROVIDER_DEFINE()

SDT_PROVIDER_DEFINE ( lock  )

◆ SYSCTL_INT() [1/2]

SYSCTL_INT ( _debug_lock_delay  ,
OID_AUTO  ,
restrict_starvation  ,
CTLFLAG_RW  ,
restrict_starvation,
,
""   
)

◆ SYSCTL_INT() [2/2]

SYSCTL_INT ( _debug_lock_delay  ,
OID_AUTO  ,
starvation_limit  ,
CTLFLAG_RW  ,
starvation_limit,
,
""   
)

◆ SYSCTL_NODE() [1/2]

static SYSCTL_NODE ( _debug  ,
OID_AUTO  ,
lock  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
"lock debugging"   
)
static

◆ SYSCTL_NODE() [2/2]

static SYSCTL_NODE ( _debug_lock  ,
OID_AUTO  ,
delay  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
"lock delay"   
)
static

◆ SYSCTL_U16() [1/4]

SYSCTL_U16 ( _debug_lock  ,
OID_AUTO  ,
delay_base  ,
CTLFLAG_RW  ,
&locks_delay.  base,
,
""   
)

◆ SYSCTL_U16() [2/4]

SYSCTL_U16 ( _debug_lock  ,
OID_AUTO  ,
delay_loops  ,
CTLFLAG_RW  ,
locks_delay_loops,
,
""   
)

◆ SYSCTL_U16() [3/4]

SYSCTL_U16 ( _debug_lock  ,
OID_AUTO  ,
delay_max  ,
CTLFLAG_RW  ,
&locks_delay.  max,
,
""   
)

◆ SYSCTL_U16() [4/4]

SYSCTL_U16 ( _debug_lock  ,
OID_AUTO  ,
delay_retries  ,
CTLFLAG_RW  ,
locks_delay_retries,
,
""   
)

Variable Documentation

◆ lock_classes

struct lock_class* lock_classes[LOCK_CLASS_MAX+1]
Initial value:
= {
}
struct lock_class lock_class_lockmgr
Definition: kern_lock.c:163
struct lock_class lock_class_mtx_sleep
Definition: kern_mutex.c:115
struct lock_class lock_class_mtx_spin
Definition: kern_mutex.c:128
struct lock_class lock_class_rm_sleepable
Definition: kern_rmlock.c:102
struct lock_class lock_class_rm
Definition: kern_rmlock.c:88
struct lock_class lock_class_rw
Definition: kern_rwlock.c:82
struct lock_class lock_class_sx
Definition: kern_sx.c:127

Definition at line 72 of file subr_lock.c.

Referenced by lock_init().

◆ locks_delay

struct lock_delay_config __read_frequently locks_delay

Definition at line 173 of file subr_lock.c.

Referenced by locks_delay_init().

◆ locks_delay_loops

u_short __read_frequently locks_delay_loops

Definition at line 175 of file subr_lock.c.

Referenced by locks_delay_init().

◆ locks_delay_retries

u_short __read_frequently locks_delay_retries

Definition at line 174 of file subr_lock.c.

Referenced by locks_delay_init().

◆ restrict_starvation

u_int __read_mostly restrict_starvation = 0
static

Definition at line 127 of file subr_lock.c.

Referenced by lock_delay().

◆ starvation_limit

u_int __read_mostly starvation_limit = 131072
static

Definition at line 123 of file subr_lock.c.

Referenced by lock_delay().