Date: Tue, 12 Oct 2004 17:16:59 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 63077 for review Message-ID: <200410121716.i9CHGxmX028246@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=63077 Change 63077 by jhb@jhb_twclab on 2004/10/12 17:16:25 Merge in a patch to whine if a task takes a long time to run. Submitted by: rwatson Affected files ... .. //depot/projects/smpng/sys/kern/subr_taskqueue.c#22 edit .. //depot/projects/smpng/sys/sys/_task.h#4 edit Differences ... ==== //depot/projects/smpng/sys/kern/subr_taskqueue.c#22 (text+ko) ==== @@ -36,9 +36,16 @@ #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mutex.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; @@ -140,6 +147,9 @@ return 0; } + getnanotime(&task->ta_queuetime); + tq_in++; + /* * Optimise the case when all tasks have the same priority. */ @@ -172,6 +182,7 @@ taskqueue_run(struct taskqueue *queue) { struct task *task; + struct timespec tv; int owned, pending; owned = mtx_owned(&queue->tq_mutex); @@ -187,7 +198,15 @@ pending = task->ta_pending; task->ta_pending = 0; task->ta_flags |= TAF_PENDING; + tq_out++; + getnanotime(&tv); + timespecsub(&tv, &task->ta_queuetime); mtx_unlock(&queue->tq_mutex); + 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); ==== //depot/projects/smpng/sys/sys/_task.h#4 (text+ko) ==== @@ -46,6 +46,7 @@ task_fn_t *ta_func; /* task handler */ void *ta_context; /* argument for handler */ int ta_flags; /* Flags */ + struct timespec ta_queuetime; /* time enqueued */ }; #define TAF_PENDING 0x1 /* Task is being run now */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410121716.i9CHGxmX028246>