FreeBSD kernel kern code
subr_witness.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_hwpmc_hooks.h"
#include "opt_stack.h"
#include "opt_witness.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/sched.h>
#include <sys/stack.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <machine/stdarg.h>
Include dependency graph for subr_witness.c:

Go to the source code of this file.

Data Structures

struct  lock_instance
 
struct  lock_list_entry
 
struct  witness
 
struct  witness_hash
 
struct  witness_lock_order_key
 
struct  witness_lock_order_data
 
struct  witness_lock_order_hash
 
struct  witness_pendhelp
 
struct  witness_order_list_entry
 

Macros

#define KTR_WITNESS   0
 
#define LI_RECURSEMASK   0x0000ffff /* Recursion depth of lock instance. */
 
#define LI_EXCLUSIVE   0x00010000 /* Exclusive lock instance. */
 
#define LI_NORELEASE   0x00020000 /* Lock not allowed to be released. */
 
#define WITNESS_COUNT   1024
 
#define WITNESS_CHILDCOUNT   (WITNESS_COUNT * 4)
 
#define WITNESS_HASH_SIZE   251 /* Prime, gives load factor < 2 */
 
#define WITNESS_PENDLIST   768
 
#define WITNESS_LO_DATA_COUNT   2048
 
#define WITNESS_LO_HASH_SIZE   1021
 
#define LOCK_NCHILDREN   5
 
#define LOCK_CHILDCOUNT   2048
 
#define MAX_W_NAME   64
 
#define BADSTACK_SBUF_SIZE   (256 * WITNESS_COUNT)
 
#define FULLGRAPH_SBUF_SIZE   512
 
#define WITNESS_UNRELATED   0x00 /* No lock order relation. */
 
#define WITNESS_PARENT   0x01 /* Parent, aka direct ancestor. */
 
#define WITNESS_ANCESTOR   0x02 /* Direct or indirect ancestor. */
 
#define WITNESS_CHILD   0x04 /* Child, aka direct descendant. */
 
#define WITNESS_DESCENDANT   0x08 /* Direct or indirect descendant. */
 
#define WITNESS_ANCESTOR_MASK   (WITNESS_PARENT | WITNESS_ANCESTOR)
 
#define WITNESS_DESCENDANT_MASK   (WITNESS_CHILD | WITNESS_DESCENDANT)
 
#define WITNESS_RELATED_MASK   (WITNESS_ANCESTOR_MASK | WITNESS_DESCENDANT_MASK)
 
#define WITNESS_REVERSAL
 
#define WITNESS_RESERVED1   0x20 /* Unused flag, reserved. */
 
#define WITNESS_RESERVED2   0x40 /* Unused flag, reserved. */
 
#define WITNESS_LOCK_ORDER_KNOWN   0x80 /* This lock order is known. */
 
#define WITNESS_DTOA(x)   (((x) & WITNESS_RELATED_MASK) >> 2)
 
#define WITNESS_ATOD(x)   (((x) & WITNESS_RELATED_MASK) << 2)
 
#define WITNESS_INDEX_ASSERT(i)   MPASS((i) > 0 && (i) <= w_max_used_index && (i) < WITNESS_COUNT)
 
#define witness_debugger(c)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_WITNESS,"Witness","Witness")
 
 STAILQ_HEAD (witness_list, witness)
 
static __inline int witness_lock_type_equal (struct witness *w1, struct witness *w2)
 
static __inline int witness_lock_order_key_equal (const struct witness_lock_order_key *a, const struct witness_lock_order_key *b)
 
static int _isitmyx (struct witness *w1, struct witness *w2, int rmask, const char *fname)
 
static void adopt (struct witness *parent, struct witness *child)
 
static void depart (struct witness *w)
 
static struct witnessenroll (const char *description, struct lock_class *lock_class)
 
static struct lock_instancefind_instance (struct lock_list_entry *list, struct lock_object *lock)
 
static int isitmychild (struct witness *parent, struct witness *child)
 
static int isitmydescendant (struct witness *parent, struct witness *child)
 
