| FreeBSD kernel kern code
    | 
#include "opt_adaptive_lockmgrs.h"#include "opt_ddb.h"#include "opt_hwpmc_hooks.h"#include "opt_kdtrace.h"#include <sys/cdefs.h>#include <sys/param.h>#include <sys/kdb.h>#include <sys/ktr.h>#include <sys/lock.h>#include <sys/lock_profile.h>#include <sys/lockmgr.h>#include <sys/mutex.h>#include <sys/proc.h>#include <sys/sleepqueue.h>#include <sys/sysctl.h>#include <sys/systm.h>#include <machine/cpu.h>
Go to the source code of this file.
| Macros | |
| #define | SQ_EXCLUSIVE_QUEUE 0 | 
| #define | SQ_SHARED_QUEUE 1 | 
| #define | _lockmgr_assert(lk, what, file, line) | 
| #define | TD_LOCKS_INC(td) | 
| #define | TD_LOCKS_DEC(td) | 
| #define | TD_SLOCKS_INC(td) ((td)->td_lk_slocks++) | 
| #define | TD_SLOCKS_DEC(td) ((td)->td_lk_slocks--) | 
| #define | STACK_PRINT(lk) | 
| #define | STACK_SAVE(lk) | 
| #define | STACK_ZERO(lk) | 
| #define | LOCK_LOG2(lk, string, arg1, arg2) | 
| #define | LOCK_LOG3(lk, string, arg1, arg2, arg3) | 
| #define | GIANT_DECLARE | 
| #define | GIANT_RESTORE() | 
| #define | GIANT_SAVE() | 
| #define | LK_CAN_SHARE(x) | 
| #define | LK_TRYOP(x) ((x) & LK_NOWAIT) | 
| #define | LK_CAN_WITNESS(x) (((x) & LK_NOWITNESS) == 0 && !LK_TRYOP(x)) | 
| #define | LK_TRYWIT(x) (LK_TRYOP(x) ? LOP_TRYLOCK : 0) | 
| #define | LK_CAN_ADAPT(lk, f) | 
| #define | lockmgr_disowned(lk) (((lk)->lk_lock & ~(LK_FLAGMASK & ~LK_SHARE)) == LK_KERNPROC) | 
| #define | lockmgr_xlocked(lk) (((lk)->lk_lock & ~(LK_FLAGMASK & ~LK_SHARE)) == (uintptr_t)curthread) | 
| Functions | |
| __FBSDID ("$BSDSUniX$") | |
| CTASSERT (((LK_ADAPTIVE|LK_NOSHARE)&LO_CLASSFLAGS)==(LK_ADAPTIVE|LK_NOSHARE)) | |
| CTASSERT (LK_UNLOCKED==(LK_UNLOCKED & ~(LK_ALL_WAITERS|LK_EXCLUSIVE_SPINNERS))) | |
| static void | assert_lockmgr (struct lock_object *lock, int how) | 
| static void | lock_lockmgr (struct lock_object *lock, int how) | 
| static int | unlock_lockmgr (struct lock_object *lock) | 
| static __inline struct thread * | lockmgr_xholder (struct lock *lk) | 
| static __inline int | sleeplk (struct lock *lk, u_int flags, struct lock_object *ilk, const char *wmesg, int pri, int timo, int queue) | 
| static __inline int | wakeupshlk (struct lock *lk, const char *file, int line) | 
| void | lockinit (struct lock *lk, int pri, const char *wmesg, int timo, int flags) | 
| void | lockallowshare (struct lock *lk) | 
| void | lockallowrecurse (struct lock *lk) | 
| void | lockdisablerecurse (struct lock *lk) | 
| void | lockdestroy (struct lock *lk) | 
| int | __lockmgr_args (struct lock *lk, u_int flags, struct lock_object *ilk, const char *wmesg, int pri, int timo, const char *file, int line) | 
| void | _lockmgr_disown (struct lock *lk, const char *file, int line) | 
| void | lockmgr_printinfo (struct lock *lk) | 
| int | lockstatus (struct lock *lk) | 
| Variables | |
| struct lock_class | lock_class_lockmgr | 
| #define _lockmgr_assert | ( | lk, | |
| what, | |||
| file, | |||
| line | |||
| ) | 
Definition at line 77 of file kern_lock.c.
Referenced by __lockmgr_args(), and _lockmgr_disown().
| #define GIANT_DECLARE | 
Definition at line 104 of file kern_lock.c.
Referenced by __lockmgr_args(), and sleeplk().
| #define GIANT_RESTORE | ( | ) | 
Definition at line 107 of file kern_lock.c.
Referenced by __lockmgr_args(), and sleeplk().
| #define GIANT_SAVE | ( | ) | 
Definition at line 114 of file kern_lock.c.
Referenced by __lockmgr_args(), and sleeplk().
| #define LK_CAN_ADAPT | ( | lk, | |
| f | |||
| ) | 
Definition at line 136 of file kern_lock.c.
Referenced by __lockmgr_args().
| #define LK_CAN_SHARE | ( | x | ) | 
Definition at line 124 of file kern_lock.c.
Referenced by __lockmgr_args().
| #define LK_CAN_WITNESS | ( | x | ) | (((x) & LK_NOWITNESS) == 0 && !LK_TRYOP(x)) | 
Definition at line 131 of file kern_lock.c.
Referenced by __lockmgr_args().
| #define LK_TRYOP | ( | x | ) | ((x) & LK_NOWAIT) | 
Definition at line 128 of file kern_lock.c.
Referenced by __lockmgr_args().
| #define LK_TRYWIT | ( | x | ) | (LK_TRYOP(x) ? LOP_TRYLOCK : 0) | 
Definition at line 133 of file kern_lock.c.
Referenced by __lockmgr_args().
| #define LOCK_LOG2 | ( | lk, | |
| string, | |||
| arg1, | |||
| arg2 | |||
| ) | 
Definition at line 97 of file kern_lock.c.
Referenced by __lockmgr_args(), and wakeupshlk().
| #define LOCK_LOG3 | ( | lk, | |
| string, | |||
| arg1, | |||
| arg2, | |||
| arg3 | |||
| ) | 
Definition at line 100 of file kern_lock.c.
Referenced by __lockmgr_args(), sleeplk(), and wakeupshlk().
| #define lockmgr_disowned | ( | lk | ) | (((lk)->lk_lock & ~(LK_FLAGMASK & ~LK_SHARE)) == LK_KERNPROC) | 
Definition at line 140 of file kern_lock.c.
| #define lockmgr_xlocked | ( | lk | ) | (((lk)->lk_lock & ~(LK_FLAGMASK & ~LK_SHARE)) == (uintptr_t)curthread) | 
Definition at line 143 of file kern_lock.c.
Referenced by __lockmgr_args().
| #define SQ_EXCLUSIVE_QUEUE 0 | 
Definition at line 68 of file kern_lock.c.
Referenced by __lockmgr_args(), sleeplk(), and wakeupshlk().
| #define SQ_SHARED_QUEUE 1 | 
Definition at line 69 of file kern_lock.c.
Referenced by __lockmgr_args(), and wakeupshlk().
| #define STACK_PRINT | ( | lk | ) | 
Definition at line 88 of file kern_lock.c.
Referenced by lockmgr_printinfo().
| #define STACK_SAVE | ( | lk | ) | 
Definition at line 89 of file kern_lock.c.
Referenced by __lockmgr_args(), and _lockmgr_disown().
| #define STACK_ZERO | ( | lk | ) | 
Definition at line 90 of file kern_lock.c.
Referenced by lockinit().
| #define TD_LOCKS_DEC | ( | td | ) | 
Definition at line 79 of file kern_lock.c.
Referenced by __lockmgr_args(), _lockmgr_disown(), and wakeupshlk().
| #define TD_LOCKS_INC | ( | td | ) | 
Definition at line 78 of file kern_lock.c.
Referenced by __lockmgr_args().
| #define TD_SLOCKS_DEC | ( | td | ) | ((td)->td_lk_slocks--) | 
Definition at line 85 of file kern_lock.c.
Referenced by __lockmgr_args(), and wakeupshlk().
| #define TD_SLOCKS_INC | ( | td | ) | ((td)->td_lk_slocks++) | 
Definition at line 84 of file kern_lock.c.
Referenced by __lockmgr_args().
| __FBSDID | ( | "$BSDSUniX$" | ) | 
| int __lockmgr_args | ( | struct lock * | lk, | 
| u_int | flags, | ||
| struct lock_object * | ilk, | ||
| const char * | wmesg, | ||
| int | pri, | ||
| int | timo, | ||
| const char * | file, | ||
| int | line | ||
| ) | 
Definition at line 441 of file kern_lock.c.
References _lockmgr_assert, GIANT_DECLARE, GIANT_RESTORE, GIANT_SAVE, kdb_active, LK_CAN_ADAPT, LK_CAN_SHARE, LK_CAN_WITNESS, LK_TRYOP, LK_TRYWIT, LOCK_LOG2, LOCK_LOG3, lockmgr_xlocked, panic(), panicstr, sleeplk(), sleepq_add(), sleepq_broadcast(), sleepq_lock(), sleepq_release(), sleepq_sleepcnt(), sleepq_wait(), SQ_EXCLUSIVE_QUEUE, SQ_SHARED_QUEUE, STACK_SAVE, TD_LOCKS_DEC, TD_LOCKS_INC, TD_SLOCKS_DEC, TD_SLOCKS_INC, waittime, and wakeupshlk().

