Index: sys/kern/kern_timeout.c =================================================================== --- sys/kern/kern_timeout.c (revision 239017) +++ sys/kern/kern_timeout.c (working copy) @@ -448,6 +448,7 @@ callout_process(struct bintime *now) break; first = (first + 1) & callwheelmask; } + cc->cc_exec_next_dir = NULL; future = (last + hz / 4) & callwheelmask; max.sec = min.sec = TIME_T_MAX; max.frac = min.frac = UINT64_MAX; @@ -614,9 +615,12 @@ callout_cc_add(struct callout *c, struct callout_c static void callout_cc_del(struct callout *c, struct callout_cpu *cc, int direct) { - if (direct && cc->cc_exec_next_dir == c) + + if (((c->c_flags & CALLOUT_PROCESSED) == 0) && direct && + cc->cc_exec_next_dir == c) cc->cc_exec_next_dir = TAILQ_NEXT(c, c_links.tqe); - else if (!direct && cc->cc_exec_next == c) + else if ((c->c_flags & CALLOUT_PROCESSED) && !direct && + cc->cc_exec_next == c) cc->cc_exec_next = TAILQ_NEXT(c, c_staiter); if (c->c_flags & CALLOUT_LOCAL_ALLOC) { c->c_func = NULL; @@ -649,12 +653,8 @@ softclock_call_cc(struct callout *c, struct callou if (direct) cc->cc_exec_next_dir = TAILQ_NEXT(c, c_links.tqe); - else { - if ((c->c_flags & CALLOUT_PROCESSED) == 0) - cc->cc_exec_next = TAILQ_NEXT(c, c_links.tqe); - else - cc->cc_exec_next = TAILQ_NEXT(c, c_staiter); - } + else + cc->cc_exec_next = TAILQ_NEXT(c, c_staiter); class = (c->c_lock != NULL) ? LOCK_CLASS(c->c_lock) : NULL; sharedlock = (c->c_flags & CALLOUT_SHAREDLOCK) ? 0 : 1; c_lock = c->c_lock; @@ -844,6 +844,7 @@ softclock(void *arg) avg_lockcalls += (lockcalls * 1000 - avg_lockcalls) >> 8; avg_gcalls += (gcalls * 1000 - avg_gcalls) >> 8; #endif + cc->cc_exec_next = NULL; CC_UNLOCK(cc); } @@ -980,9 +981,7 @@ _callout_reset_on(struct callout *c, struct bintim } if (c->c_flags & CALLOUT_PENDING) { if ((c->c_flags & CALLOUT_PROCESSED) == 0) { - if (cc->cc_exec_next == c) - cc->cc_exec_next = TAILQ_NEXT(c, c_links.tqe); - else if (cc->cc_exec_next_dir == c) + if (cc->cc_exec_next_dir == c) cc->cc_exec_next_dir = TAILQ_NEXT(c, c_links.tqe); bucket = get_bucket(&c->c_time);