static void itismychild (struct witness *parent, struct witness *child)
 
static int sysctl_debug_witness_badstacks (SYSCTL_HANDLER_ARGS)
 
static int sysctl_debug_witness_watch (SYSCTL_HANDLER_ARGS)
 
static int sysctl_debug_witness_fullgraph (SYSCTL_HANDLER_ARGS)
 
static void witness_add_fullgraph (struct sbuf *sb, struct witness *parent)
 
static void witness_free (struct witness *m)
 
static struct witnesswitness_get (void)
 
static uint32_t witness_hash_djb2 (const uint8_t *key, uint32_t size)
 
static struct witnesswitness_hash_get (const char *key)
 
static void witness_hash_put (struct witness *w)
 
static void witness_init_hash_tables (void)
 
static void witness_increment_graph_generation (void)
 
static void witness_lock_list_free (struct lock_list_entry *lle)
 
static struct lock_list_entrywitness_lock_list_get (void)
 
static int witness_lock_order_add (struct witness *parent, struct witness *child)
 
static int witness_lock_order_check (struct witness *parent, struct witness *child)
 
static struct witness_lock_order_datawitness_lock_order_get (struct witness *parent, struct witness *child)
 
static void witness_list_lock (struct lock_instance *instance, int(*prnt)(const char *fmt,...))
 
static void witness_setflag (struct lock_object *lock, int flag, int set)
 
static SYSCTL_NODE (_debug, OID_AUTO, witness, CTLFLAG_RW, NULL,"Witness Locking")
 
 TUNABLE_INT ("debug.witness.watch",&witness_watch)
 
 SYSCTL_PROC (_debug_witness, OID_AUTO, watch, CTLFLAG_RW|CTLTYPE_INT, NULL, 0, sysctl_debug_witness_watch,"I","witness is watching lock operations")
 
 TUNABLE_INT ("debug.witness.skipspin",&witness_skipspin)
 
 SYSCTL_INT (_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN,&witness_skipspin, 0,"")
 
 SYSCTL_PROC (_debug_witness, OID_AUTO, fullgraph, CTLTYPE_STRING|CTLFLAG_RD, NULL, 0, sysctl_debug_witness_fullgraph,"A","Show locks relation graphs")
 
 SYSCTL_PROC (_debug_witness, OID_AUTO, badstacks, CTLTYPE_STRING|CTLFLAG_RD, NULL, 0, sysctl_debug_witness_badstacks,"A","Show bad witness stacks")
 
 SYSCTL_INT (_debug_witness, OID_AUTO, free_cnt, CTLFLAG_RD,&w_free_cnt, 0,"")
 
 SYSCTL_INT (_debug_witness, OID_AUTO, spin_cnt, CTLFLAG_RD,&w_spin_cnt, 0,"")
 
 SYSCTL_INT (_debug_witness, OID_AUTO, sleep_cnt, CTLFLAG_RD,&w_sleep_cnt, 0,"")
 
static const char * fixup_filename (const char *file)
 
static void witness_initialize (void *dummy __unused)
 
 SYSINIT (witness_init, SI_SUB_WITNESS, SI_ORDER_FIRST, witness_initialize, NULL)
 
void witness_init (struct lock_object *lock, const char *type)
 
void witness_destroy (struct lock_object *lock)
 
int witness_defineorder (struct lock_object *lock1, struct lock_object *lock2)
 
void witness_checkorder (struct lock_object *lock, int flags, const char *file, int line, struct lock_object *interlock)
 
void witness_lock (struct lock_object *lock, int flags, const char *file, int line)
 
void witness_upgrade (struct lock_object *lock, int flags, const char *file, int line)
 
void witness_downgrade (struct lock_object *lock, int flags, const char *file, int line)
 
void witness_unlock (struct lock_object *lock, int flags, const char *file, int line)
 
void witness_thread_exit (struct thread *td)
 
int witness_warn (int flags, struct lock_object *lock, const char *fmt,...)
 
const char * witness_file (struct lock_object *lock)
 
int witness_line (struct lock_object *lock)
 
