kern_timeout.c revision 1.34 1 /* $NetBSD: kern_timeout.c,v 1.34 2008/03/29 14:00:55 ad Exp $ */
2
3 /*-
4 * Copyright (c) 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe, and by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Copyright (c) 2001 Thomas Nordin <nordin (at) openbsd.org>
41 * Copyright (c) 2000-2001 Artur Grabowski <art (at) openbsd.org>
42 * All rights reserved.
43 *
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 *
48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
53 * 3. The name of the author may not be used to endorse or promote products
54 * derived from this software without specific prior written permission.
55 *
56 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
57 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
58 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
59 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
60 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
61 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
62 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
63 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
64 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
65 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 */
67
68 #include <sys/cdefs.h>
69 __KERNEL_RCSID(0, "$NetBSD: kern_timeout.c,v 1.34 2008/03/29 14:00:55 ad Exp $");
70
71 /*
72 * Timeouts are kept in a hierarchical timing wheel. The c_time is the
73 * value of the global variable "hardclock_ticks" when the timeout should
74 * be called. There are four levels with 256 buckets each. See 'Scheme 7'
75 * in "Hashed and Hierarchical Timing Wheels: Efficient Data Structures
76 * for Implementing a Timer Facility" by George Varghese and Tony Lauck.
77 *
78 * Some of the "math" in here is a bit tricky. We have to beware of
79 * wrapping ints.
80 *
81 * We use the fact that any element added to the queue must be added with
82 * a positive time. That means that any element `to' on the queue cannot
83 * be scheduled to timeout further in time than INT_MAX, but c->c_time can
84 * be positive or negative so comparing it with anything is dangerous.
85 * The only way we can use the c->c_time value in any predictable way is
86 * when we calculate how far in the future `to' will timeout - "c->c_time
87 * - hardclock_ticks". The result will always be positive for future
88 * timeouts and 0 or negative for due timeouts.
89 */
90
91 #define _CALLOUT_PRIVATE
92
93 #include <sys/param.h>
94 #include <sys/systm.h>
95 #include <sys/kernel.h>
96 #include <sys/callout.h>
97 #include <sys/mutex.h>
98 #include <sys/proc.h>
99 #include <sys/sleepq.h>
100 #include <sys/syncobj.h>
101 #include <sys/evcnt.h>
102 #include <sys/intr.h>
103 #include <sys/cpu.h>
104
105 #ifdef DDB
106 #include <machine/db_machdep.h>
107 #include <ddb/db_interface.h>
108 #include <ddb/db_access.h>
109 #include <ddb/db_sym.h>
110 #include <ddb/db_output.h>
111 #endif
112
113 #define BUCKETS 1024
114 #define WHEELSIZE 256
115 #define WHEELMASK 255
116 #define WHEELBITS 8
117
118 static struct callout_circq timeout_wheel[BUCKETS]; /* Queues of timeouts */
119 static struct callout_circq timeout_todo; /* Worklist */
120
121 #define MASKWHEEL(wheel, time) (((time) >> ((wheel)*WHEELBITS)) & WHEELMASK)
122
123 #define BUCKET(rel, abs) \
124 (((rel) <= (1 << (2*WHEELBITS))) \
125 ? ((rel) <= (1 << WHEELBITS)) \
126 ? &timeout_wheel[MASKWHEEL(0, (abs))] \
127 : &timeout_wheel[MASKWHEEL(1, (abs)) + WHEELSIZE] \
128 : ((rel) <= (1 << (3*WHEELBITS))) \
129 ? &timeout_wheel[MASKWHEEL(2, (abs)) + 2*WHEELSIZE] \
130 : &timeout_wheel[MASKWHEEL(3, (abs)) + 3*WHEELSIZE])
131
132 #define MOVEBUCKET(wheel, time) \
133 CIRCQ_APPEND(&timeout_todo, \
134 &timeout_wheel[MASKWHEEL((wheel), (time)) + (wheel)*WHEELSIZE])
135
136 /*
137 * Circular queue definitions.
138 */
139
140 #define CIRCQ_INIT(list) \
141 do { \
142 (list)->cq_next_l = (list); \
143 (list)->cq_prev_l = (list); \
144 } while (/*CONSTCOND*/0)
145
146 #define CIRCQ_INSERT(elem, list) \
147 do { \
148 (elem)->cq_prev_e = (list)->cq_prev_e; \
149 (elem)->cq_next_l = (list); \
150 (list)->cq_prev_l->cq_next_l = (elem); \
151 (list)->cq_prev_l = (elem); \
152 } while (/*CONSTCOND*/0)
153
154 #define CIRCQ_APPEND(fst, snd) \
155 do { \
156 if (!CIRCQ_EMPTY(snd)) { \
157 (fst)->cq_prev_l->cq_next_l = (snd)->cq_next_l; \
158 (snd)->cq_next_l->cq_prev_l = (fst)->cq_prev_l; \
159 (snd)->cq_prev_l->cq_next_l = (fst); \
160 (fst)->cq_prev_l = (snd)->cq_prev_l; \
161 CIRCQ_INIT(snd); \
162 } \
163 } while (/*CONSTCOND*/0)
164
165 #define CIRCQ_REMOVE(elem) \
166 do { \
167 (elem)->cq_next_l->cq_prev_e = (elem)->cq_prev_e; \
168 (elem)->cq_prev_l->cq_next_e = (elem)->cq_next_e; \
169 } while (/*CONSTCOND*/0)
170
171 #define CIRCQ_FIRST(list) ((list)->cq_next_e)
172 #define CIRCQ_NEXT(elem) ((elem)->cq_next_e)
173 #define CIRCQ_LAST(elem,list) ((elem)->cq_next_l == (list))
174 #define CIRCQ_EMPTY(list) ((list)->cq_next_l == (list))
175
176 static void callout_softclock(void *);
177
178 /*
179 * All wheels are locked with the same lock (which must also block out
180 * all interrupts). Eventually this should become per-CPU.
181 */
182 kmutex_t callout_lock;
183 sleepq_t callout_sleepq;
184 void *callout_si;
185
186 static struct evcnt callout_ev_late;
187 static struct evcnt callout_ev_block;
188
189 /*
190 * callout_startup:
191 *
192 * Initialize the callout facility, called at system startup time.
193 */
194 void
195 callout_startup(void)
196 {
197 int b;
198
199 KASSERT(sizeof(callout_impl_t) <= sizeof(callout_t));
200
201 CIRCQ_INIT(&timeout_todo);
202 for (b = 0; b < BUCKETS; b++)
203 CIRCQ_INIT(&timeout_wheel[b]);
204
205 mutex_init(&callout_lock, MUTEX_DEFAULT, IPL_SCHED);
206 sleepq_init(&callout_sleepq, &callout_lock);
207
208 evcnt_attach_dynamic(&callout_ev_late, EVCNT_TYPE_MISC,
209 NULL, "callout", "late");
210 evcnt_attach_dynamic(&callout_ev_block, EVCNT_TYPE_MISC,
211 NULL, "callout", "wait for completion");
212 }
213
214 /*
215 * callout_startup2:
216 *
217 * Complete initialization once soft interrupts are available.
218 */
219 void
220 callout_startup2(void)
221 {
222
223 callout_si = softint_establish(SOFTINT_CLOCK | SOFTINT_MPSAFE,
224 callout_softclock, NULL);
225 if (callout_si == NULL)
226 panic("callout_startup2: unable to register softclock intr");
227 }
228
229 /*
230 * callout_init:
231 *
232 * Initialize a callout structure.
233 */
234 void
235 callout_init(callout_t *cs, u_int flags)
236 {
237 callout_impl_t *c = (callout_impl_t *)cs;
238
239 KASSERT((flags & ~CALLOUT_FLAGMASK) == 0);
240
241 memset(c, 0, sizeof(*c));
242 c->c_flags = flags;
243 c->c_magic = CALLOUT_MAGIC;
244 }
245
246 /*
247 * callout_destroy:
248 *
249 * Destroy a callout structure. The callout must be stopped.
250 */
251 void
252 callout_destroy(callout_t *cs)
253 {
254 callout_impl_t *c = (callout_impl_t *)cs;
255
256 /*
257 * It's not necessary to lock in order to see the correct value
258 * of c->c_flags. If the callout could potentially have been
259 * running, the current thread should have stopped it.
260 */
261 KASSERT((c->c_flags & CALLOUT_PENDING) == 0);
262 if (c->c_oncpu != NULL && c->c_onlwp != curlwp) {
263 KASSERT(
264 ((struct cpu_info *)c->c_oncpu)->ci_data.cpu_callout != c);
265 }
266 KASSERT(c->c_magic == CALLOUT_MAGIC);
267
268 c->c_magic = 0;
269 }
270
271 /*
272 * callout_schedule_locked:
273 *
274 * Schedule a callout to run. The function and argument must
275 * already be set in the callout structure. Must be called with
276 * callout_lock.
277 */
278 static void
279 callout_schedule_locked(callout_impl_t *c, int to_ticks)
280 {
281 int old_time;
282
283 KASSERT(to_ticks >= 0);
284 KASSERT(c->c_func != NULL);
285
286 /* Initialize the time here, it won't change. */
287 old_time = c->c_time;
288 c->c_time = to_ticks + hardclock_ticks;
289 c->c_flags &= ~CALLOUT_FIRED;
290
291 /*
292 * If this timeout is already scheduled and now is moved
293 * earlier, reschedule it now. Otherwise leave it in place
294 * and let it be rescheduled later.
295 */
296 if ((c->c_flags & CALLOUT_PENDING) != 0) {
297 if (c->c_time - old_time < 0) {
298 CIRCQ_REMOVE(&c->c_list);
299 CIRCQ_INSERT(&c->c_list, &timeout_todo);
300 }
301 } else {
302 c->c_flags |= CALLOUT_PENDING;
303 CIRCQ_INSERT(&c->c_list, &timeout_todo);
304 }
305 }
306
307 /*
308 * callout_reset:
309 *
310 * Reset a callout structure with a new function and argument, and
311 * schedule it to run.
312 */
313 void
314 callout_reset(callout_t *cs, int to_ticks, void (*func)(void *), void *arg)
315 {
316 callout_impl_t *c = (callout_impl_t *)cs;
317
318 KASSERT(c->c_magic == CALLOUT_MAGIC);
319
320 mutex_spin_enter(&callout_lock);
321
322 c->c_func = func;
323 c->c_arg = arg;
324
325 callout_schedule_locked(c, to_ticks);
326
327 mutex_spin_exit(&callout_lock);
328 }
329
330 /*
331 * callout_schedule:
332 *
333 * Schedule a callout to run. The function and argument must
334 * already be set in the callout structure.
335 */
336 void
337 callout_schedule(callout_t *cs, int to_ticks)
338 {
339 callout_impl_t *c = (callout_impl_t *)cs;
340
341 KASSERT(c->c_magic == CALLOUT_MAGIC);
342
343 mutex_spin_enter(&callout_lock);
344 callout_schedule_locked(c, to_ticks);
345 mutex_spin_exit(&callout_lock);
346 }
347
348
349 /*
350 * callout_stop:
351 *
352 * Try to cancel a pending callout.
353 */
354 bool
355 callout_stop(callout_t *cs)
356 {
357 callout_impl_t *c = (callout_impl_t *)cs;
358 struct cpu_info *ci;
359 bool expired;
360
361 KASSERT(c->c_magic == CALLOUT_MAGIC);
362
363 mutex_spin_enter(&callout_lock);
364
365 if ((c->c_flags & CALLOUT_PENDING) != 0)
366 CIRCQ_REMOVE(&c->c_list);
367 expired = ((c->c_flags & CALLOUT_FIRED) != 0);
368 c->c_flags &= ~(CALLOUT_PENDING|CALLOUT_FIRED);
369
370 if ((ci = c->c_oncpu) != NULL && ci->ci_data.cpu_callout == c) {
371 /*
372 * This is for non-MPSAFE callouts only. To synchronize
373 * effectively we must be called with kernel_lock held.
374 * It's also taken in callout_softclock.
375 */
376 ci = c->c_oncpu;
377 ci->ci_data.cpu_callout_cancel = c;
378 }
379
380 mutex_spin_exit(&callout_lock);
381
382 return expired;
383 }
384
385 /*
386 * callout_halt:
387 *
388 * Cancel a pending callout. If in-flight, block until it completes.
389 * May not be called from a hard interrupt handler.
390 */
391 bool
392 callout_halt(callout_t *cs)
393 {
394 callout_impl_t *c = (callout_impl_t *)cs;
395 extern syncobj_t sleep_syncobj;
396 struct cpu_info *ci;
397 struct lwp *l;
398 bool expired;
399
400 KASSERT(c->c_magic == CALLOUT_MAGIC);
401 KASSERT(!cpu_intr_p());
402
403 mutex_spin_enter(&callout_lock);
404
405 expired = ((c->c_flags & CALLOUT_FIRED) != 0);
406 if ((c->c_flags & CALLOUT_PENDING) != 0)
407 CIRCQ_REMOVE(&c->c_list);
408 c->c_flags &= ~(CALLOUT_PENDING|CALLOUT_FIRED);
409
410 l = curlwp;
411 while (__predict_false((ci = c->c_oncpu) != NULL &&
412 ci->ci_data.cpu_callout == c && c->c_onlwp != l)) {
413 KASSERT(l->l_wchan == NULL);
414
415 ci->ci_data.cpu_callout_nwait++;
416 callout_ev_block.ev_count++;
417
418 l->l_kpriority = true;
419 sleepq_enter(&callout_sleepq, l);
420 sleepq_enqueue(&callout_sleepq, ci, "callout", &sleep_syncobj);
421 KERNEL_UNLOCK_ALL(l, &l->l_biglocks);
422 sleepq_block(0, false);
423 mutex_spin_enter(&callout_lock);
424 }
425
426 mutex_spin_exit(&callout_lock);
427
428 return expired;
429 }
430
431 void
432 callout_setfunc(callout_t *cs, void (*func)(void *), void *arg)
433 {
434 callout_impl_t *c = (callout_impl_t *)cs;
435
436 KASSERT(c->c_magic == CALLOUT_MAGIC);
437
438 mutex_spin_enter(&callout_lock);
439 c->c_func = func;
440 c->c_arg = arg;
441 mutex_spin_exit(&callout_lock);
442 }
443
444 bool
445 callout_expired(callout_t *cs)
446 {
447 callout_impl_t *c = (callout_impl_t *)cs;
448 bool rv;
449
450 KASSERT(c->c_magic == CALLOUT_MAGIC);
451
452 mutex_spin_enter(&callout_lock);
453 rv = ((c->c_flags & CALLOUT_FIRED) != 0);
454 mutex_spin_exit(&callout_lock);
455
456 return rv;
457 }
458
459 bool
460 callout_active(callout_t *cs)
461 {
462 callout_impl_t *c = (callout_impl_t *)cs;
463 bool rv;
464
465 KASSERT(c->c_magic == CALLOUT_MAGIC);
466
467 mutex_spin_enter(&callout_lock);
468 rv = ((c->c_flags & (CALLOUT_PENDING|CALLOUT_FIRED)) != 0);
469 mutex_spin_exit(&callout_lock);
470
471 return rv;
472 }
473
474 bool
475 callout_pending(callout_t *cs)
476 {
477 callout_impl_t *c = (callout_impl_t *)cs;
478 bool rv;
479
480 KASSERT(c->c_magic == CALLOUT_MAGIC);
481
482 mutex_spin_enter(&callout_lock);
483 rv = ((c->c_flags & CALLOUT_PENDING) != 0);
484 mutex_spin_exit(&callout_lock);
485
486 return rv;
487 }
488
489 bool
490 callout_invoking(callout_t *cs)
491 {
492 callout_impl_t *c = (callout_impl_t *)cs;
493 bool rv;
494
495 KASSERT(c->c_magic == CALLOUT_MAGIC);
496
497 mutex_spin_enter(&callout_lock);
498 rv = ((c->c_flags & CALLOUT_INVOKING) != 0);
499 mutex_spin_exit(&callout_lock);
500
501 return rv;
502 }
503
504 void
505 callout_ack(callout_t *cs)
506 {
507 callout_impl_t *c = (callout_impl_t *)cs;
508
509 KASSERT(c->c_magic == CALLOUT_MAGIC);
510
511 mutex_spin_enter(&callout_lock);
512 c->c_flags &= ~CALLOUT_INVOKING;
513 mutex_spin_exit(&callout_lock);
514 }
515
516 /*
517 * This is called from hardclock() once every tick.
518 * We schedule callout_softclock() if there is work
519 * to be done.
520 */
521 void
522 callout_hardclock(void)
523 {
524 int needsoftclock;
525
526 mutex_spin_enter(&callout_lock);
527
528 MOVEBUCKET(0, hardclock_ticks);
529 if (MASKWHEEL(0, hardclock_ticks) == 0) {
530 MOVEBUCKET(1, hardclock_ticks);
531 if (MASKWHEEL(1, hardclock_ticks) == 0) {
532 MOVEBUCKET(2, hardclock_ticks);
533 if (MASKWHEEL(2, hardclock_ticks) == 0)
534 MOVEBUCKET(3, hardclock_ticks);
535 }
536 }
537
538 needsoftclock = !CIRCQ_EMPTY(&timeout_todo);
539 mutex_spin_exit(&callout_lock);
540
541 if (needsoftclock)
542 softint_schedule(callout_si);
543 }
544
545 /* ARGSUSED */
546 static void
547 callout_softclock(void *v)
548 {
549 callout_impl_t *c;
550 struct cpu_info *ci;
551 void (*func)(void *);
552 void *arg;
553 u_int mpsafe, count;
554 lwp_t *l;
555
556 l = curlwp;
557 ci = l->l_cpu;
558
559 mutex_spin_enter(&callout_lock);
560
561 while (!CIRCQ_EMPTY(&timeout_todo)) {
562 c = CIRCQ_FIRST(&timeout_todo);
563 KASSERT(c->c_magic == CALLOUT_MAGIC);
564 KASSERT(c->c_func != NULL);
565 KASSERT((c->c_flags & CALLOUT_PENDING) != 0);
566 KASSERT((c->c_flags & CALLOUT_FIRED) == 0);
567 CIRCQ_REMOVE(&c->c_list);
568
569 /* If due run it, otherwise insert it into the right bucket. */
570 if (c->c_time - hardclock_ticks > 0) {
571 CIRCQ_INSERT(&c->c_list,
572 BUCKET((c->c_time - hardclock_ticks), c->c_time));
573 } else {
574 if (c->c_time - hardclock_ticks < 0)
575 callout_ev_late.ev_count++;
576
577 c->c_flags ^= (CALLOUT_PENDING | CALLOUT_FIRED);
578 mpsafe = (c->c_flags & CALLOUT_MPSAFE);
579 func = c->c_func;
580 arg = c->c_arg;
581 c->c_oncpu = ci;
582 c->c_onlwp = l;
583 ci->ci_data.cpu_callout = c;
584
585 mutex_spin_exit(&callout_lock);
586 if (!mpsafe) {
587 KERNEL_LOCK(1, curlwp);
588 (*func)(arg);
589 KERNEL_UNLOCK_ONE(curlwp);
590 } else
591 (*func)(arg);
592 mutex_spin_enter(&callout_lock);
593
594 /*
595 * We can't touch 'c' here because it might be
596 * freed already. If LWPs waiting for callout
597 * to complete, awaken them.
598 */
599 ci->ci_data.cpu_callout = NULL;
600 if ((count = ci->ci_data.cpu_callout_nwait) != 0) {
601 ci->ci_data.cpu_callout_nwait = 0;
602 /* sleepq_wake() drops the lock. */
603 sleepq_wake(&callout_sleepq, ci, count);
604 mutex_spin_enter(&callout_lock);
605 }
606 }
607 }
608
609 mutex_spin_exit(&callout_lock);
610 }
611
612 #ifdef DDB
613 static void
614 db_show_callout_bucket(struct callout_circq *bucket)
615 {
616 callout_impl_t *c;
617 db_expr_t offset;
618 const char *name;
619 static char question[] = "?";
620
621 if (CIRCQ_EMPTY(bucket))
622 return;
623
624 for (c = CIRCQ_FIRST(bucket); /*nothing*/; c = CIRCQ_NEXT(&c->c_list)) {
625 db_find_sym_and_offset((db_addr_t)(intptr_t)c->c_func, &name,
626 &offset);
627 name = name ? name : question;
628 #ifdef _LP64
629 #define POINTER_WIDTH "%16lx"
630 #else
631 #define POINTER_WIDTH "%8lx"
632 #endif
633 db_printf("%9d %2d/%-4d " POINTER_WIDTH " %s\n",
634 c->c_time - hardclock_ticks,
635 (int)((bucket - timeout_wheel) / WHEELSIZE),
636 (int)(bucket - timeout_wheel), (u_long) c->c_arg, name);
637
638 if (CIRCQ_LAST(&c->c_list, bucket))
639 break;
640 }
641 }
642
643 void
644 db_show_callout(db_expr_t addr, bool haddr, db_expr_t count, const char *modif)
645 {
646 int b;
647
648 db_printf("hardclock_ticks now: %d\n", hardclock_ticks);
649 #ifdef _LP64
650 db_printf(" ticks wheel arg func\n");
651 #else
652 db_printf(" ticks wheel arg func\n");
653 #endif
654
655 /*
656 * Don't lock the callwheel; all the other CPUs are paused
657 * anyhow, and we might be called in a circumstance where
658 * some other CPU was paused while holding the lock.
659 */
660
661 db_show_callout_bucket(&timeout_todo);
662 for (b = 0; b < BUCKETS; b++)
663 db_show_callout_bucket(&timeout_wheel[b]);
664 }
665 #endif /* DDB */
666