From 14d19bb6947ed5e8b51de47f9a047bbb00a514ba Mon Sep 17 00:00:00 2001
From: jhb <jhb@FreeBSD.org>
Date: Mon, 24 Oct 2005 15:57:27 +0000
Subject: [PATCH] Spell hierarchy correctly in comments.

Submitted by:	Wojciech A. Koszek dunstan at freebsd dot czest dot pl
---
 sys/kern/subr_taskqueue.c | 19 +++++++++++++++++++
 sys/kern/subr_witness.c   |  4 ++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index 9622098e3447..4ae91e734e16 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -37,9 +37,16 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
+#include <sys/sysctl.h>
 #include <sys/taskqueue.h>
+#include <sys/time.h>
 #include <sys/unistd.h>
 
+int tq_in;
+SYSCTL_INT(_kern, OID_AUTO, tq_in, CTLFLAG_RD, &tq_in, 0, "");
+int tq_out;
+SYSCTL_INT(_kern, OID_AUTO, tq_out, CTLFLAG_RD, &tq_out, 0, "");
+
 static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues");
 static void	*taskqueue_giant_ih;
 static void	*taskqueue_ih;
@@ -166,6 +173,9 @@ taskqueue_enqueue(struct taskqueue *queue, struct task *task)
 		return 0;
 	}
 
+	getnanotime(&task->ta_queuetime);
+	tq_in++;
+
 	/*
 	 * Optimise the case when all tasks have the same priority.
 	 */
@@ -197,6 +207,7 @@ void
 taskqueue_run(struct taskqueue *queue)
 {
 	struct task *task;
+	struct timespec tv;
 	int owned, pending;
 
 	owned = mtx_owned(&queue->tq_mutex);
@@ -212,8 +223,16 @@ taskqueue_run(struct taskqueue *queue)
 		pending = task->ta_pending;
 		task->ta_pending = 0;
 		queue->tq_running = task;
+ 		tq_out++;
 		mtx_unlock(&queue->tq_mutex);
 
+ 		getnanotime(&tv);
+ 		timespecsub(&tv, &task->ta_queuetime);
+ 		if (tv.tv_nsec >= 0500000000) {
+ 			printf("taskqueue_run: warning, queue time of %d.%09ld "
+ 			    "for context %p\n", tv.tv_sec, tv.tv_nsec,
+ 			    task->ta_func);
+ 		}
 		task->ta_func(task->ta_context, pending);
 
 		mtx_lock(&queue->tq_mutex);
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 72c08c81e693..06bab9106176 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -205,7 +205,7 @@ SYSCTL_PROC(_debug_witness, OID_AUTO, watch, CTLFLAG_RW | CTLTYPE_INT, NULL, 0,
 /*
  * When KDB is enabled and witness_kdb is set to 1, it will cause the system
  * to drop into kdebug() when:
- *	- a lock heirarchy violation occurs
+ *	- a lock hierarchy violation occurs
  *	- locks are held when going to sleep.
  */
 #ifdef WITNESS_KDB
@@ -219,7 +219,7 @@ SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RW, &witness_kdb, 0, "");
 /*
  * When KDB is enabled and witness_trace is set to 1, it will cause the system
  * to print a stack trace:
- *	- a lock heirarchy violation occurs
+ *	- a lock hierarchy violation occurs
  *	- locks are held when going to sleep.
  */
 int	witness_trace = 1;