int witness_list_locks (struct lock_list_entry **lock_list, int(*prnt)(const char *fmt,...))
 
void witness_display_spinlock (struct lock_object *lock, struct thread *owner, int(*prnt)(const char *fmt,...))
 
void witness_save (struct lock_object *lock, const char **filep, int *linep)
 
void witness_restore (struct lock_object *lock, const char *file, int line)
 
void witness_assert (struct lock_object *lock, int flags, const char *file, int line)
 
void witness_norelease (struct lock_object *lock)
 
void witness_releaseok (struct lock_object *lock)
 

Variables

static int witness_watch = 1
 
int witness_skipspin = 0
 
static struct mtx w_mtx
 
static struct witness_list w_free = STAILQ_HEAD_INITIALIZER(w_free)
 
static struct witness_list w_all = STAILQ_HEAD_INITIALIZER(w_all)
 
static struct witness_list w_spin = STAILQ_HEAD_INITIALIZER(w_spin)
 
static struct witness_list w_sleep = STAILQ_HEAD_INITIALIZER(w_sleep)
 
static struct lock_list_entryw_lock_list_free = NULL
 
static struct witness_pendhelp pending_locks [WITNESS_PENDLIST]
 
static u_int pending_cnt
 
static int w_free_cnt
 
static int w_spin_cnt
 
static int w_sleep_cnt
 
static struct witnessw_data
 
static uint8_t w_rmatrix [WITNESS_COUNT+1][WITNESS_COUNT+1]
 
static struct lock_list_entry w_locklistdata [LOCK_CHILDCOUNT]
 
static struct witness_hash w_hash
 
static struct witness_lock_order_data w_lodata [WITNESS_LO_DATA_COUNT]
 
static struct witness_lock_order_dataw_lofree = NULL
 
static struct witness_lock_order_hash w_lohash
 
static int w_max_used_index = 0
 
static unsigned int w_generation = 0
 
static const char w_notrunning [] = "Witness not running\n"
 
static const char w_stillcold [] = "Witness is still cold\n"
 
static struct witness_order_list_entry order_lists []
 
static int witness_cold = 1
 
static int witness_spin_warn = 0
 

Macro Definition Documentation

#define BADSTACK_SBUF_SIZE   (256 * WITNESS_COUNT)

Definition at line 156 of file subr_witness.c.

Referenced by sysctl_debug_witness_badstacks().

#define FULLGRAPH_SBUF_SIZE   512

Definition at line 157 of file subr_witness.c.

Referenced by sysctl_debug_witness_fullgraph().

#define KTR_WITNESS   0
#define LI_EXCLUSIVE   0x00010000 /* Exclusive lock instance. */
#define LI_NORELEASE   0x00020000 /* Lock not allowed to be released. */

Definition at line 130 of file subr_witness.c.

Referenced by witness_norelease(), witness_releaseok(), and witness_unlock().

#define LI_RECURSEMASK   0x0000ffff /* Recursion depth of lock instance. */
#define LOCK_CHILDCOUNT   2048

Definition at line 152 of file subr_witness.c.

Referenced by witness_initialize().

#define LOCK_NCHILDREN   5

Definition at line 151 of file subr_witness.c.

Referenced by witness_checkorder(), and witness_lock().

#define MAX_W_NAME   64

Definition at line 154 of file subr_witness.c.

Referenced by enroll().

#define WITNESS_ANCESTOR   0x02 /* Direct or indirect ancestor. */

Definition at line 165 of file subr_witness.c.

Referenced by adopt().

#define WITNESS_ANCESTOR_MASK   (WITNESS_PARENT | WITNESS_ANCESTOR)

Definition at line 168 of file subr_witness.c.

Referenced by adopt(), and isitmydescendant().

#define WITNESS_ATOD (   x)    (((x) & WITNESS_RELATED_MASK) << 2)

Definition at line 182 of file subr_witness.c.

Referenced by _isitmyx().

#define WITNESS_CHILD   0x04 /* Child, aka direct descendant. */

Definition at line 166 of file subr_witness.c.

Referenced by adopt().

