diff --git a/sys/kern/kern_idle.c b/sys/kern/kern_idle.c index 224ba6391e7c..cb273b76067b 100644 --- a/sys/kern/kern_idle.c +++ b/sys/kern/kern_idle.c @@ -6,25 +6,16 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_ktrace.h" - #include #include #include -#include #include #include #include -#include #include #include #include -#include #include -#ifdef KTRACE -#include -#include -#endif static void idle_setup(void *dummy); SYSINIT(idle_setup, SI_SUB_SCHED_IDLE, SI_ORDER_FIRST, idle_setup, NULL) @@ -32,7 +23,7 @@ SYSINIT(idle_setup, SI_SUB_SCHED_IDLE, SI_ORDER_FIRST, idle_setup, NULL) static void idle_proc(void *dummy); /* - * Setup per-cpu idle process contexts. The AP's shouldn't be running or + * Set up per-cpu idle process contexts. The AP's shouldn't be running or * accessing their idle processes at this point, so don't bother with * locking. */ @@ -78,48 +69,25 @@ idle_setup(void *dummy) } /* - * idle process context + * The actual idle process. */ static void idle_proc(void *dummy) { -#ifdef DIAGNOSTIC - int count; -#endif - struct thread *td; struct proc *p; + struct thread *td; td = curthread; p = td->td_proc; for (;;) { mtx_assert(&Giant, MA_NOTOWNED); -#ifdef DIAGNOSTIC - count = 0; - - while (count >= 0 && sched_runnable() == 0) { -#else - while (sched_runnable() == 0) { -#endif - /* - * This is a good place to put things to be done in - * the background, including sanity checks. - */ - -#ifdef DIAGNOSTIC - if (count++ < 0) - CTR0(KTR_PROC, "idle_proc: timed out waiting" - " for a process"); -#endif - -#if defined(__i386__) || defined(__amd64__) || defined(__ia64__) + while (sched_runnable() == 0) cpu_idle(); -#endif - } mtx_lock_spin(&sched_lock); - p->p_stats->p_ru.ru_nvcsw++; td->td_state = TDS_CAN_RUN; + p->p_stats->p_ru.ru_nvcsw++; mi_switch(); mtx_unlock_spin(&sched_lock); }