summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-12-26 22:52:24 +0000
committerrwatson <rwatson@FreeBSD.org>2004-12-26 22:52:24 +0000
commitb864ac486cc4d57ca87dac803405abb87b4a8f86 (patch)
treebeac688482181577e26896b9d586db4a0f484a85 /sys/kern
parent5c1258faf6ef5b7306425ab62169de09e3d15f6f (diff)
downloadFreeBSD-src-b864ac486cc4d57ca87dac803405abb87b4a8f86.zip
FreeBSD-src-b864ac486cc4d57ca87dac803405abb87b4a8f86.tar.gz
Add "show alllocks" command to DDB, which dumps a list of processes
and threads currently holding sleep mutexes (and spin mutexes for curthread). This can be quite useful in looking for a lock condition summary for a system, as it avoids manually iterating through threads and processes to find all the interesting locks. NB: "alllocks" is up there with "lockedvnods" for a bad argument for show. MFC after: 2 weeks
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_witness.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 005d4e2..6d6afe8 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -1721,6 +1721,25 @@ witness_list_lock(struct lock_instance *instance)
instance->li_line);
}
+static int
+witness_thread_has_locks(struct thread *td)
+{
+
+ return (td->td_sleeplocks != NULL);
+}
+
+static int
+witness_proc_has_locks(struct proc *p)
+{
+ struct thread *td;
+
+ FOREACH_THREAD_IN_PROC(p, td) {
+ if (witness_thread_has_locks(td))
+ return (1);
+ }
+ return (0);
+}
+
int
witness_list_locks(struct lock_list_entry **lock_list)
{
@@ -1917,6 +1936,29 @@ DB_SHOW_COMMAND(locks, db_witness_list)
}
}
+DB_SHOW_COMMAND(alllocks, db_witness_list_all)
+{
+ struct thread *td;
+ struct proc *p;
+
+ /*
+ * It would be nice to list only threads and processes that actually
+ * held sleep locks, but that information is currently not exported
+ * by WITNESS.
+ */
+ FOREACH_PROC_IN_SYSTEM(p) {
+ if (!witness_proc_has_locks(p))
+ continue;
+ printf("Process %d (%s)\n", p->p_pid, p->p_comm);
+ FOREACH_THREAD_IN_PROC(p, td) {
+ if (!witness_thread_has_locks(td))
+ continue;
+ printf("Thread 0x%x\n", td->td_tid);
+ witness_list(td);
+ }
+ }
+}
+
DB_SHOW_COMMAND(witness, db_witness_display)
{
OpenPOWER on IntegriCloud