#define WITNESS_CHILDCOUNT   (WITNESS_COUNT * 4)

Definition at line 136 of file subr_witness.c.

#define WITNESS_COUNT   1024

Definition at line 135 of file subr_witness.c.

Referenced by witness_checkorder(), witness_get(), and witness_initialize().

#define witness_debugger (   c)

Definition at line 369 of file subr_witness.c.

Referenced by witness_checkorder(), and witness_warn().

#define WITNESS_DESCENDANT   0x08 /* Direct or indirect descendant. */

Definition at line 167 of file subr_witness.c.

Referenced by adopt().

#define WITNESS_DESCENDANT_MASK   (WITNESS_CHILD | WITNESS_DESCENDANT)

Definition at line 169 of file subr_witness.c.

Referenced by adopt().

#define WITNESS_DTOA (   x)    (((x) & WITNESS_RELATED_MASK) >> 2)

Definition at line 179 of file subr_witness.c.

Referenced by _isitmyx().

#define WITNESS_HASH_SIZE   251 /* Prime, gives load factor < 2 */

Definition at line 137 of file subr_witness.c.

Referenced by witness_init_hash_tables().

#define WITNESS_INDEX_ASSERT (   i)    MPASS((i) > 0 && (i) <= w_max_used_index && (i) < WITNESS_COUNT)
#define WITNESS_LO_DATA_COUNT   2048

Definition at line 141 of file subr_witness.c.

Referenced by witness_init_hash_tables().

#define WITNESS_LO_HASH_SIZE   1021

Definition at line 144 of file subr_witness.c.

Referenced by witness_init_hash_tables().

#define WITNESS_LOCK_ORDER_KNOWN   0x80 /* This lock order is known. */
#define WITNESS_PARENT   0x01 /* Parent, aka direct ancestor. */

Definition at line 164 of file subr_witness.c.

Referenced by adopt(), isitmychild(), and witness_add_fullgraph().

#define WITNESS_PENDLIST   768

Definition at line 138 of file subr_witness.c.

Referenced by witness_init().

#define WITNESS_RELATED_MASK   (WITNESS_ANCESTOR_MASK | WITNESS_DESCENDANT_MASK)

Definition at line 170 of file subr_witness.c.

Referenced by _isitmyx().

#define WITNESS_RESERVED1   0x20 /* Unused flag, reserved. */

Definition at line 174 of file subr_witness.c.

#define WITNESS_RESERVED2   0x40 /* Unused flag, reserved. */

Definition at line 175 of file subr_witness.c.

#define WITNESS_REVERSAL
Value:
0x10 /* A lock order reversal has been
* observed. */

Definition at line 172 of file subr_witness.c.

Referenced by sysctl_debug_witness_badstacks(), and witness_checkorder().

#define WITNESS_UNRELATED   0x00 /* No lock order relation. */

Definition at line 163 of file subr_witness.c.

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int _isitmyx ( struct witness w1,
struct witness w2,
int  rmask,
const char *  fname 
)
static

Definition at line 1930 of file subr_witness.c.

References kdb_backtrace(), printf(), witness::w_index, witness::w_name, WITNESS_ATOD, WITNESS_DTOA, WITNESS_INDEX_ASSERT, and WITNESS_RELATED_MASK.

Referenced by isitmychild(), and isitmydescendant().

Here is the call graph for this function:

Here is the caller graph for this function:

static void adopt ( struct witness parent,
struct witness child 
)
static
static void depart ( struct witness w)
static

Definition at line 1791 of file subr_witness.c.

References witness::w_class, w_sleep, w_spin, and witness_increment_graph_generation().

Referenced by witness_destroy().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct witness * enroll ( const char *  description,
struct lock_class *  lock_class 
)
static

Definition at line 1735 of file subr_witness.c.

References MAX_W_NAME, panic(), panicstr, witness::w_class, w_mtx, witness::w_name, w_sleep, w_spin, witness_get(), witness_hash_get(), witness_hash_put(), and witness_increment_graph_generation().