| void _lockmgr_disown | ( | struct lock * | lk, | 
| const char * | file, | ||
| int | line | ||
| ) | 
Definition at line 1260 of file kern_lock.c.
References _lockmgr_assert, STACK_SAVE, and TD_LOCKS_DEC.
| 
 | static | 
Definition at line 341 of file kern_lock.c.
References panic().

| CTASSERT | ( | ((LK_ADAPTIVE|LK_NOSHARE)&LO_CLASSFLAGS) | = =(LK_ADAPTIVE|LK_NOSHARE) | ) | 
| CTASSERT | ( | LK_UNLOCKED | = =(LK_UNLOCKED &       ~(LK_ALL_WAITERS|LK_EXCLUSIVE_SPINNERS)) | ) | 
| 
 | static | 
Definition at line 348 of file kern_lock.c.
References panic().

| void lockallowrecurse | ( | struct lock * | lk | ) | 
Definition at line 415 of file kern_lock.c.
| void lockallowshare | ( | struct lock * | lk | ) | 
Definition at line 407 of file kern_lock.c.
| void lockdestroy | ( | struct lock * | lk | ) | 
Definition at line 431 of file kern_lock.c.
References lock_destroy().
Referenced by mount_fini(), and vdropl().


| void lockdisablerecurse | ( | struct lock * | lk | ) | 
Definition at line 423 of file kern_lock.c.
| void lockinit | ( | struct lock * | lk, | 
| int | pri, | ||
| const char * | wmesg, | ||
| int | timo, | ||
| int | flags | ||
| ) | 
Definition at line 371 of file kern_lock.c.
References lock_init(), and STACK_ZERO.
Referenced by getnewvnode(), and mount_init().


