Page MenuHomeFreeBSD

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

Authored by rlibby on Tue, Sep 30, 7:20 AM.
Tags
None
Referenced Files
F132367396: D52794.diff
Thu, Oct 16, 6:56 AM
Unknown Object (File)
Mon, Oct 13, 3:08 AM
Unknown Object (File)
Sun, Oct 12, 4:26 PM
Unknown Object (File)
Sun, Oct 12, 7:46 AM
Unknown Object (File)
Sun, Oct 12, 1:04 AM
Unknown Object (File)
Sun, Oct 12, 1:04 AM
Unknown Object (File)
Sun, Oct 12, 1:04 AM
Unknown Object (File)
Sat, Oct 11, 3:35 PM
Subscribers

Details

Summary

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.

Sponsored by: Dell Inc.

Test Plan

Manual testing of ddb show allchains:

  • no longer regularly traps
  • still follows lock chains through lockmgr locks
  • still follows lock chains through sx locks
  • the newly outputted pointers can be used with ddb show lock

Demo: P673.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rlibby added reviewers: jhb, markj.

The TD_ON_SLEEPQ test is redundant currently, but it makes sense to include it.

This revision is now accepted and ready to land.Thu, Oct 2, 10:11 PM