Referenced by witness_init(), and witness_initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct lock_instance * find_instance ( struct lock_list_entry list,
struct lock_object *  lock 
)
static
static const char* fixup_filename ( const char *  file)
static

Definition at line 721 of file subr_witness.c.

Referenced by witness_assert(), witness_checkorder(), witness_downgrade(), witness_list_lock(), witness_unlock(), and witness_upgrade().

Here is the caller graph for this function:

static int isitmychild ( struct witness parent,
struct witness child 
)
static

Definition at line 1961 of file subr_witness.c.

References _isitmyx(), and WITNESS_PARENT.

Referenced by adopt(), witness_checkorder(), and witness_lock_order_check().

Here is the call graph for this function:

Here is the caller graph for this function:

static int isitmydescendant ( struct witness parent,
struct witness child 
)
static

Definition at line 1971 of file subr_witness.c.

References _isitmyx(), and WITNESS_ANCESTOR_MASK.

Referenced by witness_checkorder(), and witness_defineorder().

Here is the call graph for this function:

Here is the caller graph for this function:

static void itismychild ( struct witness parent,
struct witness child 
)
static

Definition at line 1907 of file subr_witness.c.

References adopt(), panic(), witness::w_class, w_mtx, witness::w_name, and witness_lock_type_equal().

Referenced by witness_checkorder(), witness_defineorder(), and witness_initialize().

Here is the call graph for this function:

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_WITNESS  ,
"Witness"  ,
"Witness"   
)
static
STAILQ_HEAD ( witness_list  ,
witness   
)
static int sysctl_debug_witness_fullgraph ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2576 of file subr_witness.c.

References FULLGRAPH_SBUF_SIZE, sbuf_delete(), sbuf_finish(), sbuf_new_for_sysctl(), sbuf_printf(), sysctl_wire_old_buffer(), w_mtx, and witness_add_fullgraph().

Here is the call graph for this function:

static int sysctl_debug_witness_watch ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2617 of file subr_witness.c.

References sysctl_handle_int(), value, and witness_watch.

Here is the call graph for this function:

SYSCTL_INT ( _debug_witness  ,
OID_AUTO  ,
skipspin  ,
CTLFLAG_RDTUN  ,
witness_skipspin,
,
""   
)
SYSCTL_INT ( _debug_witness  ,
OID_AUTO  ,
free_cnt  ,
CTLFLAG_RD  ,
w_free_cnt,
,
""   
)
SYSCTL_INT ( _debug_witness  ,
OID_AUTO  ,
spin_cnt  ,
CTLFLAG_RD  ,
w_spin_cnt,
,
""   
)
SYSCTL_INT ( _debug_witness  ,
OID_AUTO  ,
sleep_cnt  ,
CTLFLAG_RD  ,
w_sleep_cnt,
,
""   
)
static SYSCTL_NODE ( _debug  ,
OID_AUTO  ,
witness  ,
CTLFLAG_RW  ,
NULL  ,
"Witness Locking"   
)
static
SYSCTL_PROC ( _debug_witness  ,
OID_AUTO  ,
watch  ,
CTLFLAG_RW|  CTLTYPE_INT,
NULL  ,
,
sysctl_debug_witness_watch  ,
"I"  ,
"witness is watching lock operations"   
)
SYSCTL_PROC ( _debug_witness  ,
OID_AUTO  ,
fullgraph  ,
CTLTYPE_STRING|  CTLFLAG_RD,
NULL  ,
,
sysctl_debug_witness_fullgraph  ,
"A"  ,
"Show locks relation graphs"   
)
SYSCTL_PROC ( _debug_witness  ,
OID_AUTO  ,
badstacks  ,
CTLTYPE_STRING|  CTLFLAG_RD,
NULL  ,
,
sysctl_debug_witness_badstacks  ,
"A"  ,
"Show bad witness stacks"   
)
SYSINIT ( witness_init  ,
SI_SUB_WITNESS  ,
SI_ORDER_FIRST  ,
witness_initialize  ,
NULL   
)
TUNABLE_INT ( "debug.witness.watch"  ,
witness_watch 
)
TUNABLE_INT ( "debug.witness.skipspin"  ,
witness_skipspin 
)
static void witness_add_fullgraph ( struct sbuf *  sb,
struct witness parent 
)
static

