summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_timeout.c
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2004-08-06 02:44:58 +0000
committercperciva <cperciva@FreeBSD.org>2004-08-06 02:44:58 +0000
commitb4bae139fdb215c76a40d08f96e4f9b338cf7393 (patch)
treea4cd470532fe8d22706ca632c5c81b02e380eb2a /sys/kern/kern_timeout.c
parent2ce46f099e305079439e5da87d339ccdc1bf0006 (diff)
downloadFreeBSD-src-b4bae139fdb215c76a40d08f96e4f9b338cf7393.zip
FreeBSD-src-b4bae139fdb215c76a40d08f96e4f9b338cf7393.tar.gz
When reseting a pending callout, perform the deregistration in
callout_reset rather than calling callout_stop. This results in a few lines of code duplication, but it provides a significant performance improvement because it avoids recursing on callout_lock. Requested by: rwatson
Diffstat (limited to 'sys/kern/kern_timeout.c')
-rw-r--r--sys/kern/kern_timeout.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 031283c..eac675b 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -401,8 +401,22 @@ callout_reset(c, to_ticks, ftn, arg)
mtx_unlock_spin(&callout_lock);
return;
}
- if (c->c_flags & CALLOUT_PENDING)
- callout_stop(c);
+ if (c->c_flags & CALLOUT_PENDING) {
+ if (nextsoftcheck == c) {
+ nextsoftcheck = TAILQ_NEXT(c, c_links.tqe);
+ }
+ TAILQ_REMOVE(&callwheel[c->c_time & callwheelmask], c,
+ c_links.tqe);
+
+ /*
+ * Part of the normal "stop a pending callout" process
+ * is to clear the CALLOUT_ACTIVE and CALLOUT_PENDING
+ * flags. We're not going to bother doing that here,
+ * because we're going to be setting those flags ten lines
+ * after this point, and we're holding callout_lock
+ * between now and then.
+ */
+ }
/*
* We could unlock callout_lock here and lock it again before the
OpenPOWER on IntegriCloud