| void lockmgr_printinfo | ( | struct lock * | lk | ) | 
Definition at line 1296 of file kern_lock.c.
References lockmgr_xholder(), printf(), and STACK_PRINT.
Referenced by vn_printf().


| 
 | static | 
Definition at line 171 of file kern_lock.c.
Referenced by lockmgr_printinfo().

| int lockstatus | ( | struct lock * | lk | ) | 
Definition at line 1325 of file kern_lock.c.
Referenced by vop_stdislocked().

| 
 | static | 
Definition at line 186 of file kern_lock.c.
References GIANT_DECLARE, GIANT_RESTORE, GIANT_SAVE, LOCK_LOG3, sleepq_add(), sleepq_set_timeout(), sleepq_timedwait(), sleepq_timedwait_sig(), sleepq_wait(), sleepq_wait_sig(), and SQ_EXCLUSIVE_QUEUE.
Referenced by __lockmgr_args().


| 
 | static | 
Definition at line 355 of file kern_lock.c.
References panic().

| 
 | static | 
Definition at line 230 of file kern_lock.c.
References LOCK_LOG2, LOCK_LOG3, sleepq_broadcast(), sleepq_lock(), sleepq_release(), sleepq_sleepcnt(), SQ_EXCLUSIVE_QUEUE, SQ_SHARED_QUEUE, TD_LOCKS_DEC, and TD_SLOCKS_DEC.
Referenced by __lockmgr_args().


| struct lock_class lock_class_lockmgr | 
Definition at line 156 of file kern_lock.c.