Definition at line 2633 of file subr_witness.c.

References sbuf_printf(), witness::w_index, w_max_used_index, witness::w_name, WITNESS_INDEX_ASSERT, and WITNESS_PARENT.

Referenced by sysctl_debug_witness_fullgraph().

Here is the call graph for this function:

Here is the caller graph for this function:

void witness_assert ( struct lock_object *  lock,
int  flags,
const char *  file,
int  line 
)

Definition at line 2233 of file subr_witness.c.

References find_instance(), fixup_filename(), LI_EXCLUSIVE, lock_instance::li_flags, LI_RECURSEMASK, panic(), and panicstr.

Here is the call graph for this function:

int witness_defineorder ( struct lock_object *  lock1,
struct lock_object *  lock2 
)

Definition at line 1013 of file subr_witness.c.

References isitmydescendant(), itismychild(), KTR_WITNESS, panicstr, and w_mtx.

Here is the call graph for this function:

void witness_destroy ( struct lock_object *  lock)

Definition at line 853 of file subr_witness.c.

References depart(), panic(), and w_mtx.

Here is the call graph for this function:

void witness_display_spinlock ( struct lock_object *  lock,
struct thread *  owner,
int(*)(const char *fmt,...)  prnt 
)

Definition at line 2150 of file subr_witness.c.

References find_instance(), pcpu_find(), and witness_list_lock().

Referenced by _mtx_lock_spin_failed().

Here is the call graph for this function:

Here is the caller graph for this function:

void witness_downgrade ( struct lock_object *  lock,
int  flags,
const char *  file,
int  line 
)

Definition at line 1460 of file subr_witness.c.

References find_instance(), fixup_filename(), LI_EXCLUSIVE, lock_instance::li_flags, LI_RECURSEMASK, panic(), and panicstr.

Here is the call graph for this function:

const char* witness_file ( struct lock_object *  lock)

Definition at line 1713 of file subr_witness.c.

static void witness_free ( struct witness m)
static

Definition at line 2033 of file subr_witness.c.

Referenced by witness_initialize().

Here is the caller graph for this function:

static struct witness * witness_get ( void  )
static

Definition at line 2001 of file subr_witness.c.

References printf(), witness::w_index, w_mtx, and WITNESS_COUNT.

Referenced by enroll().

Here is the call graph for this function:

Here is the caller graph for this function:

static uint32_t witness_hash_djb2 ( const uint8_t *  key,
uint32_t  size 
)
static

Definition at line 2658 of file subr_witness.c.

Referenced by witness_hash_get(), witness_hash_put(), witness_lock_order_add(), and witness_lock_order_get().

Here is the caller graph for this function:

static struct witness * witness_hash_get ( const char *  key)
static

Definition at line 2707 of file subr_witness.c.

References w_hash, w_mtx, witness::w_name, witness_hash::wh_array, witness_hash::wh_size, and witness_hash_djb2().

Referenced by enroll(), and witness_hash_put().

Here is the call graph for this function:

Here is the caller graph for this function:

static void witness_hash_put ( struct witness w)
static

Definition at line 2728 of file subr_witness.c.

References w_hash, w_mtx, witness::w_name, witness_hash::wh_array, witness_hash::wh_count, witness_hash::wh_size, witness_hash_djb2(), and witness_hash_get().

Referenced by enroll().

Here is the call graph for this function:

Here is the caller graph for this function:

static void witness_increment_graph_generation ( void  )
static

Definition at line 2829 of file subr_witness.c.

References w_mtx.

Referenced by adopt(), depart(), enroll(), and witness_checkorder().

Here is the caller graph for this function:

void witness_init ( struct lock_object *  lock,
const char *  type 
)

Definition at line 813 of file subr_witness.c.

References enroll(), panic(), panicstr, pending_cnt, pending_locks, type, witness_pendhelp::wh_lock, witness_pendhelp::wh_type, and WITNESS_PENDLIST.

