From b2ca74654c0329457867bc2f5e14784c5968f5a7 Mon Sep 17 00:00:00 2001 From: mckusick Date: Wed, 12 Nov 2003 22:28:27 +0000 Subject: At the request of several developers, restore the DIAGNOSIC code deleted in 1.81. Increase the initial timeout limit to 2ms to eliminate spurious messages of excessive timeouts in the NFS client code. Requested by: Poul-Henning Kamp Requested by: Mike Silbersack Requested by: Sam Leffler --- sys/kern/kern_timeout.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index f1c4b90..8878500 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -70,6 +70,9 @@ int callwheelsize, callwheelbits, callwheelmask; struct callout_tailq *callwheel; int softticks; /* Like ticks, but for softclock(). */ struct mtx callout_lock; +#ifdef DIAGNOSTIC +struct mtx callout_dont_sleep; +#endif static struct callout *nextsoftcheck; /* Next callout to be checked. */ @@ -120,6 +123,9 @@ kern_timeout_callwheel_init(void) TAILQ_INIT(&callwheel[i]); } mtx_init(&callout_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE); +#ifdef DIAGNOSTIC + mtx_init(&callout_dont_sleep, "callout_dont_sleep", NULL, MTX_DEF); +#endif } /* @@ -148,6 +154,11 @@ softclock(void *dummy) int depth; int mpcalls; int gcalls; +#ifdef DIAGNOSTIC + struct bintime bt1, bt2; + struct timespec ts2; + static uint64_t maxdt = 36893488147419102LL; /* 2 msec */ +#endif #ifndef MAX_SOFTCLOCK_STEPS #define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */ @@ -207,7 +218,24 @@ softclock(void *dummy) } else { mpcalls++; } +#ifdef DIAGNOSTIC + binuptime(&bt1); + mtx_lock(&callout_dont_sleep); +#endif c_func(c_arg); +#ifdef DIAGNOSTIC + mtx_unlock(&callout_dont_sleep); + binuptime(&bt2); + bintime_sub(&bt2, &bt1); + if (bt2.frac > maxdt) { + maxdt = bt2.frac; + bintime2timespec(&bt2, &ts2); + printf( + "Expensive timeout(9) function: %p(%p) %ld.%09ld s\n", + c_func, c_arg, + (long)ts2.tv_sec, ts2.tv_nsec); + } +#endif if (!(c_flags & CALLOUT_MPSAFE)) mtx_unlock(&Giant); mtx_lock_spin(&callout_lock); -- cgit v1.1