HomeFreeBSD

ddb show allchains: avoid traps and show pointers for lockmgr and sx

Description

ddb show allchains: avoid traps and show pointers for lockmgr and sx

When trying to walk lock chains, we have to deduce what a thread is
blocked on. Checking LOCK_CLASS(td->td_wchan) is not a very reliable
method by itself, as it just tests whether a particular 4 bits near
where td_wchan points have a particular value. Misinterpreting wait
channel pointers of other sleeps as lockmgr locks would frequently cause
ddb show allchains (or show lockchain) to trap, or to produce incorrect
output.

Now, check the sleepq_type. When calling sleepq_add, we use SLEEPQ_LK
for lockmgr locks and SLEEPQ_SX for sx locks. This is a more reliable
indication that the td_wchan is actually a lock.

While here, also make the output of lockmgr and sx locks consistent with
the output for other locks (see print_lockchain). Outputting a pointer
to the lock allows it to be inspected further with ddb show lock or
other methods.

Reviewed by: markj
Sponsored by: Dell Inc.
Differential Revision: https://reviews.freebsd.org/D52794

Details

Provenance
rlibbyAuthored on Oct 3 2025, 5:47 AM
Reviewer
markj
Differential Revision
D52794: ddb show allchains: avoid traps and show pointers for lockmgr and sx
Parents
rGdfc9da624849: Makefile: Fix ordering for (update-)packages
Branches
Unknown
Tags
Unknown