Here is the call graph for this function:

int witness_line ( struct lock_object *  lock)

Definition at line 1724 of file subr_witness.c.

static void witness_list_lock ( struct lock_instance instance,
int(*)(const char *fmt,...)  prnt 
)
static

Definition at line 2088 of file subr_witness.c.

References fixup_filename(), LI_EXCLUSIVE, lock_instance::li_file, lock_instance::li_flags, lock_instance::li_line, lock_instance::li_lock, and LI_RECURSEMASK.

Referenced by witness_display_spinlock(), witness_list_locks(), witness_thread_exit(), and witness_warn().

Here is the call graph for this function:

Here is the caller graph for this function:

int witness_list_locks ( struct lock_list_entry **  lock_list,
int(*)(const char *fmt,...)  prnt 
)

Definition at line 2127 of file subr_witness.c.

References lock_list_entry::ll_children, lock_list_entry::ll_count, lock_list_entry::ll_next, and witness_list_lock().

Referenced by witness_warn().

Here is the call graph for this function:

Here is the caller graph for this function:

void witness_lock ( struct lock_object *  lock,
int  flags,
const char *  file,
int  line 
)
static void witness_lock_list_free ( struct lock_list_entry lle)
static

Definition at line 2062 of file subr_witness.c.

References lock_list_entry::ll_next, w_lock_list_free, and w_mtx.

Referenced by witness_initialize(), witness_thread_exit(), and witness_unlock().

Here is the caller graph for this function:

static struct lock_list_entry * witness_lock_list_get ( void  )
static

Definition at line 2041 of file subr_witness.c.

References lock_list_entry::ll_next, printf(), w_lock_list_free, and w_mtx.

Referenced by witness_lock().

Here is the call graph for this function:

Here is the caller graph for this function:

static int witness_lock_order_check ( struct witness parent,
struct witness child 
)
static

Definition at line 2783 of file subr_witness.c.

References isitmychild(), witness::w_index, and WITNESS_LOCK_ORDER_KNOWN.

Referenced by witness_checkorder().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct witness_lock_order_data * witness_lock_order_get ( struct witness parent,
struct witness child 
)
static
static __inline int witness_lock_order_key_equal ( const struct witness_lock_order_key a,
const struct witness_lock_order_key b 
)
static

Definition at line 308 of file subr_witness.c.

References witness_lock_order_key::from, and witness_lock_order_key::to.

Referenced by witness_lock_order_get().

Here is the caller graph for this function:

static __inline int witness_lock_type_equal ( struct witness w1,
struct witness w2 
)
static

Definition at line 300 of file subr_witness.c.

References witness::w_class.

Referenced by itismychild().

Here is the caller graph for this function:

void witness_norelease ( struct lock_object *  lock)

Definition at line 2330 of file subr_witness.c.

References LI_NORELEASE, and witness_setflag().

Here is the call graph for this function:

void witness_releaseok ( struct lock_object *  lock)

Definition at line 2337 of file subr_witness.c.

References LI_NORELEASE, and witness_setflag().

Here is the call graph for this function:

void witness_restore ( struct lock_object *  lock,
const char *  file,
int  line 
)

Definition at line 2198 of file subr_witness.c.

References find_instance(), lock_instance::li_file, lock_instance::li_line, panic(), and panicstr.

Here is the call graph for this function:

void witness_save ( struct lock_object *  lock,
const char **  filep,
int *  linep 
)

Definition at line 2165 of file subr_witness.c.

References find_instance(), lock_instance::li_file, lock_instance::li_line, panic(), and panicstr.

Here is the call graph for this function:

static void witness_setflag ( struct lock_object *  lock,
int  flag,
int  set 
)
static

Definition at line 2302 of file subr_witness.c.

References find_instance(), flag, lock_instance::li_flags, panic(), and panicstr.

Referenced by witness_norelease(), and witness_releaseok().

Here is the call graph for this function:

Here is the caller graph for this function:

void witness_thread_exit ( struct thread *  td)

Definition at line 1607 of file subr_witness.c.

