Subject: lock debugging
To: None <>
From: Jed Davis <>
List: tech-kern
Date: 11/17/2006 05:49:54
For diagnosing problems with locking (e.g., lots of processes getting
stuck on vnlock), it would be nice to be able to dump, for each lock
on the system that's being slept on, which lwp holds it and which are
sleeping on it.  Finding the thread at the root (or, for vnlock, leaf)
of the trouble should then be easier.

Given a struck lock*, the identity of the holder is right there; but
getting from a sleeping lwp to the lock it's sleeping on seems harder.
A quick glance shows that the sleep address will point to the struct
lock (except in the LK_DRAIN case when it's the lk_flags field, it
looks like), but it might also point to something else entirely.

Am I missing something obvious?

Also, it would be more helpful if the attempt to trace the offending
thread wouldn't fail due to its process's having been swapped out, but
I don't know how that might be approached.

(None of this is to say that I myself will necessarily have time to do
anything useful any time in the near future.)
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l))))))  (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k)))))))    '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))