summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-06-04 05:25:58 +0000
committerphk <phk@FreeBSD.org>2003-06-04 05:25:58 +0000
commita9b8284f73dbdded9334e7fdd26f87bc17b0e835 (patch)
tree83c7195ae295dd36a56408597209445534d27bc4 /sys
parent56091404e85973cb405b9e03d2157364e96a4e0c (diff)
downloadFreeBSD-src-a9b8284f73dbdded9334e7fdd26f87bc17b0e835.zip
FreeBSD-src-a9b8284f73dbdded9334e7fdd26f87bc17b0e835.tar.gz
Add instrumentation which tells us how much work softclock() does
per invocation.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_timeout.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 34b6d8c..8d4be83 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -45,7 +45,17 @@
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
-
+#include <sys/sysctl.h>
+
+static int avg_depth;
+SYSCTL_INT(_debug, OID_AUTO, to_avg_depth, CTLFLAG_RD, &avg_depth, 0,
+ "Average number of items examined per softclock call. Units = 1/1000");
+static int avg_gcalls;
+SYSCTL_INT(_debug, OID_AUTO, to_avg_gcalls, CTLFLAG_RD, &avg_gcalls, 0,
+ "Average number of Giant callouts made per softclock call. Units = 1/1000");
+static int avg_mpcalls;
+SYSCTL_INT(_debug, OID_AUTO, to_avg_mpcalls, CTLFLAG_RD, &avg_mpcalls, 0,
+ "Average number of MP callouts made per softclock call. Units = 1/1000");
/*
* TODO:
* allocate more timeout table slots when table overflows.
@@ -133,6 +143,9 @@ softclock(void *dummy)
struct callout_tailq *bucket;
int curticks;
int steps; /* #steps since we last allowed interrupts */
+ int depth;
+ int mpcalls;
+ int gcalls;
#ifdef DIAGNOSTIC
struct bintime bt1, bt2;
struct timespec ts2;
@@ -143,6 +156,9 @@ softclock(void *dummy)
#define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */
#endif /* MAX_SOFTCLOCK_STEPS */
+ mpcalls = 0;
+ gcalls = 0;
+ depth = 0;
steps = 0;
mtx_lock_spin(&callout_lock);
while (softticks != ticks) {
@@ -155,6 +171,7 @@ softclock(void *dummy)
bucket = &callwheel[curticks & callwheelmask];
c = TAILQ_FIRST(bucket);
while (c) {
+ depth++;
if (c->c_time != curticks) {
c = TAILQ_NEXT(c, c_links.tqe);
++steps;
@@ -187,8 +204,12 @@ softclock(void *dummy)
(c->c_flags & ~CALLOUT_PENDING);
}
mtx_unlock_spin(&callout_lock);
- if (!(c_flags & CALLOUT_MPSAFE))
+ if (!(c_flags & CALLOUT_MPSAFE)) {
mtx_lock(&Giant);
+ gcalls++;
+ } else {
+ mpcalls++;
+ }
#ifdef DIAGNOSTIC
binuptime(&bt1);
#endif
@@ -213,6 +234,9 @@ softclock(void *dummy)
}
}
}
+ avg_depth += (depth * 1000 - avg_depth) >> 8;
+ avg_mpcalls += (mpcalls * 1000 - avg_mpcalls) >> 8;
+ avg_gcalls += (gcalls * 1000 - avg_gcalls) >> 8;
nextsoftcheck = NULL;
mtx_unlock_spin(&callout_lock);
}
OpenPOWER on IntegriCloud