References lock_list_entry::ll_children, lock_list_entry::ll_count, lock_list_entry::ll_next, panic(), panicstr, printf(), witness_list_lock(), and witness_lock_list_free().

Referenced by thread_exit().

Here is the call graph for this function:

Here is the caller graph for this function:

void witness_unlock ( struct lock_object *  lock,
int  flags,
const char *  file,
int  line 
)
void witness_upgrade ( struct lock_object *  lock,
int  flags,
const char *  file,
int  line 
)

Definition at line 1421 of file subr_witness.c.

References find_instance(), fixup_filename(), LI_EXCLUSIVE, lock_instance::li_flags, LI_RECURSEMASK, panic(), and panicstr.

Here is the call graph for this function:

int witness_warn ( int  flags,
struct lock_object *  lock,
const char *  fmt,
  ... 
)

Variable Documentation

struct witness_order_list_entry order_lists[]
static

Definition at line 470 of file subr_witness.c.

u_int pending_cnt
static

Definition at line 447 of file subr_witness.c.

Referenced by witness_init().

struct witness_pendhelp pending_locks[WITNESS_PENDLIST]
static

Definition at line 446 of file subr_witness.c.

Referenced by witness_init(), and witness_initialize().

struct witness_list w_all = STAILQ_HEAD_INITIALIZER(w_all)
static

Definition at line 438 of file subr_witness.c.

struct witness* w_data
static

Definition at line 455 of file subr_witness.c.

struct witness_list w_free = STAILQ_HEAD_INITIALIZER(w_free)
static

Definition at line 437 of file subr_witness.c.

int w_free_cnt
static

Definition at line 449 of file subr_witness.c.

unsigned int w_generation = 0
static

Definition at line 465 of file subr_witness.c.

Referenced by sysctl_debug_witness_badstacks().

struct witness_hash w_hash
static

Definition at line 458 of file subr_witness.c.

Referenced by witness_hash_get(), witness_hash_put(), and witness_init_hash_tables().

struct lock_list_entry* w_lock_list_free = NULL
static

Definition at line 445 of file subr_witness.c.

Referenced by witness_lock_list_free(), and witness_lock_list_get().

struct lock_list_entry w_locklistdata[LOCK_CHILDCOUNT]
static

Definition at line 457 of file subr_witness.c.

Referenced by witness_initialize().

Definition at line 461 of file subr_witness.c.

Referenced by witness_init_hash_tables().

struct witness_lock_order_data* w_lofree = NULL
static

Definition at line 462 of file subr_witness.c.

Referenced by witness_init_hash_tables(), and witness_lock_order_add().

int w_max_used_index = 0
static

Definition at line 464 of file subr_witness.c.

Referenced by adopt(), sysctl_debug_witness_badstacks(), and witness_add_fullgraph().

const char w_notrunning[] = "Witness not running\n"
static

Definition at line 466 of file subr_witness.c.

uint8_t w_rmatrix[WITNESS_COUNT+1][WITNESS_COUNT+1]
static

Definition at line 456 of file subr_witness.c.

struct witness_list w_sleep = STAILQ_HEAD_INITIALIZER(w_sleep)
static

Definition at line 442 of file subr_witness.c.

Referenced by depart(), and enroll().

int w_sleep_cnt
static

Definition at line 449 of file subr_witness.c.

struct witness_list w_spin = STAILQ_HEAD_INITIALIZER(w_spin)
static

Definition at line 441 of file subr_witness.c.

Referenced by depart(), and enroll().

int w_spin_cnt
static

Definition at line 449 of file subr_witness.c.

const char w_stillcold[] = "Witness is still cold\n"
static

Definition at line 467 of file subr_witness.c.

int witness_cold = 1
static

Definition at line 711 of file subr_witness.c.

int witness_skipspin = 0

Definition at line 416 of file subr_witness.c.

int witness_spin_warn = 0
static

Definition at line 717 of file subr_witness.c.

int witness_watch = 1
static

Definition at line 382 of file subr_witness.c.

Referenced by sysctl_debug_witness_watch().