2006-11-01 13:17:58 +03:00
|
|
|
/* $NetBSD: kern_timeout.c,v 1.19 2006/11/01 10:17:58 yamt Exp $ */
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Jason R. Thorpe.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
|
|
|
|
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
|
2005-02-27 00:34:55 +03:00
|
|
|
* All rights reserved.
|
2003-02-04 04:21:03 +03:00
|
|
|
*
|
2005-02-27 00:34:55 +03:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
2003-02-04 04:21:03 +03:00
|
|
|
*
|
2005-02-27 00:34:55 +03:00
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-02-04 04:21:03 +03:00
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
2005-02-27 00:34:55 +03:00
|
|
|
* derived from this software without specific prior written permission.
|
2003-02-04 04:21:03 +03:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
2005-02-27 00:34:55 +03:00
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2003-02-04 04:21:03 +03:00
|
|
|
*/
|
|
|
|
|
2003-07-14 18:59:01 +04:00
|
|
|
#include <sys/cdefs.h>
|
2006-11-01 13:17:58 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.19 2006/11/01 10:17:58 yamt Exp $");
|
2003-07-14 18:59:01 +04:00
|
|
|
|
2003-02-04 04:21:03 +03:00
|
|
|
/*
|
|
|
|
* Adapted from OpenBSD: kern_timeout.c,v 1.15 2002/12/08 04:21:07 art Exp,
|
|
|
|
* modified to match NetBSD's pre-existing callout API.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/callout.h>
|
|
|
|
|
|
|
|
#ifdef DDB
|
|
|
|
#include <machine/db_machdep.h>
|
|
|
|
#include <ddb/db_interface.h>
|
|
|
|
#include <ddb/db_access.h>
|
|
|
|
#include <ddb/db_sym.h>
|
|
|
|
#include <ddb/db_output.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Timeouts are kept in a hierarchical timing wheel. The c_time is the value
|
|
|
|
* of the global variable "hardclock_ticks" when the timeout should be called.
|
|
|
|
* There are four levels with 256 buckets each. See 'Scheme 7' in
|
|
|
|
* "Hashed and Hierarchical Timing Wheels: Efficient Data Structures for
|
|
|
|
* Implementing a Timer Facility" by George Varghese and Tony Lauck.
|
|
|
|
*/
|
|
|
|
#define BUCKETS 1024
|
|
|
|
#define WHEELSIZE 256
|
|
|
|
#define WHEELMASK 255
|
|
|
|
#define WHEELBITS 8
|
|
|
|
|
|
|
|
static struct callout_circq timeout_wheel[BUCKETS]; /* Queues of timeouts */
|
|
|
|
static struct callout_circq timeout_todo; /* Worklist */
|
|
|
|
|
|
|
|
#define MASKWHEEL(wheel, time) (((time) >> ((wheel)*WHEELBITS)) & WHEELMASK)
|
|
|
|
|
|
|
|
#define BUCKET(rel, abs) \
|
|
|
|
(((rel) <= (1 << (2*WHEELBITS))) \
|
|
|
|
? ((rel) <= (1 << WHEELBITS)) \
|
2003-02-10 22:18:56 +03:00
|
|
|
? &timeout_wheel[MASKWHEEL(0, (abs))] \
|
|
|
|
: &timeout_wheel[MASKWHEEL(1, (abs)) + WHEELSIZE] \
|
2003-02-04 04:21:03 +03:00
|
|
|
: ((rel) <= (1 << (3*WHEELBITS))) \
|
2003-02-10 22:18:56 +03:00
|
|
|
? &timeout_wheel[MASKWHEEL(2, (abs)) + 2*WHEELSIZE] \
|
|
|
|
: &timeout_wheel[MASKWHEEL(3, (abs)) + 3*WHEELSIZE])
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
#define MOVEBUCKET(wheel, time) \
|
|
|
|
CIRCQ_APPEND(&timeout_todo, \
|
|
|
|
&timeout_wheel[MASKWHEEL((wheel), (time)) + (wheel)*WHEELSIZE])
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All wheels are locked with the same lock (which must also block out all
|
|
|
|
* interrupts).
|
|
|
|
*/
|
|
|
|
static struct simplelock callout_slock;
|
|
|
|
|
|
|
|
#define CALLOUT_LOCK(s) \
|
|
|
|
do { \
|
|
|
|
s = splsched(); \
|
|
|
|
simple_lock(&callout_slock); \
|
|
|
|
} while (/*CONSTCOND*/0)
|
|
|
|
|
|
|
|
#define CALLOUT_UNLOCK(s) \
|
|
|
|
do { \
|
|
|
|
simple_unlock(&callout_slock); \
|
|
|
|
splx((s)); \
|
|
|
|
} while (/*CONSTCOND*/0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Circular queue definitions.
|
|
|
|
*/
|
|
|
|
|
2003-09-25 14:44:11 +04:00
|
|
|
#define CIRCQ_INIT(list) \
|
2003-02-04 04:21:03 +03:00
|
|
|
do { \
|
2003-09-25 14:44:11 +04:00
|
|
|
(list)->cq_next_l = (list); \
|
|
|
|
(list)->cq_prev_l = (list); \
|
2003-02-04 04:21:03 +03:00
|
|
|
} while (/*CONSTCOND*/0)
|
|
|
|
|
|
|
|
#define CIRCQ_INSERT(elem, list) \
|
|
|
|
do { \
|
2003-09-25 14:44:11 +04:00
|
|
|
(elem)->cq_prev_e = (list)->cq_prev_e; \
|
|
|
|
(elem)->cq_next_l = (list); \
|
|
|
|
(list)->cq_prev_l->cq_next_l = (elem); \
|
|
|
|
(list)->cq_prev_l = (elem); \
|
2003-02-04 04:21:03 +03:00
|
|
|
} while (/*CONSTCOND*/0)
|
|
|
|
|
|
|
|
#define CIRCQ_APPEND(fst, snd) \
|
|
|
|
do { \
|
|
|
|
if (!CIRCQ_EMPTY(snd)) { \
|
2003-09-25 14:44:11 +04:00
|
|
|
(fst)->cq_prev_l->cq_next_l = (snd)->cq_next_l; \
|
|
|
|
(snd)->cq_next_l->cq_prev_l = (fst)->cq_prev_l; \
|
|
|
|
(snd)->cq_prev_l->cq_next_l = (fst); \
|
|
|
|
(fst)->cq_prev_l = (snd)->cq_prev_l; \
|
2003-02-04 04:21:03 +03:00
|
|
|
CIRCQ_INIT(snd); \
|
|
|
|
} \
|
|
|
|
} while (/*CONSTCOND*/0)
|
|
|
|
|
|
|
|
#define CIRCQ_REMOVE(elem) \
|
|
|
|
do { \
|
2003-09-25 14:44:11 +04:00
|
|
|
(elem)->cq_next_l->cq_prev_e = (elem)->cq_prev_e; \
|
|
|
|
(elem)->cq_prev_l->cq_next_e = (elem)->cq_next_e; \
|
2003-02-04 04:21:03 +03:00
|
|
|
} while (/*CONSTCOND*/0)
|
|
|
|
|
2003-09-25 14:44:11 +04:00
|
|
|
#define CIRCQ_FIRST(list) ((list)->cq_next_e)
|
|
|
|
#define CIRCQ_NEXT(elem) ((elem)->cq_next_e)
|
|
|
|
#define CIRCQ_LAST(elem,list) ((elem)->cq_next_l == (list))
|
|
|
|
#define CIRCQ_EMPTY(list) ((list)->cq_next_l == (list))
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some of the "math" in here is a bit tricky.
|
|
|
|
*
|
|
|
|
* We have to beware of wrapping ints.
|
|
|
|
* We use the fact that any element added to the queue must be added with a
|
|
|
|
* positive time. That means that any element `to' on the queue cannot be
|
|
|
|
* scheduled to timeout further in time than INT_MAX, but c->c_time can
|
|
|
|
* be positive or negative so comparing it with anything is dangerous.
|
|
|
|
* The only way we can use the c->c_time value in any predictable way
|
2003-05-17 19:53:42 +04:00
|
|
|
* is when we calculate how far in the future `to' will timeout -
|
2003-02-04 04:21:03 +03:00
|
|
|
* "c->c_time - hardclock_ticks". The result will always be positive for
|
|
|
|
* future timeouts and 0 or negative for due timeouts.
|
|
|
|
*/
|
|
|
|
|
2003-02-27 02:13:19 +03:00
|
|
|
#ifdef CALLOUT_EVENT_COUNTERS
|
|
|
|
static struct evcnt callout_ev_late;
|
|
|
|
#endif
|
|
|
|
|
2003-02-04 04:21:03 +03:00
|
|
|
/*
|
|
|
|
* callout_startup:
|
|
|
|
*
|
|
|
|
* Initialize the callout facility, called at system startup time.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
callout_startup(void)
|
|
|
|
{
|
|
|
|
int b;
|
|
|
|
|
|
|
|
CIRCQ_INIT(&timeout_todo);
|
|
|
|
for (b = 0; b < BUCKETS; b++)
|
|
|
|
CIRCQ_INIT(&timeout_wheel[b]);
|
|
|
|
simple_lock_init(&callout_slock);
|
2003-02-27 02:13:19 +03:00
|
|
|
|
|
|
|
#ifdef CALLOUT_EVENT_COUNTERS
|
|
|
|
evcnt_attach_dynamic(&callout_ev_late, EVCNT_TYPE_MISC,
|
|
|
|
NULL, "callout", "late");
|
|
|
|
#endif
|
2003-02-04 04:21:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* callout_init:
|
|
|
|
*
|
|
|
|
* Initialize a callout structure.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
callout_init(struct callout *c)
|
|
|
|
{
|
|
|
|
|
|
|
|
memset(c, 0, sizeof(*c));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* callout_reset:
|
|
|
|
*
|
|
|
|
* Reset a callout structure with a new function and argument, and
|
|
|
|
* schedule it to run.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
callout_reset(struct callout *c, int to_ticks, void (*func)(void *), void *arg)
|
|
|
|
{
|
|
|
|
int s, old_time;
|
|
|
|
|
|
|
|
KASSERT(to_ticks >= 0);
|
|
|
|
|
|
|
|
CALLOUT_LOCK(s);
|
|
|
|
|
|
|
|
/* Initialize the time here, it won't change. */
|
|
|
|
old_time = c->c_time;
|
|
|
|
c->c_time = to_ticks + hardclock_ticks;
|
2003-07-20 20:25:57 +04:00
|
|
|
c->c_flags &= ~(CALLOUT_FIRED|CALLOUT_INVOKING);
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
c->c_func = func;
|
|
|
|
c->c_arg = arg;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this timeout is already scheduled and now is moved
|
|
|
|
* earlier, reschedule it now. Otherwise leave it in place
|
|
|
|
* and let it be rescheduled later.
|
|
|
|
*/
|
|
|
|
if (callout_pending(c)) {
|
2003-02-11 12:43:37 +03:00
|
|
|
if (c->c_time - old_time < 0) {
|
2003-02-04 04:21:03 +03:00
|
|
|
CIRCQ_REMOVE(&c->c_list);
|
|
|
|
CIRCQ_INSERT(&c->c_list, &timeout_todo);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
c->c_flags |= CALLOUT_PENDING;
|
|
|
|
CIRCQ_INSERT(&c->c_list, &timeout_todo);
|
|
|
|
}
|
|
|
|
|
|
|
|
CALLOUT_UNLOCK(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* callout_schedule:
|
|
|
|
*
|
|
|
|
* Schedule a callout to run. The function and argument must
|
|
|
|
* already be set in the callout structure.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
callout_schedule(struct callout *c, int to_ticks)
|
|
|
|
{
|
|
|
|
int s, old_time;
|
|
|
|
|
|
|
|
KASSERT(to_ticks >= 0);
|
|
|
|
|
|
|
|
CALLOUT_LOCK(s);
|
|
|
|
|
|
|
|
/* Initialize the time here, it won't change. */
|
|
|
|
old_time = c->c_time;
|
|
|
|
c->c_time = to_ticks + hardclock_ticks;
|
2003-07-20 20:25:57 +04:00
|
|
|
c->c_flags &= ~(CALLOUT_FIRED|CALLOUT_INVOKING);
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this timeout is already scheduled and now is moved
|
|
|
|
* earlier, reschedule it now. Otherwise leave it in place
|
|
|
|
* and let it be rescheduled later.
|
|
|
|
*/
|
|
|
|
if (callout_pending(c)) {
|
2003-02-11 12:43:37 +03:00
|
|
|
if (c->c_time - old_time < 0) {
|
2003-02-04 04:21:03 +03:00
|
|
|
CIRCQ_REMOVE(&c->c_list);
|
|
|
|
CIRCQ_INSERT(&c->c_list, &timeout_todo);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
c->c_flags |= CALLOUT_PENDING;
|
|
|
|
CIRCQ_INSERT(&c->c_list, &timeout_todo);
|
|
|
|
}
|
|
|
|
|
|
|
|
CALLOUT_UNLOCK(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* callout_stop:
|
|
|
|
*
|
|
|
|
* Cancel a pending callout.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
callout_stop(struct callout *c)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
CALLOUT_LOCK(s);
|
|
|
|
|
|
|
|
if (callout_pending(c))
|
|
|
|
CIRCQ_REMOVE(&c->c_list);
|
|
|
|
|
2003-08-03 23:14:59 +04:00
|
|
|
c->c_flags &= ~(CALLOUT_PENDING|CALLOUT_FIRED);
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
CALLOUT_UNLOCK(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is called from hardclock() once every tick.
|
|
|
|
* We return !0 if we need to schedule a softclock.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
callout_hardclock(void)
|
|
|
|
{
|
|
|
|
int s;
|
2003-02-11 12:43:37 +03:00
|
|
|
int needsoftclock;
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
CALLOUT_LOCK(s);
|
|
|
|
|
|
|
|
MOVEBUCKET(0, hardclock_ticks);
|
|
|
|
if (MASKWHEEL(0, hardclock_ticks) == 0) {
|
|
|
|
MOVEBUCKET(1, hardclock_ticks);
|
|
|
|
if (MASKWHEEL(1, hardclock_ticks) == 0) {
|
|
|
|
MOVEBUCKET(2, hardclock_ticks);
|
|
|
|
if (MASKWHEEL(2, hardclock_ticks) == 0)
|
|
|
|
MOVEBUCKET(3, hardclock_ticks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-11 12:43:37 +03:00
|
|
|
needsoftclock = !CIRCQ_EMPTY(&timeout_todo);
|
2003-02-04 04:21:03 +03:00
|
|
|
CALLOUT_UNLOCK(s);
|
|
|
|
|
2003-02-11 12:43:37 +03:00
|
|
|
return needsoftclock;
|
2003-02-04 04:21:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
|
|
|
void
|
2006-11-01 13:17:58 +03:00
|
|
|
softclock(void *v)
|
2003-02-04 04:21:03 +03:00
|
|
|
{
|
|
|
|
struct callout *c;
|
|
|
|
void (*func)(void *);
|
|
|
|
void *arg;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
CALLOUT_LOCK(s);
|
|
|
|
|
|
|
|
while (!CIRCQ_EMPTY(&timeout_todo)) {
|
2003-09-25 14:44:11 +04:00
|
|
|
c = CIRCQ_FIRST(&timeout_todo);
|
2003-02-04 04:21:03 +03:00
|
|
|
CIRCQ_REMOVE(&c->c_list);
|
|
|
|
|
|
|
|
/* If due run it, otherwise insert it into the right bucket. */
|
|
|
|
if (c->c_time - hardclock_ticks > 0) {
|
|
|
|
CIRCQ_INSERT(&c->c_list,
|
2003-02-10 22:18:56 +03:00
|
|
|
BUCKET((c->c_time - hardclock_ticks), c->c_time));
|
2003-02-04 04:21:03 +03:00
|
|
|
} else {
|
2003-02-27 02:13:19 +03:00
|
|
|
#ifdef CALLOUT_EVENT_COUNTERS
|
2003-02-04 04:21:03 +03:00
|
|
|
if (c->c_time - hardclock_ticks < 0)
|
2003-02-27 02:13:19 +03:00
|
|
|
callout_ev_late.ev_count++;
|
2003-02-04 04:21:03 +03:00
|
|
|
#endif
|
|
|
|
c->c_flags = (c->c_flags & ~CALLOUT_PENDING) |
|
2003-07-20 20:25:57 +04:00
|
|
|
(CALLOUT_FIRED|CALLOUT_INVOKING);
|
2003-02-04 04:21:03 +03:00
|
|
|
|
|
|
|
func = c->c_func;
|
|
|
|
arg = c->c_arg;
|
|
|
|
|
|
|
|
CALLOUT_UNLOCK(s);
|
|
|
|
(*func)(arg);
|
|
|
|
CALLOUT_LOCK(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CALLOUT_UNLOCK(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DDB
|
|
|
|
static void
|
|
|
|
db_show_callout_bucket(struct callout_circq *bucket)
|
|
|
|
{
|
|
|
|
struct callout *c;
|
|
|
|
db_expr_t offset;
|
2005-05-30 02:24:14 +04:00
|
|
|
const char *name;
|
|
|
|
static char question[] = "?";
|
2003-02-04 04:21:03 +03:00
|
|
|
|
2003-09-25 14:44:11 +04:00
|
|
|
if (CIRCQ_EMPTY(bucket))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (c = CIRCQ_FIRST(bucket); /*nothing*/; c = CIRCQ_NEXT(&c->c_list)) {
|
2003-09-08 01:28:16 +04:00
|
|
|
db_find_sym_and_offset((db_addr_t)(intptr_t)c->c_func, &name,
|
|
|
|
&offset);
|
2005-05-30 02:24:14 +04:00
|
|
|
name = name ? name : question;
|
2003-02-04 04:21:03 +03:00
|
|
|
#ifdef _LP64
|
|
|
|
#define POINTER_WIDTH "%16lx"
|
|
|
|
#else
|
|
|
|
#define POINTER_WIDTH "%8lx"
|
|
|
|
#endif
|
|
|
|
db_printf("%9d %2d/%-4d " POINTER_WIDTH " %s\n",
|
|
|
|
c->c_time - hardclock_ticks,
|
2003-02-04 13:14:53 +03:00
|
|
|
(int)((bucket - timeout_wheel) / WHEELSIZE),
|
|
|
|
(int)(bucket - timeout_wheel), (u_long) c->c_arg, name);
|
2003-09-25 14:44:11 +04:00
|
|
|
|
|
|
|
if (CIRCQ_LAST(&c->c_list, bucket))
|
|
|
|
break;
|
2003-02-04 04:21:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-11-01 13:17:58 +03:00
|
|
|
db_show_callout(db_expr_t addr, int haddr, db_expr_t count, const char *modif)
|
2003-02-04 04:21:03 +03:00
|
|
|
{
|
|
|
|
int b;
|
|
|
|
|
|
|
|
db_printf("hardclock_ticks now: %d\n", hardclock_ticks);
|
|
|
|
#ifdef _LP64
|
|
|
|
db_printf(" ticks wheel arg func\n");
|
|
|
|
#else
|
|
|
|
db_printf(" ticks wheel arg func\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't lock the callwheel; all the other CPUs are paused
|
|
|
|
* anyhow, and we might be called in a circumstance where
|
|
|
|
* some other CPU was paused while holding the lock.
|
|
|
|
*/
|
|
|
|
|
|
|
|
db_show_callout_bucket(&timeout_todo);
|
|
|
|
for (b = 0; b < BUCKETS; b++)
|
|
|
|
db_show_callout_bucket(&timeout_wheel[b]);
|
|
|
|
}
|
|
|
|
#endif /* DDB */
|