From b4bae139fdb215c76a40d08f96e4f9b338cf7393 Mon Sep 17 00:00:00 2001 From: cperciva Date: Fri, 6 Aug 2004 02:44:58 +0000 Subject: 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 --- sys/kern/kern_timeout.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sys/kern/kern_timeout.c') 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 -- cgit v1.1