* Switch to idle mode (all ticks handled). */
| 758 | * Switch to idle mode (all ticks handled). |
| 759 | */ |
| 760 | sbintime_t |
| 761 | cpu_idleclock(void) |
| 762 | { |
| 763 | sbintime_t now, t; |
| 764 | struct pcpu_state *state; |
| 765 | |
| 766 | if (idletick || busy || |
| 767 | (periodic && (timer->et_flags & ET_FLAGS_PERCPU)) |
| 768 | #ifdef DEVICE_POLLING |
| 769 | || curcpu == CPU_FIRST() |
| 770 | #endif |
| 771 | ) |
| 772 | return (-1); |
| 773 | state = DPCPU_PTR(timerstate); |
| 774 | if (periodic) |
| 775 | now = state->now; |
| 776 | else |
| 777 | now = sbinuptime(); |
| 778 | CTR3(KTR_SPARE2, "idle at %d: now %d.%08x", |
| 779 | curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff)); |
| 780 | t = getnextcpuevent(1); |
| 781 | ET_HW_LOCK(state); |
| 782 | state->idle = 1; |
| 783 | state->nextevent = t; |
| 784 | if (!periodic) |
| 785 | loadtimer(now, 0); |
| 786 | ET_HW_UNLOCK(state); |
| 787 | return (MAX(t - now, 0)); |
| 788 | } |
| 789 | |
| 790 | /* |
| 791 | * Switch to active mode (skip empty ticks). |