| 603 | } |
| 604 | |
| 605 | static void |
| 606 | softclock_call_cc(struct callout *c, struct callout_cpu *cc, |
| 607 | #ifdef CALLOUT_PROFILING |
| 608 | int *mpcalls, int *lockcalls, int *gcalls, |
| 609 | #endif |
| 610 | int direct) |
| 611 | { |
| 612 | struct rm_priotracker tracker; |
| 613 | callout_func_t *c_func, *drain; |
| 614 | void *c_arg; |
| 615 | struct lock_class *class; |
| 616 | struct lock_object *c_lock; |
| 617 | uintptr_t lock_status; |
| 618 | int c_iflags; |
| 619 | #ifdef SMP |
| 620 | struct callout_cpu *new_cc; |
| 621 | callout_func_t *new_func; |
| 622 | void *new_arg; |
| 623 | int flags, new_cpu; |
| 624 | sbintime_t new_prec, new_time; |
| 625 | #endif |
| 626 | #if defined(DIAGNOSTIC) || defined(CALLOUT_PROFILING) |
| 627 | sbintime_t sbt1, sbt2; |
| 628 | struct timespec ts2; |
| 629 | static sbintime_t maxdt = 2 * SBT_1MS; /* 2 msec */ |
| 630 | static callout_func_t *lastfunc; |
| 631 | #endif |
| 632 | |
| 633 | KASSERT((c->c_iflags & CALLOUT_PENDING) == CALLOUT_PENDING, |
| 634 | ("softclock_call_cc: pend %p %x", c, c->c_iflags)); |
| 635 | KASSERT((c->c_flags & CALLOUT_ACTIVE) == CALLOUT_ACTIVE, |
| 636 | ("softclock_call_cc: act %p %x", c, c->c_flags)); |
| 637 | class = (c->c_lock != NULL) ? LOCK_CLASS(c->c_lock) : NULL; |
| 638 | lock_status = 0; |
| 639 | if (c->c_flags & CALLOUT_SHAREDLOCK) { |
| 640 | if (class == &lock_class_rm) |
| 641 | lock_status = (uintptr_t)&tracker; |
| 642 | else |
| 643 | lock_status = 1; |
| 644 | } |
| 645 | c_lock = c->c_lock; |
| 646 | c_func = c->c_func; |
| 647 | c_arg = c->c_arg; |
| 648 | c_iflags = c->c_iflags; |
| 649 | c->c_iflags &= ~CALLOUT_PENDING; |
| 650 | |
| 651 | cc_exec_curr(cc, direct) = c; |
| 652 | cc_exec_last_func(cc, direct) = c_func; |
| 653 | cc_exec_last_arg(cc, direct) = c_arg; |
| 654 | cc_exec_cancel(cc, direct) = false; |
| 655 | cc_exec_drain(cc, direct) = NULL; |
| 656 | CC_UNLOCK(cc); |
| 657 | if (c_lock != NULL) { |
| 658 | class->lc_lock(c_lock, lock_status); |
| 659 | /* |
| 660 | * The callout may have been cancelled |
| 661 | * while we switched locks. |
| 662 | */ |
no test coverage detected