lock.9: describe lockmgr_{disowned,lock_flags,slock,unlock,xlock}

Describe and link the following functions in the lockgmr API:
 - lockmgr_disowned
 - lockmgr_lock_flags
 - lockmgr_slock
 - lockmgr_unlock
 - lockmgr_xlock

This is not a complete update of lock.9 but at least covers all the main
lock operations.

Reviewed by:	gbe, kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45689
This commit is contained in:
Ryan Libby 2024-06-23 14:46:31 -07:00
parent 60117f9ee5
commit fda32d5860
2 changed files with 67 additions and 1 deletions

View file

@ -1431,9 +1431,14 @@ MLINKS+=lock.9 lockdestroy.9 \
lock.9 lockmgr_args_rw.9 \ lock.9 lockmgr_args_rw.9 \
lock.9 lockmgr_assert.9 \ lock.9 lockmgr_assert.9 \
lock.9 lockmgr_disown.9 \ lock.9 lockmgr_disown.9 \
lock.9 lockmgr_disowned.9 \
lock.9 lockmgr_lock_flags.9 \
lock.9 lockmgr_printinfo.9 \ lock.9 lockmgr_printinfo.9 \
lock.9 lockmgr_recursed.9 \ lock.9 lockmgr_recursed.9 \
lock.9 lockmgr_rw.9 \ lock.9 lockmgr_rw.9 \
lock.9 lockmgr_slock.9 \
lock.9 lockmgr_unlock.9 \
lock.9 lockmgr_xlock.9 \
lock.9 lockstatus.9 lock.9 lockstatus.9
MLINKS+=LOCK_PROFILING.9 MUTEX_PROFILING.9 MLINKS+=LOCK_PROFILING.9 MUTEX_PROFILING.9
MLINKS+=make_dev.9 destroy_dev.9 \ MLINKS+=make_dev.9 destroy_dev.9 \

View file

@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
.\" DAMAGE. .\" DAMAGE.
.\" .\"
.Dd May 18, 2024 .Dd June 21, 2024
.Dt LOCK 9 .Dt LOCK 9
.Os .Os
.Sh NAME .Sh NAME
@ -34,9 +34,14 @@
.Nm lockmgr_args , .Nm lockmgr_args ,
.Nm lockmgr_args_rw , .Nm lockmgr_args_rw ,
.Nm lockmgr_disown , .Nm lockmgr_disown ,
.Nm lockmgr_disowned ,
.Nm lockmgr_lock_flags ,
.Nm lockmgr_printinfo , .Nm lockmgr_printinfo ,
.Nm lockmgr_recursed , .Nm lockmgr_recursed ,
.Nm lockmgr_rw , .Nm lockmgr_rw ,
.Nm lockmgr_slock ,
.Nm lockmgr_unlock ,
.Nm lockmgr_xlock ,
.Nm lockstatus , .Nm lockstatus ,
.Nm lockmgr_assert .Nm lockmgr_assert
.Nd "lockmgr family of functions" .Nd "lockmgr family of functions"
@ -56,6 +61,10 @@
.Fn lockmgr_args_rw "struct lock *lkp" "u_int flags" "struct rwlock *ilk" "const char *wmesg" "int prio" "int timo" .Fn lockmgr_args_rw "struct lock *lkp" "u_int flags" "struct rwlock *ilk" "const char *wmesg" "int prio" "int timo"
.Ft void .Ft void
.Fn lockmgr_disown "struct lock *lkp" .Fn lockmgr_disown "struct lock *lkp"
.Ft int
.Fn lockmgr_disowned "const struct lock *lkp"
.Ft int
.Fn lockmgr_lock_flags "struct lock *lkp" "u_int flags" "struct lock_object *ilk" "const char *file" "int line"
.Ft void .Ft void
.Fn lockmgr_printinfo "const struct lock *lkp" .Fn lockmgr_printinfo "const struct lock *lkp"
.Ft int .Ft int
@ -63,6 +72,12 @@
.Ft int .Ft int
.Fn lockmgr_rw "struct lock *lkp" "u_int flags" "struct rwlock *ilk" .Fn lockmgr_rw "struct lock *lkp" "u_int flags" "struct rwlock *ilk"
.Ft int .Ft int
.Fn lockmgr_slock "struct lock *lkp" "u_int flags" "const char *file" "int line"
.Ft int
.Fn lockmgr_unlock "struct lock *lkp"
.Ft int
.Fn lockmgr_xlock "struct lock *lkp" "u_int flags" "const char *file" "int line"
.Ft int
.Fn lockstatus "const struct lock *lkp" .Fn lockstatus "const struct lock *lkp"
.Pp .Pp
.Cd "options INVARIANTS" .Cd "options INVARIANTS"
@ -253,12 +268,55 @@ and
.Dv LK_TIMO_DEFAULT . .Dv LK_TIMO_DEFAULT .
.Pp .Pp
The The
.Fn lockmgr_lock_flags
function works like
.Fn lockmgr
but accepts explicit
.Fa file
and
.Fa line
arguments for lock tracing.
.Pp
The
.Fn lockmgr_slock ,
.Fn lockmgr_xlock ,
and
.Fn lockmgr_unlock
functions are lightweight entry points that function like
.Fn lockmgr
for the
.Dv LK_SHARED ,
.Dv LK_EXCLUSIVE ,
and
.Dv LK_RELEASE
operations respectively.
They provide functionality similar to
.Xr sx 9
locks in that none of the additional
.Xr lockmgr 9
features are supported.
Specifically, these functions do not support unlocking interlocks, the
.Dv LK_SLEEPFAIL
flag, or locks with shared locking disabled via
.Dv LK_NOSHARE .
They also accept explicit
.Fa file
and
.Fa line
arguments for lock tracing.
.Pp
The
.Fn lockmgr_disown .Fn lockmgr_disown
function switches the owner from the current thread to be function switches the owner from the current thread to be
.Dv LK_KERNPROC , .Dv LK_KERNPROC ,
if the lock is already held. if the lock is already held.
.Pp .Pp
The The
.Fn lockmgr_disowned
function returns true or false according to whether the lock is held by
.Dv LK_KERNPROC .
.Pp
The
.Fn lockmgr_printinfo .Fn lockmgr_printinfo
function prints debugging information about the lock. function prints debugging information about the lock.
It is used primarily by It is used primarily by
@ -354,6 +412,8 @@ was requested and another thread had already requested a lock upgrade.
was set, and a sleep would have been required, or was set, and a sleep would have been required, or
.Dv LK_TRYUPGRADE .Dv LK_TRYUPGRADE
operation was not able to upgrade the lock. operation was not able to upgrade the lock.
.It Bq Er EDEADLK
A shared lock was attempted while the thread already held the exclusive lock.
.It Bq Er ENOLCK .It Bq Er ENOLCK
.Dv LK_SLEEPFAIL .Dv LK_SLEEPFAIL
was set and was set and
@ -398,6 +458,7 @@ exclusive lock, and a
.Xr panic 9 .Xr panic 9
will be the result of trying. will be the result of trying.
.Sh SEE ALSO .Sh SEE ALSO
.Xr witness 4 ,
.Xr condvar 9 , .Xr condvar 9 ,
.Xr locking 9 , .Xr locking 9 ,
.Xr mtx_assert 9 , .Xr mtx_assert 9 ,