diff options
author | phk <phk@FreeBSD.org> | 2002-09-04 20:05:00 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-04 20:05:00 +0000 |
commit | b1f33fc74e2b3b76887c175f8c8465fdf0df469b (patch) | |
tree | 2cc247df5f50925f809a8c0738b33211fa9213b8 /sys/kern/kern_timeout.c | |
parent | 27e53f19b6cfd4ea1e6031886923a38c9baa0fb9 (diff) | |
download | FreeBSD-src-b1f33fc74e2b3b76887c175f8c8465fdf0df469b.zip FreeBSD-src-b1f33fc74e2b3b76887c175f8c8465fdf0df469b.tar.gz |
Under DIAGNOSTIC, complain if a timeout(9) routine took more than 1msec.
Diffstat (limited to 'sys/kern/kern_timeout.c')
-rw-r--r-- | sys/kern/kern_timeout.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 937b0c2..85e18c3 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -129,10 +129,15 @@ kern_timeout_callwheel_init(void) void softclock(void *dummy) { - register struct callout *c; - register struct callout_tailq *bucket; - register int curticks; - register int steps; /* #steps since we last allowed interrupts */ + struct callout *c; + struct callout_tailq *bucket; + int curticks; + int steps; /* #steps since we last allowed interrupts */ +#ifdef DIAGNOSTIC + struct bintime bt1, bt2; + struct timespec ts2; + static uint64_t maxdt = 18446744073709551LL; /* 1 msec */ +#endif #ifndef MAX_SOFTCLOCK_STEPS #define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */ @@ -184,7 +189,21 @@ softclock(void *dummy) mtx_unlock_spin(&callout_lock); if (!(c_flags & CALLOUT_MPSAFE)) mtx_lock(&Giant); +#ifdef DIAGNOSTIC + binuptime(&bt1); +#endif c_func(c_arg); +#ifdef DIAGNOSTIC + binuptime(&bt2); + bintime_sub(&bt2, &bt1); + if (bt2.frac > maxdt) { + bintime2timespec(&bt2, &ts2); + printf( + "Expensive timeout(9) function: %p(%p) %d.%09d\n", + c_func, c_arg, + ts2.tv_sec, ts2.tv_nsec); + } +#endif if (!(c_flags & CALLOUT_MPSAFE)) mtx_unlock(&Giant); mtx_lock_spin(&callout_lock); |